lib/PublicInbox/SearchIdx.pm | 8 ++++++-- lib/PublicInbox/V2Writable.pm | 5 +++-- t/spawn.t | 4 ++-- diff --git a/lib/PublicInbox/SearchIdx.pm b/lib/PublicInbox/SearchIdx.pm index b2d71a1f88b462493d3db527c609d00f4e16b31b..f265fa7f27ae7ed3cb0baa7f8e4fd7215adb3e9d 100644 --- a/lib/PublicInbox/SearchIdx.pm +++ b/lib/PublicInbox/SearchIdx.pm @@ -590,6 +590,7 @@ $latest = $1; $newest ||= $latest; } } + close($log) or die "git log failed: \$?=$?"; # get the leftovers foreach my $blob (keys %D) { my $mime = do_cat_mail($git, $blob, \$bytes) or next; @@ -632,7 +633,7 @@ my $fh = $git->popen(qw(log --pretty=tformat:%h --no-notes --no-color --no-renames --diff-filter=AM), $range); ++$fcount while <$fh>; - close $fh; + close $fh or die "git log failed: \$?=$?"; my $high = $self->{mm}->num_highwater; $pr->("$fcount\n") if $pr; # continue previous line $self->{ntodo} = $fcount; @@ -713,7 +714,10 @@ my $xdb = $self->begin_txn_lazy; my $mm = _msgmap_init($self); do { - $xlog = undef; + if ($xlog) { + close($xlog) or die "git log failed: \$?=$?"; + $xlog = undef; + } $last_commit = _last_x_commit($self, $mm); $lx = reindex_from($opts->{reindex}, $last_commit); diff --git a/lib/PublicInbox/V2Writable.pm b/lib/PublicInbox/V2Writable.pm index 1825da2cf69f6ed2dc87ab8ea15b9bb1343e3308..02f313b022c01dc7a52140016a4b1715a20f0f37 100644 --- a/lib/PublicInbox/V2Writable.pm +++ b/lib/PublicInbox/V2Writable.pm @@ -1128,6 +1128,7 @@ my $fh = $git->popen(qw(log --pretty=tformat:%H --no-notes --no-color --no-renames --diff-filter=AM), $range, '--', 'm'); ++$n while <$fh>; + close $fh or die "git log failed: \$?=$?"; $pr->("$n\n") if $pr; $regen_max += $n; } @@ -1195,7 +1196,7 @@ /\A:\d{6} 100644 $x40 ($x40) [AM]\tm$/o or next; unindex_oid($self, $git, $1, $unindexed); } delete $self->{reindex_pipe}; - $fh = undef; + close $fh or die "git log failed: \$?=$?"; return unless $sync->{-opt}->{prune}; my $after = scalar keys %$unindexed; @@ -1251,7 +1252,7 @@ } elsif (/\A:\d{6} 100644 $x40 ($x40) [AM]\td$/o) { mark_deleted($self, $sync, $git, $1); } } - $fh = undef; + close $fh or die "git log failed: \$?=$?"; delete $self->{reindex_pipe}; update_last_commit($self, $git, $i, $cmt) if defined $cmt; } diff --git a/t/spawn.t b/t/spawn.t index aba1a26c7ce66e6571511196d5bcb5b743fe78ee..ebebfb57eafc078577c4b79bc6021fce8d6c4846 100644 --- a/t/spawn.t +++ b/t/spawn.t @@ -71,13 +71,13 @@ is(sysread($fh, $buf, 6), 6, 'sysread got 6 bytes'); is($buf, "hello\n", 'tied gets works'); is(sysread($fh, $buf, 6), 0, 'sysread got EOF'); $? = 1; - close $fh; + ok(close($fh), 'close succeeds'); is($?, 0, '$? set properly'); } { my $fh = popen_rd([qw(false)]); - close $fh; + ok(!close($fh), 'close fails on false'); isnt($?, 0, '$? set properly: '.$?); }