summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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);