For simplicity, we quit and recreate an entire watch instance
on SIGHUP. However, inotify (and signalfd) FDs are tied to
the DS event loop and stay pinned to existence that way.
Thus we explicitly close the FD in Watch->quit to prevent
leakage on SIGHUP.
---
lib/PublicInbox/Watch.pm | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/lib/PublicInbox/Watch.pm b/lib/PublicInbox/Watch.pm
index b87abafe..c7acda14 100644
--- a/lib/PublicInbox/Watch.pm
+++ b/lib/PublicInbox/Watch.pm
@@ -256,6 +256,10 @@ sub quit {
%{$self->{opendirs}} = ();
_done_for_now($self);
quit_done($self);
+ if (defined(my $fd = delete $self->{dir_idle_fd})) {
+ my $di = $PublicInbox::DS::DescriptorMap{$fd};
+ $di->close if $di && $di->can('add_watches');
+ }
if (my $idle_mic = delete $self->{idle_mic}) {
return unless $idle_mic->IsConnected && $idle_mic->Socket;
eval { $idle_mic->done };
@@ -280,6 +284,7 @@ sub watch_fs_init ($) {
require PublicInbox::DirIdle;
# inotify_create + EPOLL_CTL_ADD
my $dir_idle = PublicInbox::DirIdle->new($cb);
+ $self->{dir_idle_fd} = fileno($dir_idle->{sock}) if $dir_idle->{sock};
$dir_idle->add_watches([keys %{$self->{mdmap}}]);
}