From 90c5a78c8f6239b27c32b816d1cd029196ba2fe2 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 8 May 2019 19:04:17 +0000 Subject: DS: epoll: fix misordered EPOLL_CTL_DEL call 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 c03bd5dd..779215c9 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; } -- cgit v1.2.3-24-ge0c7