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/Git.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/PublicInbox/Git.pm') diff --git a/lib/PublicInbox/Git.pm b/lib/PublicInbox/Git.pm index 6a7b109f..893df71e 100644 --- a/lib/PublicInbox/Git.pm +++ b/lib/PublicInbox/Git.pm @@ -253,10 +253,10 @@ sub cat_async_compat ($$$) { $self->{out}->print($obj."\n") or fail($self, "write error: $!"); my $in = $self->{in}; my $info = async_info_compat($in); + my (undef, $type, $left) = @$info; $cb->($info); - return if scalar(@$info) != 3; # missing + return if $info->[1] eq 'missing'; my $max = 8192; - my $left = $info->[2]; my ($buf, $r); while ($left > 0) { $r = read($in, $buf, $left > $max ? $max : $left); @@ -267,6 +267,7 @@ sub cat_async_compat ($$$) { $r = read($in, $buf, 1); defined($r) or fail($self, "read failed: $!"); fail($self, 'newline missing after blob') if ($r != 1 || $buf ne "\n"); + $cb->(0); } sub check_async { -- cgit v1.2.3-24-ge0c7