]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: drop -watches and -lei_note_event from workers
authorEric Wong <e@80x24.org>
Tue, 31 Jan 2023 00:05:15 +0000 (00:05 +0000)
committerEric Wong <e@80x24.org>
Tue, 31 Jan 2023 00:27:06 +0000 (00:27 +0000)
I noticed these while tracking down circular refs for commit
7b654d175cf2e31b (ipc: drop awaitpid_init to avoid circular refs, 2023-01-30).
While they're not the cause of circular refs, they're still
a waste of memory in worker processes.

lib/PublicInbox/LEI.pm

index ffd50db5e9d6e3744584a5ee81db8107b9f8bf0f..d05b20dee4873ce57a6e0d9c44bf54d21dbe6c37 100644 (file)
@@ -561,17 +561,17 @@ sub note_sigpipe { # triggers sigpipe_handler
 sub _lei_atfork_child {
        my ($self, $persist) = @_;
        # we need to explicitly close things which are on stack
+       my $cfg = $self->{cfg};
        if ($persist) {
                open $self->{3}, '<', '/' or die "open(/) $!";
                fchdir($self);
                close($_) for (grep(defined, delete @$self{qw(0 1 2 sock)}));
-               if (my $cfg = $self->{cfg}) {
-                       delete @$cfg{qw(-lei_store -watches -lei_note_event)};
-               }
+               delete @$cfg{qw(-lei_store -watches -lei_note_event)};
        } else { # worker, Net::NNTP (Net::Cmd) uses STDERR directly
                open STDERR, '+>&='.fileno($self->{2}) or warn "open $!";
                STDERR->autoflush(1);
                POSIX::setpgid(0, $$) // die "setpgid(0, $$): $!";
+               delete @$cfg{qw(-watches -lei_note_event)};
        }
        close($_) for (grep(defined, delete @$self{qw(old_1 au_done)}));
        delete $self->{-socks};