from trunk: fix a bug where deleting signals with kqueue would delete subsequent adds

svn:r900
This commit is contained in:
Niels Provos 2008-07-11 15:17:35 +00:00
parent 537e122101
commit 459c78a20a
3 changed files with 9 additions and 2 deletions

View File

@ -5,6 +5,7 @@ Changes in 1.4.6-stable:
o Support multi-line HTTP headers; based on a patch from Moshe Litvin
o Reject negative Content-Length headers; anonymous bug report
o Detect CLOCK_MONOTONIC at runtime for evdns; anonymous bug report
o Fix a bug where deleting signals with the kqueue backend would cause subsequent adds to fail
Changes in 1.4.5-stable:
o Fix connection keep-alive behavior for HTTP/1.0

View File

@ -362,14 +362,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);

View File

@ -517,6 +517,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;