diff options
author | Eric Wong <e@80x24.org> | 2021-01-13 19:06:18 -1200 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2021-01-14 23:14:08 +0000 |
commit | 529c7edd3cc62f0e328517b6628706251a33099e (patch) | |
tree | 79cacd6b5d82e04652a6dabf2010534cfbcd3741 | |
parent | b5607f3185f956f23dee025255a84b75c79f8e62 (diff) | |
download | public-inbox-529c7edd3cc62f0e328517b6628706251a33099e.tar.gz |
We can shrink the @TO_CLOSE_ATFORK_CHILD array by two elements, at least. I may be possible to eliminate this array entirely but clobbering $quit doesn't seem to remove references to $eof_w or the $listener socket.
-rw-r--r-- | lib/PublicInbox/LEI.pm | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 7a1df0bb..fd2b722c 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -279,6 +279,7 @@ sub atfork_child_wq { my ($self, $wq) = @_; @$self{qw(0 1 2 sock)} = delete(@$wq{0..3}); %PATH2CFG = (); + $quit = \&CORE::exit; @TO_CLOSE_ATFORK_CHILD = (); (__WARN__ => sub { err($self, @_) }, PIPE => sub { @@ -782,8 +783,8 @@ sub lazy_start { return if $pid; $0 = "lei-daemon $path"; local %PATH2CFG; - local @TO_CLOSE_ATFORK_CHILD = ($l, $eof_r, $eof_w); - $_->blocking(0) for ($l, $eof_r, $eof_w); + local @TO_CLOSE_ATFORK_CHILD = ($l, $eof_w); + $l->blocking(0); $l = PublicInbox::Listener->new($l, \&accept_dispatch, $l); my $exit_code; local $quit = sub { @@ -795,6 +796,7 @@ sub lazy_start { PublicInbox::DS->SetLoopTimeout(1000); }; PublicInbox::EOFpipe->new($eof_r, \&noop, undef); + undef $eof_r; my $sig = { CHLD => \&PublicInbox::DS::enqueue_reap, QUIT => $quit, @@ -806,9 +808,10 @@ sub lazy_start { }; my $sigfd = PublicInbox::Sigfd->new($sig, SFD_NONBLOCK); local @SIG{keys %$sig} = values(%$sig) unless $sigfd; + undef $sig; local $SIG{PIPE} = 'IGNORE'; if ($sigfd) { # TODO: use inotify/kqueue to detect unlinked sockets - push @TO_CLOSE_ATFORK_CHILD, $sigfd->{sock}; + undef $sigfd; PublicInbox::DS->SetLoopTimeout(5000); } else { # wake up every second to accept signals if we don't |