about summary refs log tree commit
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-05-08 19:04:17 +0000
committerEric Wong <e@80x24.org>2019-05-08 19:04:17 +0000
commit90c5a78c8f6239b27c32b816d1cd029196ba2fe2 (patch)
treec847d11f24951e10714fae649739805a5bd3c22a
parentb6759f4bb35d7eda60044c6f8784274ebd61d729 (diff)
downloadpublic-inbox-90c5a78c8f6239b27c32b816d1cd029196ba2fe2.tar.gz
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
-rw-r--r--lib/PublicInbox/DS.pm2
1 files changed, 1 insertions, 1 deletions
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;
             }