]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Emergency.pm
wwwstream: drop tor2web URL
[public-inbox.git] / lib / PublicInbox / Emergency.pm
index 4ee862153fdfe3d80d4735b68b7d0e32a5cd43cd..66adc6318076a395aa9c6be81d7a483bff6a151c 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Emergency Maildir delivery for MDA
@@ -18,7 +18,7 @@ sub new {
                next if -d $d;
                -d $d or mkdir($d) or die "failed to mkdir($d): $!\n";
        }
-       bless { dir => $dir, files => {}, t => 0, cnt => 0 }, $class;
+       bless { dir => $dir, files => {}, t => 0, cnt => 0, pid => $$ }, $class;
 }
 
 sub _fn_in {
@@ -75,6 +75,7 @@ sub fh {
 
 sub commit {
        my ($self) = @_;
+       $$ == $self->{pid} or return; # no-op in forked child
 
        delete $self->{fh};
        my $tmp = delete $self->{tmp} or return;