]> Sergey Matveev's repositories - public-inbox.git/commitdiff
daemon: share FDs for identical log paths
authorEric Wong <e@80x24.org>
Mon, 1 Aug 2022 21:24:47 +0000 (21:24 +0000)
committerEric Wong <e@80x24.org>
Tue, 2 Aug 2022 19:20:14 +0000 (19:20 +0000)
We rely on the %logs hash for SIGUSR1 log reopening.  Without this sharing,
some FDs would be hidden inside its respective {HTTP,IMAP,POP3}D
object and not reopened on USR2

lib/PublicInbox/Daemon.pm

index ead5afc09d747eb1df338ebca634a3920c107869..20b07b83997aa90d3e196d4b94e107d591d931b7 100644 (file)
@@ -104,6 +104,7 @@ sub open_log_path ($$) { # my ($fh, $path) = @_; # $_[0] is modified
        open $_[0], '>>', $_[1] or die "open(>> $_[1]): $!";
        $_[0]->autoflush(1);
        do_chown($_[1]);
+       $_[0];
 }
 
 sub load_mod ($;$$) {
@@ -141,8 +142,7 @@ sub load_mod ($;$$) {
                die "multiple $f= options specified\n" if @$p > 1;
                check_absolute("$f=", $p->[0]) if $daemonize;
                $p = File::Spec->canonpath($p->[0]);
-               open_log_path(my $fh, $p);
-               $tlsd->{$f} = $logs{$p} = $fh;
+               $tlsd->{$f} = $logs{$p} //= open_log_path(my $fh, $p);
                warn "# $scheme://$addr $f=$p\n";
        }
        \%xn;