]> granicus.if.org Git - libevent/commitdiff
fix a bug where deleting signals with kqueue would delete subsequent adds
authorNiels Provos <provos@gmail.com>
Fri, 11 Jul 2008 15:15:04 +0000 (15:15 +0000)
committerNiels Provos <provos@gmail.com>
Fri, 11 Jul 2008 15:15:04 +0000 (15:15 +0000)
svn:r899

ChangeLog
kqueue.c
test/regress.c

index 4fa55b3cc772b829943b8e9da63eb9538a1372f9..f3e6696264805d9024bee600efbb7e123eade4ab 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -116,6 +116,7 @@ Changes in current version:
  o Reject negative Content-Length headers; anonymous bug report
  o Detect CLOCK_MONOTONIC at runtime for evdns; anonymous bug report   
  o Various HTTP correctness fixes from Scott Lamb
+ o Fix a bug where deleting signals with the kqueue backend would cause subsequent adds to fail
        
 Changes in 1.4.0:
  o allow \r or \n individually to separate HTTP headers instead of the standard "\r\n"; from Charles Kerr.
index 862aa2bcba76e46d94c00f043ff3c28c512ebb7a..6627171e6a5ce002e3ea0a4caaa2ae33996b1a25 100644 (file)
--- a/kqueue.c
+++ b/kqueue.c
@@ -364,14 +364,17 @@ kq_del(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;
                kev.filter = EVFILT_SIGNAL;
                kev.flags = EV_DELETE;
                
-               if (kq_insert(kqop, &kev) == -1)
-                       return (-1);
+               /* Because we insert signal events immediately, we need to
+                * delete them immediately, too */
+                if (kevent(kqop->kq, &kev, 1, NULL, 0, &timeout) == -1)
+                       return (-1);
 
                if (_evsignal_restore_handler(ev->ev_base, nsignal) == -1)
                        return (-1);
index 6c13deb84f7e727ed2260b046e022cc6eda6ddc7..b19402daee3d1f3b73bfbd5858fc43365ccbd1ef 100644 (file)
@@ -560,6 +560,9 @@ test_simplesignal(void)
        setup_test("Simple signal: ");
        signal_set(&ev, SIGALRM, signal_cb, &ev);
        signal_add(&ev, NULL);
+       /* find bugs in which operations are re-ordered */
+       signal_del(&ev);
+       signal_add(&ev, NULL);
 
        memset(&itv, 0, sizeof(itv));
        itv.it_value.tv_sec = 1;