about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-04-11 10:53:28 +0000
committerEric Wong <e@yhbt.net>2020-04-15 10:16:05 +0000
commit6d10213d5121ac6b71221acff3caa68ba9a8bc52 (patch)
tree9728560014bf9a898b1f83da9094876f9bdf50e0
parent2e59372029f89ae0e9c68384d6bda0ad50704730 (diff)
downloadpublic-inbox-6d10213d5121ac6b71221acff3caa68ba9a8bc52.tar.gz
Just like the EPOLL_CTL_ADD emulation path, the EPOLL_CTL_MOD
and EPOLL_CTL_DEL emulation paths can fail if attempting to
install an EVFILT_WRITE for a read-only pipe.

I've only observed this on the EPOLL_CTL_DEL emulation path, but
I suspect it could happen on the EPOLL_CTL_MOD path as well.

Increasing the amount of read-only pipes we rely on with altid
exports via sqlite3 made this old bug more apparent and
reproducible while looping the test suite.

This may be adjusted in the future to deal with write-only
pipes, but we currently don't have any of those watched by
kqueue.
-rw-r--r--lib/PublicInbox/DSKQXS.pm4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/PublicInbox/DSKQXS.pm b/lib/PublicInbox/DSKQXS.pm
index b9b0b6c5..35cdecda 100644
--- a/lib/PublicInbox/DSKQXS.pm
+++ b/lib/PublicInbox/DSKQXS.pm
@@ -105,10 +105,10 @@ sub epoll_ctl {
         my $kq = $self->{kq};
         if ($op == EPOLL_CTL_MOD) {
                 $kq->EV_SET($fd, EVFILT_READ, kq_flag(EPOLLIN, $ev));
-                $kq->EV_SET($fd, EVFILT_WRITE, kq_flag(EPOLLOUT, $ev));
+                eval { $kq->EV_SET($fd, EVFILT_WRITE, kq_flag(EPOLLOUT, $ev)) };
         } elsif ($op == EPOLL_CTL_DEL) {
                 $kq->EV_SET($fd, EVFILT_READ, EV_DISABLE);
-                $kq->EV_SET($fd, EVFILT_WRITE, EV_DISABLE);
+                eval { $kq->EV_SET($fd, EVFILT_WRITE, EV_DISABLE) };
         } else { # EPOLL_CTL_ADD
                 $kq->EV_SET($fd, EVFILT_READ, EV_ADD|kq_flag(EPOLLIN, $ev));