]> Sergey Matveev's repositories - public-inbox.git/commitdiff
Import.pm: Don't assume {in} and {out} always exist
authorEric W. Biederman <ebiederm@xmission.com>
Wed, 1 Aug 2018 16:43:32 +0000 (11:43 -0500)
committerEric Wong <e@80x24.org>
Thu, 2 Aug 2018 02:18:07 +0000 (02:18 +0000)
While working on one of the tests I did:
my $im = PublicInbox::V2Writable->new($ibx, 1);
my $im0 = $im->importer();
$im->add($mime);

Which resulted in a warning of the use of an undefined value from
atfork_child, and the test failing nastily.  Inspection of the code
reveals this can happen anytime gfi_start has not been called.

So just fix atfork_child to skip closing file descriptors that have
not yet been setup.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
lib/PublicInbox/Import.pm

index 4e3b4c55179766797b41960ea7c55bc266f210f4..bfa7a8053297a50c44c5e1f4fe173fbd7f882bbf 100644 (file)
@@ -451,6 +451,7 @@ sub done {
 sub atfork_child {
        my ($self) = @_;
        foreach my $f (qw(in out)) {
+               next unless defined($self->{$f});
                close $self->{$f} or die "failed to close import[$f]: $!\n";
        }
 }