mirror of
https://github.com/cuberite/libevent.git
synced 2025-09-13 06:16:10 -04:00
detect kqueue bug in Mac OS X 10.4; from Nick Mathewson
svn:r165
This commit is contained in:
parent
145c11fd6d
commit
57fafe6b5f
21
kqueue.c
21
kqueue.c
@ -122,6 +122,27 @@ kq_init(void)
|
||||
}
|
||||
kqueueop->nevents = NEVENT;
|
||||
|
||||
/* Check for Mac OS X kqueue bug. */
|
||||
kqueueop->changes[0].ident = -1;
|
||||
kqueueop->changes[0].filter = EVFILT_READ;
|
||||
kqueueop->changes[0].flags = EV_ADD;
|
||||
/*
|
||||
* If kqueue works, then kevent will succeed, and it will
|
||||
* stick an error in events[0]. If kqueue is broken, then
|
||||
* kevent will fail.
|
||||
*/
|
||||
if (kevent(kq,
|
||||
kqueueop->changes, 1, kqueueop->events, NEVENT, NULL) != 1 ||
|
||||
kqueueop->events[0].ident != -1 ||
|
||||
kqueueop->events[0].flags != EV_ERROR) {
|
||||
event_warn("%s: detected broken kqueue; not using.", __func__);
|
||||
free(kqueueop->changes);
|
||||
free(kqueueop->events);
|
||||
free(kqueueop);
|
||||
close(kq);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
return (kqueueop);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user