summaryrefslogtreecommitdiff
path: root/kqueue.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2007-11-25 17:15:28 +0000
committerNick Mathewson <nickm@torproject.org>2007-11-25 17:15:28 +0000
commit2823cb057927110719a7203c2346d6be8aa8468f (patch)
tree363e12bdbcfd225de521ae1a943ce950bd841189 /kqueue.c
parent566ca340224c39e517f14d7a45cde68b874acde1 (diff)
downloadlibevent-2823cb057927110719a7203c2346d6be8aa8468f.tar.gz
r14944@tombo: nickm | 2007-11-25 12:12:28 -0500
Make kqueue pass more unit tests. svn:r544
Diffstat (limited to 'kqueue.c')
-rw-r--r--kqueue.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/kqueue.c b/kqueue.c
index 8f92c2cd..1f2e3514 100644
--- a/kqueue.c
+++ b/kqueue.c
@@ -296,6 +296,7 @@ kq_add(void *arg, struct event *ev)
if (ev->ev_events & EV_SIGNAL) {
int nsignal = EVENT_SIGNAL(ev);
+ struct timespec timeout = { 0, 0 };
memset(&kev, 0, sizeof(kev));
kev.ident = nsignal;
@@ -304,11 +305,14 @@ kq_add(void *arg, struct event *ev)
if (!(ev->ev_events & EV_PERSIST))
kev.flags |= EV_ONESHOT;
kev.udata = PTR_TO_UDATA(ev);
-
- if (kq_insert(kqop, &kev) == -1)
- return (-1);
- if (signal(nsignal, kq_sighandler) == SIG_ERR)
+ /* Be ready for the signal if it is sent any time between
+ * now and the next call to kq_dispatch. */
+ if (kevent(kqop->kq, &kev, 1, NULL, 0, &timeout) == -1)
+ return (-1);
+
+ if (_evsignal_set_handler(ev->ev_base, nsignal,
+ kq_sighandler) == -1)
return (-1);
ev->ev_flags |= EVLIST_X_KQINKERNEL;
@@ -372,7 +376,7 @@ kq_del(void *arg, struct event *ev)
if (kq_insert(kqop, &kev) == -1)
return (-1);
- if (signal(nsignal, SIG_DFL) == SIG_ERR)
+ if (_evsignal_restore_handler(ev->ev_base, nsignal) == -1)
return (-1);
ev->ev_flags &= ~EVLIST_X_KQINKERNEL;