about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-12-26 10:47:12 +0000
committerEric Wong <e@80x24.org>2019-12-26 10:47:42 +0000
commit3647997eaf49410bbf3e33bfb3874c611ab0c38b (patch)
tree9599e576f10534d59f468ca61f58eee2a4d9ce0a
parent200efc84f8acd59ae829655f281a125128c78b52 (diff)
downloadpublic-inbox-3647997eaf49410bbf3e33bfb3874c611ab0c38b.tar.gz
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.
-rw-r--r--lib/PublicInbox/WwwListing.pm5
1 files changed, 4 insertions, 1 deletions
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;
 }