* [PATCH] wwwlisting: do not rely on $? after ProcessPipe::CLOSE
@ 2019-12-26 10:47 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2019-12-26 10:47 UTC (permalink / raw)
To: meta
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;
}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2019-12-26 10:47 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-26 10:47 [PATCH] wwwlisting: do not rely on $? after ProcessPipe::CLOSE Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).