Properly use return value of select to count the number of events
This commit is contained in:
+1
-1
@@ -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
@@ -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++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user