From: Eric Wong Date: Thu, 30 May 2024 09:45:14 +0000 (+0000) Subject: git: prefer WNOHANG for `git cat-file --batch-*' X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ea9bda92fe0565ab563763d9365e76cd0c24ea7;p=thirdparty%2Fpublic-inbox.git git: prefer WNOHANG for `git cat-file --batch-*' 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. --- diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index ff38efa16..55005475b 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -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