-# Copyright (C) 2016 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2020 all contributors <meta@public-inbox.org>
# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
#
# Emergency Maildir delivery for MDA
use warnings;
use Fcntl qw(:DEFAULT SEEK_SET);
use Sys::Hostname qw(hostname);
-use IO::Handle;
+use IO::Handle; # ->flush, ->autoflush
sub new {
my ($class, $dir) = @_;
my $d = "$dir/$_";
next if -d $d;
require File::Path;
- File::Path::mkpath($d); # croaks on fatal errors
+ if (!File::Path::mkpath($d) && !-d $d) {
+ die "failed to mkpath($d): $!\n";
+ }
}
- bless { dir => $dir, files => {}, t => 0, cnt => 0 }, $class;
+ bless { dir => $dir, files => {}, t => 0, cnt => 0, pid => $$ }, $class;
}
sub _fn_in {
sub commit {
my ($self) = @_;
+ $$ == $self->{pid} or return; # no-op in forked child
delete $self->{fh};
my $tmp = delete $self->{tmp} or return;