From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id B4ECA1F4BA for ; Mon, 24 Jun 2019 02:54:16 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 14/57] ds: get rid of redundant and unnecessary POLL* constants Date: Mon, 24 Jun 2019 02:52:15 +0000 Message-Id: <20190624025258.25592-15-e@80x24.org> In-Reply-To: <20190624025258.25592-1-e@80x24.org> References: <20190624025258.25592-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index eb468f57..bff12de5 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -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 -- EW