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,AWL,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 53F091F4A8 for ; Wed, 8 May 2019 19:18:56 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 4/4] DS: epoll: fix misordered EPOLL_CTL_DEL call Date: Wed, 8 May 2019 19:18:56 +0000 Message-Id: <20190508191856.20485-5-e@80x24.org> In-Reply-To: <20190508191856.20485-1-e@80x24.org> References: <20190505005219.31772-1-e@80x24.org> <20190508191856.20485-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Any operations on an fd after POSIX::close() are invalid, so epoll_ctl will fail. Worse off, in a multi-threaded Perl, the fd may be reused by another thread and EPOLL_CTL_DEL can hit the wrong file description as a result. cf. https://rt.cpan.org/Ticket/Display.html?id=129487 --- lib/PublicInbox/DS.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index c03bd5d..779215c 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -333,8 +333,8 @@ sub EpollEventLoop { } else { my $fd = $ev->[0]; warn "epoll() returned fd $fd w/ state $state for which we have no mapping. removing.\n"; - POSIX::close($fd); epoll_ctl($Epoll, EPOLL_CTL_DEL, $fd, 0); + POSIX::close($fd); } next; } -- EW