From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, T_SCC_BODY_TEXT_LINE shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 246201F569 for ; Thu, 30 May 2024 09:45:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1717062316; bh=RY1oHOnJj4BGa6kIEgQw8wul+NjCqfQedzLiLWzmOS4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=q7aoaNHucadp7nQLDJuxHCiV9PdFb7j5b2uqr6JVPNKBDjI2Irz+WI4K6wmRvMQFG 0XUvyR+XPRyfwfwmXG+U+3oAMKHnp9Rjw6QUlLjG+m8TcFWwBpgXGsaV03b6bntZY1 CAuFs0bqjyAHr3++6NUf7FsRDKTs+DTpDKgZ6kgE= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/3] git: prefer WNOHANG for `git cat-file --batch-*' Date: Thu, 30 May 2024 09:45:14 +0000 Message-ID: <20240530094515.3402089-3-e@80x24.org> In-Reply-To: <20240530094515.3402089-1-e@80x24.org> References: <20240530094515.3402089-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index ff38efa1..55005475 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