]> Sergey Matveev's repositories - public-inbox.git/commitdiff
ds: always use EV_ADD with EV_SET
authorEric Wong <e@80x24.org>
Mon, 24 Jun 2019 02:52:47 +0000 (02:52 +0000)
committerEric Wong <e@80x24.org>
Mon, 24 Jun 2019 05:26:27 +0000 (05:26 +0000)
kqueue EV_ONESHOT semantics are different than epoll
EPOLLONESHOT.  epoll only disables watches for that event while
keeping the item in the rbtree for future EPOLL_CTL_MOD.  kqueue
removes the watch from the filter set entirely, necessitating
the use of EV_ADD for future modifications.

lib/PublicInbox/DS.pm

index 0e48ed07cc380e05f811ad919f5f921966dae72b..8f77ce24b20ed5171f30720d88c83469fe2b28d7 100644 (file)
@@ -321,7 +321,7 @@ sub kq_flag ($$) {
         my $fl = EV_ADD() | EV_ENABLE();
         ($ev & EPOLLONESHOT) ? ($fl|EV_ONESHOT()) : $fl;
     } else {
-        EV_DISABLE();
+        EV_ADD() | EV_DISABLE();
     }
 }
 
@@ -364,8 +364,8 @@ retry:
         }
     }
     elsif ($HaveKQueue) {
-        $KQueue->EV_SET($fd, EVFILT_READ(), EV_ADD() | kq_flag(EPOLLIN, $ev));
-        $KQueue->EV_SET($fd, EVFILT_WRITE(), EV_ADD() | kq_flag(EPOLLOUT, $ev));
+        $KQueue->EV_SET($fd, EVFILT_READ(), kq_flag(EPOLLIN, $ev));
+        $KQueue->EV_SET($fd, EVFILT_WRITE(), kq_flag(EPOLLOUT, $ev));
     }
 
     Carp::cluck("PublicInbox::DS::new blowing away existing descriptor map for fd=$fd ($DescriptorMap{$fd})")