From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 737DB1F463 for ; Thu, 26 Dec 2019 10:47:13 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] wwwlisting: do not rely on $? after ProcessPipe::CLOSE Date: Thu, 26 Dec 2019 10:47:12 +0000 Message-Id: <20191226104712.38034-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: ProcessPipe::CLOSE won't reliably set $? inside the event loop if waitpid(..., WNOHANG) isn't successful. So use a blocking waitpid() call, here, and hope "git show-ref" exits promptly since we've already drained its stdout. --- lib/PublicInbox/WwwListing.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/WwwListing.pm b/lib/PublicInbox/WwwListing.pm index bcb968af..e19ae8a1 100644 --- a/lib/PublicInbox/WwwListing.pm +++ b/lib/PublicInbox/WwwListing.pm @@ -127,7 +127,9 @@ sub _json () { sub fingerprint ($) { my ($git) = @_; - my $fh = $git->popen('show-ref') or + # TODO: convert to qspawn for fairness when there's + # thousands of repos + my ($fh, $pid) = $git->popen('show-ref') or die "popen($git->{git_dir} show-ref) failed: $!"; my $dig = Digest::SHA->new(1); @@ -135,6 +137,7 @@ sub fingerprint ($) { $dig->add($buf); } close $fh; + waitpid($pid, 0); return if $?; # empty, uninitialized git repo $dig->hexdigest; }