]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
git: prefer WNOHANG for `git cat-file --batch-*'
authorEric Wong <e@80x24.org>
Thu, 30 May 2024 09:45:14 +0000 (09:45 +0000)
committerEric Wong <e@80x24.org>
Fri, 31 May 2024 03:18:53 +0000 (03:18 +0000)
When inside our DS event loop, ensure we don't stall on
synchronous waitpid when stopping `--batch-*' processes.
Instead of calling PublicInbox::IO::close explicitly, let
refcounting close the socket via PublicInbox::IO::DESTROY and
the SIGCHLD handler will deal with it when the kernel and event
loop get to it.

lib/PublicInbox/Git.pm

index ff38efa16c7ea0a416c8924a5bfd9c35d0b4e7c8..55005475b288f478483c5443ea505befcd5766e7 100644 (file)
@@ -208,7 +208,7 @@ sub cat_async_retry ($$) {
                $oid = \$oid if !@$new_inflight; # to indicate oid retried
                push @$new_inflight, $oid, $cb, $arg;
        }
-       $sock->close if $sock; # only safe once old_inflight is empty
+       undef $sock; # gcf_drain may run from PublicInbox::IO::DESTROY
        cat_async_step($self, $new_inflight); # take one step
 }
 
@@ -665,10 +665,9 @@ sub watch_async ($) {
 
 sub close {
        my ($self) = @_;
-       my $sock = $self->{sock};
        delete @$self{qw(-bc err_c inflight)};
        delete($self->{epwatch}) ? $self->SUPER::close : delete($self->{sock});
-       $sock->close if $sock; # calls gcf_drain via awaitpid
+       # gcf_drain may run from PublicInbox::IO::DESTROY
 }
 
 package PublicInbox::GitCheck; # only for git <2.36