diff options
| author | Narayan Kamath <narayan@google.com> | 2017-09-13 12:53:52 +0100 |
|---|---|---|
| committer | Narayan Kamath <narayan@google.com> | 2017-09-13 14:18:03 +0100 |
| commit | fc74cb45eafe51162b10a850016c6d2e1f8fd23c (patch) | |
| tree | 203fb0f2feed47099e5bf999bcaff954f5c0e49d /win32select.c | |
| parent | 9dfd4017adef7eaf179f743bf746254917a4fb74 (diff) | |
| download | platform_external_libevent-fc74cb45eafe51162b10a850016c6d2e1f8fd23c.tar.gz platform_external_libevent-fc74cb45eafe51162b10a850016c6d2e1f8fd23c.tar.bz2 platform_external_libevent-fc74cb45eafe51162b10a850016c6d2e1f8fd23c.zip | |
Revert "Revert "Upgrade to 2.1.8-stable (2017-01-22)." and "Probably Mac build fix?""
This reverts commit 83a0c9c65a60a92d3ea5542596b3ba56db492c37.
Bug: 64543673
Test: make checkbuild
Test: Manual tombstoned test
Change-Id: I84bb128d1dec433195f2cbdbf70236ba17fa9955
Diffstat (limited to 'win32select.c')
| -rw-r--r-- | win32select.c | 53 |
1 files changed, 32 insertions, 21 deletions
diff --git a/win32select.c b/win32select.c index 1743b01..1766858 100644 --- a/win32select.c +++ b/win32select.c @@ -25,6 +25,10 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "event2/event-config.h" +#include "evconfig-private.h" + +#ifdef _WIN32 #include <winsock2.h> #include <windows.h> @@ -38,7 +42,6 @@ #include <errno.h> #include "event2/util.h" -#include "event2/event-config.h" #include "util-internal.h" #include "log-internal.h" #include "event2/event.h" @@ -46,6 +49,7 @@ #include "evmap-internal.h" #include "event2/thread.h" #include "evthread-internal.h" +#include "time-internal.h" #define XFREE(ptr) do { if (ptr) mm_free(ptr); } while (0) @@ -53,7 +57,7 @@ extern struct event_list timequeue; extern struct event_list addqueue; struct win_fd_set { - u_int fd_count; + unsigned int fd_count; SOCKET fd_array[1]; }; @@ -77,8 +81,8 @@ struct win32op { }; static void *win32_init(struct event_base *); -static int win32_add(struct event_base *, evutil_socket_t, short old, short events, void *_idx); -static int win32_del(struct event_base *, evutil_socket_t, short old, short events, void *_idx); +static int win32_add(struct event_base *, evutil_socket_t, short old, short events, void *idx_); +static int win32_del(struct event_base *, evutil_socket_t, short old, short events, void *idx_); static int win32_dispatch(struct event_base *base, struct timeval *); static void win32_dealloc(struct event_base *); @@ -160,7 +164,7 @@ do_fd_clear(struct event_base *base, SOCKET s2; s2 = set->fd_array[i] = set->fd_array[set->fd_count]; - ent2 = evmap_io_get_fdinfo(&base->io, s2); + ent2 = evmap_io_get_fdinfo_(&base->io, s2); if (!ent2) /* This indicates a bug. */ return (0); @@ -174,7 +178,7 @@ do_fd_clear(struct event_base *base, #define NEVENT 32 void * -win32_init(struct event_base *_base) +win32_init(struct event_base *base) { struct win32op *winop; size_t size; @@ -196,9 +200,11 @@ win32_init(struct event_base *_base) winop->readset_out->fd_count = winop->writeset_out->fd_count = winop->exset_out->fd_count = 0; - if (evsig_init(_base) < 0) + if (evsig_init_(base) < 0) winop->signals_are_broken = 1; + evutil_weakrand_seed_(&base->weakrand_seed, 0); + return (winop); err: XFREE(winop->readset_in); @@ -212,10 +218,10 @@ win32_init(struct event_base *_base) int win32_add(struct event_base *base, evutil_socket_t fd, - short old, short events, void *_idx) + short old, short events, void *idx_) { struct win32op *win32op = base->evbase; - struct idx_info *idx = _idx; + struct idx_info *idx = idx_; if ((events & EV_SIGNAL) && win32op->signals_are_broken) return (-1); @@ -237,10 +243,10 @@ win32_add(struct event_base *base, evutil_socket_t fd, int win32_del(struct event_base *base, evutil_socket_t fd, short old, short events, - void *_idx) + void *idx_) { struct win32op *win32op = base->evbase; - struct idx_info *idx = _idx; + struct idx_info *idx = idx_; event_debug(("%s: Removing event for "EV_SOCK_FMT, __func__, EV_SOCK_ARG(fd))); @@ -299,7 +305,7 @@ win32_dispatch(struct event_base *base, struct timeval *tv) win32op->readset_out->fd_count : win32op->writeset_out->fd_count; if (!fd_count) { - long msec = tv ? evutil_tv_to_msec(tv) : LONG_MAX; + long msec = tv ? evutil_tv_to_msec_(tv) : LONG_MAX; /* Sleep's DWORD argument is unsigned long */ if (msec < 0) msec = LONG_MAX; @@ -324,42 +330,45 @@ win32_dispatch(struct event_base *base, struct timeval *tv) } if (win32op->readset_out->fd_count) { - i = rand() % win32op->readset_out->fd_count; + i = evutil_weakrand_range_(&base->weakrand_seed, + 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); + evmap_io_active_(base, s, EV_READ); } } if (win32op->exset_out->fd_count) { - i = rand() % win32op->exset_out->fd_count; + i = evutil_weakrand_range_(&base->weakrand_seed, + 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_WRITE); + evmap_io_active_(base, s, EV_WRITE); } } if (win32op->writeset_out->fd_count) { SOCKET s; - i = rand() % win32op->writeset_out->fd_count; + i = evutil_weakrand_range_(&base->weakrand_seed, + win32op->writeset_out->fd_count); for (j=0; j<win32op->writeset_out->fd_count; ++j) { if (++i >= win32op->writeset_out->fd_count) i = 0; s = win32op->writeset_out->fd_array[i]; - evmap_io_active(base, s, EV_WRITE); + evmap_io_active_(base, s, EV_WRITE); } } return (0); } void -win32_dealloc(struct event_base *_base) +win32_dealloc(struct event_base *base) { - struct win32op *win32op = _base->evbase; + struct win32op *win32op = base->evbase; - evsig_dealloc(_base); + evsig_dealloc_(base); if (win32op->readset_in) mm_free(win32op->readset_in); if (win32op->writeset_in) @@ -375,3 +384,5 @@ win32_dealloc(struct event_base *_base) memset(win32op, 0, sizeof(*win32op)); mm_free(win32op); } + +#endif |
