do not remove kq inkernel flag before event_del gets to it; bug reported by

Tassilo von Parseval; also add a test for this behavior.


svn:r190
This commit is contained in:
Niels Provos 2005-12-17 20:15:25 +00:00
parent 0c48c70680
commit 139e862e32
3 changed files with 47 additions and 3 deletions

1
README
View File

@ -24,5 +24,6 @@ fixing bugs:
Mike Davis
William Ahern
Alexander von Gernler
Artur Grabowski
If I have forgotten your name, please contact me.

View File

@ -266,10 +266,8 @@ kq_dispatch(struct event_base *base, void *arg, struct timeval *tv)
if (!which)
continue;
if (!(ev->ev_events & EV_PERSIST)) {
ev->ev_flags &= ~EVLIST_X_KQINKERNEL;
if (!(ev->ev_events & EV_PERSIST))
event_del(ev);
}
event_active(ev, which,
ev->ev_events & EV_SIGNAL ? events[i].data : 1);

View File

@ -656,6 +656,49 @@ test_multiple_events_for_same_fd(void)
int decode_int(u_int32_t *pnumber, struct evbuffer *evbuf);
void
read_once_cb(int fd, short event, void *arg)
{
char buf[256];
int len;
len = read(fd, buf, sizeof(buf));
if (called) {
test_ok = 0;
} else if (len) {
/* Assumes global pair[0] can be used for writing */
write(pair[0], TEST1, strlen(TEST1)+1);
test_ok = 1;
}
called++;
}
void
test_want_only_once(void)
{
struct event ev;
struct timeval tv;
/* Very simple read test */
setup_test("Want read only once: ");
write(pair[0], TEST1, strlen(TEST1)+1);
/* Setup the loop termination */
timerclear(&tv);
tv.tv_sec = 1;
event_loopexit(&tv);
event_set(&ev, pair[1], EV_READ, read_once_cb, &ev);
if (event_add(&ev, NULL) == -1)
exit(1);
event_dispatch();
cleanup_test();
}
#define TEST_MAX_INT 6
void
@ -855,6 +898,8 @@ main (int argc, char **argv)
test_multiple_events_for_same_fd();
test_want_only_once();
evtag_test();
rpc_test();