| Index: third_party/libevent/select.c
|
| diff --git a/third_party/libevent/select.c b/third_party/libevent/select.c
|
| index 7faafe4ec12a899c709adfa87ca37543465fd633..3f73331317749bee6f161fc3d7cda4cd9b36dc7c 100644
|
| --- a/third_party/libevent/select.c
|
| +++ b/third_party/libevent/select.c
|
| @@ -34,7 +34,7 @@
|
| #ifdef HAVE_SYS_TIME_H
|
| #include <sys/time.h>
|
| #else
|
| -#include <sys/_time.h>
|
| +#include <sys/_libevent_time.h>
|
| #endif
|
| #ifdef HAVE_SYS_SELECT_H
|
| #include <sys/select.h>
|
| @@ -51,6 +51,7 @@
|
| #endif
|
|
|
| #include "event.h"
|
| +#include "evutil.h"
|
| #include "event-internal.h"
|
| #include "evsignal.h"
|
| #include "log.h"
|
| @@ -59,6 +60,13 @@
|
| #define howmany(x, y) (((x)+((y)-1))/(y))
|
| #endif
|
|
|
| +#ifndef _EVENT_HAVE_FD_MASK
|
| +/* This type is mandatory, but Android doesn't define it. */
|
| +#undef NFDBITS
|
| +#define NFDBITS (sizeof(long)*8)
|
| +typedef unsigned long fd_mask;
|
| +#endif
|
| +
|
| struct selectop {
|
| int event_fds; /* Highest fd in fd set */
|
| int event_fdsz;
|
| @@ -94,7 +102,7 @@ select_init(struct event_base *base)
|
| struct selectop *sop;
|
|
|
| /* Disable select when this environment variable is set */
|
| - if (getenv("EVENT_NOSELECT"))
|
| + if (evutil_getenv("EVENT_NOSELECT"))
|
| return (NULL);
|
|
|
| if (!(sop = calloc(1, sizeof(struct selectop))))
|
| @@ -137,7 +145,7 @@ check_selectop(struct selectop *sop)
|
| static int
|
| select_dispatch(struct event_base *base, void *arg, struct timeval *tv)
|
| {
|
| - int res, i;
|
| + int res, i, j;
|
| struct selectop *sop = arg;
|
|
|
| check_selectop(sop);
|
| @@ -167,8 +175,12 @@ select_dispatch(struct event_base *base, void *arg, struct timeval *tv)
|
| event_debug(("%s: select reports %d", __func__, res));
|
|
|
| check_selectop(sop);
|
| - for (i = 0; i <= sop->event_fds; ++i) {
|
| + i = random() % (sop->event_fds+1);
|
| + for (j = 0; j <= sop->event_fds; ++j) {
|
| struct event *r_ev = NULL, *w_ev = NULL;
|
| + if (++i >= sop->event_fds+1)
|
| + i = 0;
|
| +
|
| res = 0;
|
| if (FD_ISSET(i, sop->event_readset_out)) {
|
| r_ev = sop->event_r_by_fd[i];
|
|
|