From 8a3fc4a2f027b36f27225ceee5908c571c8f4f47 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 4 Mar 2017 03:52:29 +0000 Subject: repoobrowse: explicit EOF handling for git async callback We need to ensure we've fully-drained the pipe before signalling EOF to the callback, since pipelining may not be the best choice with detachable processes in the future. --- lib/PublicInbox/GitAsync.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'lib/PublicInbox/GitAsync.pm') diff --git a/lib/PublicInbox/GitAsync.pm b/lib/PublicInbox/GitAsync.pm index 8369978c..24e0bf3b 100644 --- a/lib/PublicInbox/GitAsync.pm +++ b/lib/PublicInbox/GitAsync.pm @@ -65,7 +65,7 @@ take_job: } $cb->($info); # $info may 0 (EOF, or undef, $cb will see $!) return $self->close unless $info; - if ($check || (scalar(@$info) != 3)) { + if ($check || $info->[1] eq 'missing') { # do not monopolize the event loop if we're drained: return if ${$self->{rbuf}} eq ''; goto take_job; @@ -89,6 +89,7 @@ final_hunk: my $lf = chop $$rbuf; $lf eq "\n" or die "BUG: missing LF (got $lf)"; $cb->($rbuf); + $cb->(0); return if $buf eq ''; goto take_job; -- cgit v1.2.3-24-ge0c7