diff options
Diffstat (limited to 'poll.c')
-rw-r--r-- | poll.c | 38 |
1 files changed, 15 insertions, 23 deletions
@@ -27,12 +27,9 @@ * 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> @@ -51,7 +48,6 @@ #include "evmap-internal.h" #include "event2/thread.h" #include "evthread-internal.h" -#include "time-internal.h" struct pollidx { int idxplus1; @@ -67,8 +63,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 *); @@ -92,9 +88,7 @@ poll_init(struct event_base *base) if (!(pollop = mm_calloc(1, sizeof(struct pollop)))) return (NULL); - evsig_init_(base); - - evutil_weakrand_seed_(&base->weakrand_seed, 0); + evsig_init(base); return (pollop); } @@ -133,7 +127,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 @@ -161,7 +155,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; } @@ -186,7 +180,7 @@ poll_dispatch(struct event_base *base, struct timeval *tv) if (res == 0 || nfds == 0) return (0); - i = evutil_weakrand_range_(&base->weakrand_seed, nfds); + i = random() % nfds; for (j = 0; j < nfds; j++) { int what; if (++i == nfds) @@ -198,7 +192,7 @@ poll_dispatch(struct event_base *base, struct timeval *tv) res = 0; /* If the file gets closed notify */ - if (what & (POLLHUP|POLLERR|POLLNVAL)) + if (what & (POLLHUP|POLLERR)) what |= POLLIN|POLLOUT; if (what & POLLIN) res |= EV_READ; @@ -207,18 +201,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); @@ -275,11 +269,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); @@ -313,7 +307,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; @@ -328,7 +322,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) @@ -337,5 +331,3 @@ poll_dealloc(struct event_base *base) memset(pop, 0, sizeof(struct pollop)); mm_free(pop); } - -#endif /* EVENT__HAVE_POLL */ |