about summary refs log tree commit homepage
path: root/lib/PublicInbox/Git.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-07-08 07:01:59 +0000
committerEric Wong <e@80x24.org>2019-07-08 07:10:35 +0000
commit364d2e95439b00a211d007d93c5ba263b56c1ddf (patch)
tree857c1c9f69378ce9b4dc51dc0d736e4ff3f38ba6 /lib/PublicInbox/Git.pm
parent6d3644f5dd7c54fbee33be728f6735e4419cdc0d (diff)
downloadpublic-inbox-364d2e95439b00a211d007d93c5ba263b56c1ddf.tar.gz
While we're usually not stuck waiting on waitpid after
seeing a pipe EOF or even triggering SIGPIPE in the process
(e.g. git-http-backend) we're reading from, it MAY happen
and we should be careful to never hang the daemon process
on waitpid calls.

v2: use "eq" for string comparison against 'DEFAULT'
Diffstat (limited to 'lib/PublicInbox/Git.pm')
-rw-r--r--lib/PublicInbox/Git.pm5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm
index f5c7a95c..2f1a61f9 100644
--- a/lib/PublicInbox/Git.pm
+++ b/lib/PublicInbox/Git.pm
@@ -198,7 +198,10 @@ sub _destroy {
         my $p = delete $self->{$pid} or return;
         delete @$self{($in, $out)};
         delete $self->{$err} if $err; # `err_c'
-        waitpid $p, 0;
+
+        # PublicInbox::DS may not be loaded
+        eval { PublicInbox::DS::dwaitpid($p, undef, undef) };
+        waitpid($p, 0) if $@; # wait synchronously if not in event loop
 }
 
 sub fail {