]> Sergey Matveev's repositories - public-inbox.git/commitdiff
ds: get rid of redundant and unnecessary POLL* constants
authorEric Wong <e@80x24.org>
Mon, 24 Jun 2019 02:52:15 +0000 (02:52 +0000)
committerEric Wong <e@80x24.org>
Mon, 24 Jun 2019 05:26:26 +0000 (05:26 +0000)
EPOLL* constants already match their POLL* counterparts and
there's no way Linux can ever diverge or change the values
of those constants.  So we'll favor the EPOLL* ones since we
use EPOLLEXCLUSIVE, already.

For weird stuff like kqueue, we'd need to keep maintaining
the mapping, anyways.

lib/PublicInbox/DS.pm

index eb468f5720f698d2f3f786a6c23e7e226a42d378..bff12de51da8c3d81ede72efef89cd081fcd57d4 100644 (file)
@@ -29,19 +29,14 @@ use PublicInbox::Syscall qw(:epoll);
 use fields ('sock',              # underlying socket
             'wbuf',              # arrayref of coderefs or GLOB refs
             'wbuf_off',  # offset into first element of wbuf to start writing at
-            'event_watch',       # bitmask of events the client is interested in (POLLIN,OUT,etc.)
+            'event_watch',       # bitmask of events the client is interested in
+                                 # (EPOLLIN,OUT,etc.)
             );
 
 use Errno  qw(EAGAIN EINVAL);
 use Carp   qw(croak confess);
 use File::Temp qw(tempfile);
 
-use constant POLLIN        => 1;
-use constant POLLOUT       => 4;
-use constant POLLERR       => 8;
-use constant POLLHUP       => 16;
-use constant POLLNVAL      => 32;
-
 our $HAVE_KQUEUE = eval { require IO::KQueue; 1 };
 
 our (
@@ -403,19 +398,19 @@ sub new {
     Carp::cluck("undef sock and/or fd in PublicInbox::DS->new.  sock=" . ($sock || "") . ", fd=" . ($fd || ""))
         unless $sock && $fd;
 
-    my $ev = $self->{event_watch} = POLLERR|POLLHUP|POLLNVAL;
+    my $ev = $self->{event_watch} = 0;
 
     _InitPoller();
 
     if ($HaveEpoll) {
         if ($exclusive) {
-            $ev = $self->{event_watch} = EPOLLIN|EPOLLERR|EPOLLHUP|$EPOLLEXCLUSIVE;
+            $ev = $self->{event_watch} = EPOLLIN|$EPOLLEXCLUSIVE;
         }
 retry:
         if (epoll_ctl($Epoll, EPOLL_CTL_ADD, $fd, $ev)) {
             if ($! == EINVAL && ($ev & $EPOLLEXCLUSIVE)) {
                 $EPOLLEXCLUSIVE = 0; # old kernel
-                $ev = $self->{event_watch} = EPOLLIN|EPOLLERR|EPOLLHUP;
+                $ev = $self->{event_watch} = EPOLLIN;
                 goto retry;
             }
             die "couldn't add epoll watch for $fd: $!\n";
@@ -646,8 +641,8 @@ sub watch_read {
     my $val = shift;
     my $event = $self->{event_watch};
 
-    $event &= ~POLLIN if ! $val;
-    $event |=  POLLIN if   $val;
+    $event &= ~EPOLLIN if ! $val;
+    $event |=  EPOLLIN if   $val;
 
     my $fd = fileno($sock);
     # If it changed, set it
@@ -676,8 +671,8 @@ sub watch_write {
     my $val = shift;
     my $event = $self->{event_watch};
 
-    $event &= ~POLLOUT if ! $val;
-    $event |=  POLLOUT if   $val;
+    $event &= ~EPOLLOUT if ! $val;
+    $event |=  EPOLLOUT if   $val;
     my $fd = fileno($sock);
 
     # If it changed, set it