aboutsummaryrefslogtreecommitdiffstats
path: root/poll.c
diff options
context:
space:
mode:
authorNarayan Kamath <narayan@google.com>2017-09-13 12:53:52 +0100
committerNarayan Kamath <narayan@google.com>2017-09-13 14:18:03 +0100
commitfc74cb45eafe51162b10a850016c6d2e1f8fd23c (patch)
tree203fb0f2feed47099e5bf999bcaff954f5c0e49d /poll.c
parent9dfd4017adef7eaf179f743bf746254917a4fb74 (diff)
downloadplatform_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 'poll.c')
-rw-r--r--poll.c38
1 files changed, 23 insertions, 15 deletions
diff --git a/poll.c b/poll.c
index 04d311b..fe44071 100644
--- a/poll.c
+++ b/poll.c
@@ -27,9 +27,12 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "event2/event-config.h"
+#include "evconfig-private.h"
+
+#ifdef EVENT__HAVE_POLL
#include <sys/types.h>
-#ifdef _EVENT_HAVE_SYS_TIME_H
+#ifdef EVENT__HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
#include <sys/queue.h>
@@ -48,6 +51,7 @@
#include "evmap-internal.h"
#include "event2/thread.h"
#include "evthread-internal.h"
+#include "time-internal.h"
struct pollidx {
int idxplus1;
@@ -63,8 +67,8 @@ struct pollop {
};
static void *poll_init(struct event_base *);
-static int poll_add(struct event_base *, int, short old, short events, void *_idx);
-static int poll_del(struct event_base *, int, short old, short events, void *_idx);
+static int poll_add(struct event_base *, int, short old, short events, void *idx);
+static int poll_del(struct event_base *, int, short old, short events, void *idx);
static int poll_dispatch(struct event_base *, struct timeval *);
static void poll_dealloc(struct event_base *);
@@ -88,7 +92,9 @@ poll_init(struct event_base *base)
if (!(pollop = mm_calloc(1, sizeof(struct pollop))))
return (NULL);
- evsig_init(base);
+ evsig_init_(base);
+
+ evutil_weakrand_seed_(&base->weakrand_seed, 0);
return (pollop);
}
@@ -127,7 +133,7 @@ poll_dispatch(struct event_base *base, struct timeval *tv)
nfds = pop->nfds;
-#ifndef _EVENT_DISABLE_THREAD_SUPPORT
+#ifndef EVENT__DISABLE_THREAD_SUPPORT
if (base->th_base_lock) {
/* If we're using this backend in a multithreaded setting,
* then we need to work on a copy of event_set, so that we can
@@ -155,7 +161,7 @@ poll_dispatch(struct event_base *base, struct timeval *tv)
#endif
if (tv != NULL) {
- msec = evutil_tv_to_msec(tv);
+ msec = evutil_tv_to_msec_(tv);
if (msec < 0 || msec > INT_MAX)
msec = INT_MAX;
}
@@ -180,7 +186,7 @@ poll_dispatch(struct event_base *base, struct timeval *tv)
if (res == 0 || nfds == 0)
return (0);
- i = random() % nfds;
+ i = evutil_weakrand_range_(&base->weakrand_seed, nfds);
for (j = 0; j < nfds; j++) {
int what;
if (++i == nfds)
@@ -192,7 +198,7 @@ poll_dispatch(struct event_base *base, struct timeval *tv)
res = 0;
/* If the file gets closed notify */
- if (what & (POLLHUP|POLLERR))
+ if (what & (POLLHUP|POLLERR|POLLNVAL))
what |= POLLIN|POLLOUT;
if (what & POLLIN)
res |= EV_READ;
@@ -201,18 +207,18 @@ poll_dispatch(struct event_base *base, struct timeval *tv)
if (res == 0)
continue;
- evmap_io_active(base, event_set[i].fd, res);
+ evmap_io_active_(base, event_set[i].fd, res);
}
return (0);
}
static int
-poll_add(struct event_base *base, int fd, short old, short events, void *_idx)
+poll_add(struct event_base *base, int fd, short old, short events, void *idx_)
{
struct pollop *pop = base->evbase;
struct pollfd *pfd = NULL;
- struct pollidx *idx = _idx;
+ struct pollidx *idx = idx_;
int i;
EVUTIL_ASSERT((events & EV_SIGNAL) == 0);
@@ -269,11 +275,11 @@ poll_add(struct event_base *base, int fd, short old, short events, void *_idx)
*/
static int
-poll_del(struct event_base *base, int fd, short old, short events, void *_idx)
+poll_del(struct event_base *base, int fd, short old, short events, void *idx_)
{
struct pollop *pop = base->evbase;
struct pollfd *pfd = NULL;
- struct pollidx *idx = _idx;
+ struct pollidx *idx = idx_;
int i;
EVUTIL_ASSERT((events & EV_SIGNAL) == 0);
@@ -307,7 +313,7 @@ poll_del(struct event_base *base, int fd, short old, short events, void *_idx)
*/
memcpy(&pop->event_set[i], &pop->event_set[pop->nfds],
sizeof(struct pollfd));
- idx = evmap_io_get_fdinfo(&base->io, pop->event_set[i].fd);
+ idx = evmap_io_get_fdinfo_(&base->io, pop->event_set[i].fd);
EVUTIL_ASSERT(idx);
EVUTIL_ASSERT(idx->idxplus1 == pop->nfds + 1);
idx->idxplus1 = i + 1;
@@ -322,7 +328,7 @@ poll_dealloc(struct event_base *base)
{
struct pollop *pop = base->evbase;
- evsig_dealloc(base);
+ evsig_dealloc_(base);
if (pop->event_set)
mm_free(pop->event_set);
if (pop->event_set_copy)
@@ -331,3 +337,5 @@ poll_dealloc(struct event_base *base)
memset(pop, 0, sizeof(struct pollop));
mm_free(pop);
}
+
+#endif /* EVENT__HAVE_POLL */