+ if(io_tree.tail) {
+ io_t *last = io_tree.tail->data;
+ fds = last->fd + 1;
+ }
+
+#ifdef HAVE_MINGW
+ LeaveCriticalSection(&mutex);
+#endif
+ int n = select(fds, &readable, &writable, NULL, tv);
+#ifdef HAVE_MINGW
+ EnterCriticalSection(&mutex);
+#endif
+
+ if(n < 0) {
+ if(sockwouldblock(errno))
+ continue;
+ else
+ return false;
+ }
+
+ if(!n)
+ continue;
+
+ for splay_each(io_t, io, &io_tree) {
+ if(FD_ISSET(io->fd, &writable))
+ io->cb(io->data, IO_WRITE);
+ else if(FD_ISSET(io->fd, &readable))
+ io->cb(io->data, IO_READ);