]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
fix closing gzipped mboxrd from curl w/o IO::KQueue
authorEric Wong <e@80x24.org>
Thu, 11 Dec 2025 23:06:05 +0000 (23:06 +0000)
committerEric Wong <e@80x24.org>
Tue, 16 Dec 2025 02:52:49 +0000 (02:52 +0000)
While the `waitpid' perlop retries on EINTR, it preserves the
`errno == EINTR' value after eventual success of the underlying
wait4/waitpid syscall.  Preserving `$!' confuses
IO::Uncompress::Base::close into saving `$!' in the
IO::Uncompress::Base::saveErrorString call.  Saving `$!' there
caused the `$mbfh->close' call to fail in
PublicInbox::MboxReader::_mbox_from in t/solver_git.t when
accessing remote URLs (`lei blob --no-mail 69df7d5 -I $rurl').

So now we always clobber `$!' after successful `waitpid' perlops
to ensure subsequent calls don't misreport errors.

Only noticed when testing on FreeBSD 13.5 without IO::KQueue
while chasing t/solver_git.t regression I noticed on Debian 13.x

lib/PublicInbox/DS.pm

index 70c6c844f0b3f2d3d34fbcffc87bb3d639901b6d..12ca38a35f8687cb210124a9e9cd66846720c62b 100644 (file)
@@ -687,8 +687,11 @@ sub awaitpid {
        $AWAIT_PIDS{$pid} = \@cb_args if @cb_args;
        # provide synchronous API
        if (defined(wantarray) || (!$in_loop && !@cb_args)) {
-               my $ret = waitpid($pid, 0);
+               my $ret = waitpid($pid, 0); # n.b. Perl auto retries on EINTR
                if ($ret == $pid) {
+                       # prevent IO::Uncompress::Base::close from giving $!
+                       # to IO::Uncompress::Base::saveErrorString:
+                       $! = 0;
                        my $cb_args = delete $AWAIT_PIDS{$pid};
                        @cb_args = @$cb_args if !@cb_args && $cb_args;
                        await_cb($pid, @cb_args);