mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
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:
parent
0c48c70680
commit
139e862e32
1
README
1
README
@ -24,5 +24,6 @@ fixing bugs:
|
||||
Mike Davis
|
||||
William Ahern
|
||||
Alexander von Gernler
|
||||
Artur Grabowski
|
||||
|
||||
If I have forgotten your name, please contact me.
|
||||
|
4
kqueue.c
4
kqueue.c
@ -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);
|
||||
|
@ -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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user