summaryrefslogtreecommitdiff
path: root/ev_kqueue.c
diff options
context:
space:
mode:
authorroot <root>2007-11-23 05:28:17 +0000
committerroot <root>2007-11-23 05:28:17 +0000
commitf8b4f278bfcd0d7207ce21570247a58854fa2207 (patch)
treeeb38e0902792928c3250bedfd2e947587b6e78c4 /ev_kqueue.c
parent2ce3b6d320c115f0de28061989453813ada11237 (diff)
minor kqueue optimisation
Diffstat (limited to 'ev_kqueue.c')
-rw-r--r--ev_kqueue.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/ev_kqueue.c b/ev_kqueue.c
index 54cd5eb..a69c0a7 100644
--- a/ev_kqueue.c
+++ b/ev_kqueue.c
@@ -57,17 +57,20 @@ kqueue_change (EV_P_ int fd, int filter, int flags, int fflags)
static void
kqueue_modify (EV_P_ int fd, int oev, int nev)
{
- /* to detect close/reopen reliably, we have to remove and re-add */
- /* event requests even when oev == nev */
+ if (oev != nev)
+ {
+ if (oev & EV_READ)
+ kqueue_change (EV_A_ fd, EVFILT_READ , EV_DELETE, 0);
- if (oev & EV_READ)
- kqueue_change (EV_A_ fd, EVFILT_READ, EV_DELETE, 0);
+ if (oev & EV_WRITE)
+ kqueue_change (EV_A_ fd, EVFILT_WRITE, EV_DELETE, 0);
+ }
- if (oev & EV_WRITE)
- kqueue_change (EV_A_ fd, EVFILT_WRITE, EV_DELETE, 0);
+ /* to detect close/reopen reliably, we have to re-add */
+ /* event requests even when oev == nev */
if (nev & EV_READ)
- kqueue_change (EV_A_ fd, EVFILT_READ, EV_ADD, NOTE_EOF);
+ kqueue_change (EV_A_ fd, EVFILT_READ , EV_ADD, NOTE_EOF);
if (nev & EV_WRITE)
kqueue_change (EV_A_ fd, EVFILT_WRITE, EV_ADD, NOTE_EOF);