#ifdef HAVE_MINGW
void io_add_event(io_t *io, io_cb_t cb, void *data, WSAEVENT event) {
- io_add(io, cb, data, -1, 0);
io->event = event;
+ io_add(io, cb, data, -1, 0);
}
#endif
fd_set writable;
while(running) {
- memcpy(&readable, &readfds, sizeof readable);
- memcpy(&writable, &writefds, sizeof writable);
struct timeval diff;
struct timeval *tv = get_time_remaining(&diff);
+ memcpy(&readable, &readfds, sizeof readable);
+ memcpy(&writable, &writefds, sizeof writable);
int fds = 0;
io->cb(io->data, IO_WRITE);
else if(FD_ISSET(io->fd, &readable))
io->cb(io->data, IO_READ);
+ else
+ continue;
+
+ /*
+ There are scenarios in which the callback will remove another io_t from the tree
+ (e.g. closing a double connection). Since splay_each does not support that, we
+ need to exit the loop now. That's okay, since any remaining events will get picked
+ up by the next select() call.
+ */
+ break;
}
}
#else