diff options
Diffstat (limited to 'WIN32-Code')
-rw-r--r-- | WIN32-Code/win32.c | 37 |
1 files changed, 26 insertions, 11 deletions
diff --git a/WIN32-Code/win32.c b/WIN32-Code/win32.c index aa73192f..4c316c9a 100644 --- a/WIN32-Code/win32.c +++ b/WIN32-Code/win32.c @@ -282,8 +282,9 @@ win32_dispatch(struct event_base *base, struct timeval *tv) { struct win32op *win32op = base->evbase; int res = 0; - unsigned i; + unsigned j, i; int fd_count; + SOCKET s; fd_set_copy(win32op->readset_out, win32op->readset_in); fd_set_copy(win32op->exset_out, win32op->readset_in); @@ -314,19 +315,33 @@ win32_dispatch(struct event_base *base, struct timeval *tv) evsig_process(base); } - for (i=0; i<win32op->readset_out->fd_count; ++i) { - SOCKET s = win32op->readset_out->fd_array[i]; - evmap_io_active(base, s, EV_READ); + if (win32op->readset_out->fd_count) { + i = rand() % win32op->readset_out->fd_count; + for (j=0; j<win32op->readset_out->fd_count; ++j) { + if (++i >= win32op->readset_out->fd_count) + i = 0; + s = win32op->readset_out->fd_array[i]; + evmap_io_active(base, s, EV_READ); + } } - for (i=0; i<win32op->exset_out->fd_count; ++i) { - SOCKET s = win32op->exset_out->fd_array[i]; - evmap_io_active(base, s, EV_READ); + if (win32op->exset_out->fd_count) { + i = rand() % win32op->exset_out->fd_count; + for (j=0; j<win32op->exset_out->fd_count; ++j) { + if (++i >= win32op-exset_out->fd_count) + i = 0; + s = win32op->exset_out->fd_array[i]; + evmap_io_active(base, s, EV_READ); + } } - for (i=0; i<win32op->writeset_out->fd_count; ++i) { - SOCKET s = win32op->writeset_out->fd_array[i]; - evmap_io_active(base, s, EV_WRITE); + if (win32op->writeset_out->fd_count) { + i = rand() % win32op->writeset_out->fd_count; + for (j=0; j<win32op->writeset_out->fd_count; ++j) { + if (++i >= win32op-exset_out->fd_count) + i = 0; + SOCKET s = win32op->writeset_out->fd_array[i]; + evmap_io_active(base, s, EV_WRITE); + } } - return (0); } |