diff options
author | Brad Smith <brad@cvs.openbsd.org> | 2008-05-02 06:09:12 +0000 |
---|---|---|
committer | Brad Smith <brad@cvs.openbsd.org> | 2008-05-02 06:09:12 +0000 |
commit | aca1b177e06cca0f06297751ac178ab96e04ae4f (patch) | |
tree | 40ed096e545ca29b466eb9e383e5d548f4a090ff /lib/libevent/select.c | |
parent | 0a4d9575993ffee6da26d8e1d2569a946fce5f41 (diff) |
Update to libevent 1.3e while retaining our local changes.
"No objection" millert@
"the diff looks and works fine" reyk@
Diffstat (limited to 'lib/libevent/select.c')
-rw-r--r-- | lib/libevent/select.c | 39 |
1 files changed, 18 insertions, 21 deletions
diff --git a/lib/libevent/select.c b/lib/libevent/select.c index 75a344a3a56..de55ae057fe 100644 --- a/lib/libevent/select.c +++ b/lib/libevent/select.c @@ -1,4 +1,4 @@ -/* $OpenBSD: select.c,v 1.13 2007/03/19 15:12:49 millert Exp $ */ +/* $OpenBSD: select.c,v 1.14 2008/05/02 06:09:11 brad Exp $ */ /* * Copyright 2000-2002 Niels Provos <provos@citi.umich.edu> @@ -36,6 +36,9 @@ #else #include <sys/_time.h> #endif +#ifdef HAVE_SYS_SELECT_H +#include <sys/select.h> +#endif #include <sys/queue.h> #include <sys/tree.h> #include <signal.h> @@ -57,8 +60,6 @@ #define howmany(x, y) (((x)+((y)-1))/(y)) #endif -extern volatile sig_atomic_t evsignal_caught; - struct selectop { int event_fds; /* Highest fd in fd set */ int event_fdsz; @@ -68,15 +69,14 @@ struct selectop { fd_set *event_writeset_out; struct event **event_r_by_fd; struct event **event_w_by_fd; - sigset_t evsigmask; }; -void *select_init (void); +void *select_init (struct event_base *); int select_add (void *, struct event *); int select_del (void *, struct event *); int select_recalc (struct event_base *, void *, int); int select_dispatch (struct event_base *, void *, struct timeval *); -void select_dealloc (void *); +void select_dealloc (struct event_base *, void *); const struct eventop selectops = { "select", @@ -91,7 +91,7 @@ const struct eventop selectops = { static int select_resize(struct selectop *sop, int fdsz); void * -select_init(void) +select_init(struct event_base *base) { struct selectop *sop; @@ -104,7 +104,7 @@ select_init(void) select_resize(sop, howmany(32 + 1, NFDBITS)*sizeof(fd_mask)); - evsignal_init(&sop->evsigmask); + evsignal_init(base); return (sop); } @@ -114,7 +114,7 @@ static void check_selectop(struct selectop *sop) { int i; - for (i=0;i<=sop->event_fds;++i) { + for (i = 0; i <= sop->event_fds; ++i) { if (FD_ISSET(i, sop->event_readset_in)) { assert(sop->event_r_by_fd[i]); assert(sop->event_r_by_fd[i]->ev_events & EV_READ); @@ -148,7 +148,7 @@ select_recalc(struct event_base *base, void *arg, int max) check_selectop(sop); - return (evsignal_recalc(&sop->evsigmask)); + return (0); } int @@ -164,15 +164,10 @@ select_dispatch(struct event_base *base, void *arg, struct timeval *tv) memcpy(sop->event_writeset_out, sop->event_writeset_in, sop->event_fdsz); - if (evsignal_deliver(&sop->evsigmask) == -1) - return (-1); - res = select(sop->event_fds + 1, sop->event_readset_out, sop->event_writeset_out, NULL, tv); check_selectop(sop); - if (evsignal_recalc(&sop->evsigmask) == -1) - return (-1); if (res == -1) { if (errno != EINTR) { @@ -180,10 +175,11 @@ select_dispatch(struct event_base *base, void *arg, struct timeval *tv) return (-1); } - evsignal_process(); + evsignal_process(base); return (0); - } else if (evsignal_caught) - evsignal_process(); + } else if (base->sig.evsignal_caught) { + evsignal_process(base); + } event_debug(("%s: select reports %d", __func__, res)); @@ -281,7 +277,7 @@ select_add(void *arg, struct event *ev) struct selectop *sop = arg; if (ev->ev_events & EV_SIGNAL) - return (evsignal_add(&sop->evsigmask, ev)); + return (evsignal_add(ev)); check_selectop(sop); /* @@ -332,7 +328,7 @@ select_del(void *arg, struct event *ev) check_selectop(sop); if (ev->ev_events & EV_SIGNAL) - return (evsignal_del(&sop->evsigmask, ev)); + return (evsignal_del(ev)); if (sop->event_fds < ev->ev_fd) { check_selectop(sop); @@ -354,10 +350,11 @@ select_del(void *arg, struct event *ev) } void -select_dealloc(void *arg) +select_dealloc(struct event_base *base, void *arg) { struct selectop *sop = arg; + evsignal_dealloc(base); if (sop->event_readset_in) free(sop->event_readset_in); if (sop->event_writeset_in) |