Properly use return value of select to count the number of events

This commit is contained in:
Nils O. Selåsdal
2013-06-30 14:34:19 +02:00
parent 1e0e840ee5
commit 89232426e0
2 changed files with 3 additions and 2 deletions
+1 -1
View File
@@ -183,7 +183,7 @@ again:
fd->callback(mux_, fd, events); fd->callback(mux_, fd, events);
//be sure not to use fd after the callback, it might been removed. //be sure not to use fd after the callback, it might been removed.
mux->pending_events[i].data.ptr = NULL; mux->pending_events[i].data.ptr = NULL; //clear from pending list
event_cnt++; event_cnt++;
} }
+2 -1
View File
@@ -168,17 +168,18 @@ again:
} }
if (FD_ISSET(mux->descriptors[i]->fd, &read_set)) { if (FD_ISSET(mux->descriptors[i]->fd, &read_set)) {
rc--;
events |= MUX_EV_READ; events |= MUX_EV_READ;
} }
if (FD_ISSET(mux->descriptors[i]->fd, &write_set)) { if (FD_ISSET(mux->descriptors[i]->fd, &write_set)) {
rc--;
events |= MUX_EV_WRITE; events |= MUX_EV_WRITE;
} }
if (events) { if (events) {
assert(mux->descriptors[i]->callback != NULL); assert(mux->descriptors[i]->callback != NULL);
mux->descriptors[i]->callback(mux_, mux->descriptors[i], events); mux->descriptors[i]->callback(mux_, mux->descriptors[i], events);
rc--;
event_cnt++; event_cnt++;
} }
} }