about summary refs log tree commit homepage
path: root/lib/PublicInbox/RepoGitRaw.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2017-03-04 03:52:29 +0000
committerEric Wong <e@80x24.org>2017-03-04 03:52:29 +0000
commit8a3fc4a2f027b36f27225ceee5908c571c8f4f47 (patch)
tree5ab6f45dc41d3d25bf71bcdd5c9c3108a22a8fbd /lib/PublicInbox/RepoGitRaw.pm
parentd78b17adabb1880857c67fda40be0c47fe9d1866 (diff)
downloadpublic-inbox-8a3fc4a2f027b36f27225ceee5908c571c8f4f47.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/RepoGitRaw.pm')
-rw-r--r--lib/PublicInbox/RepoGitRaw.pm20
1 files changed, 11 insertions, 9 deletions
diff --git a/lib/PublicInbox/RepoGitRaw.pm b/lib/PublicInbox/RepoGitRaw.pm
index 858034a3..717ca71f 100644
--- a/lib/PublicInbox/RepoGitRaw.pm
+++ b/lib/PublicInbox/RepoGitRaw.pm
@@ -36,15 +36,17 @@ sub git_raw_check_res ($$$) {
                 my $buf = '';
                 $req->{-repo}->{git}->cat_async($req->{env}, $hex, sub {
                         my ($r) = @_;
-                        return if ref($r) ne 'SCALAR';
-                        $buf .= $$r;
-                        return if bytes::length($buf) < $size;
-                        $ct ||= index($buf, "\0") >= 0 ?
-                                        'application/octet-stream' :
-                                        'text/plain; charset=UTF-8';
-                        $res->([200, ['Content-Type', $ct,
-                                        'Content-Length', $size ],
-                                [ $buf ]]);
+                        if (ref($r) eq 'SCALAR') {
+                                $buf .= $$r;
+                        } elsif ($r == 0) {
+                                return if bytes::length($buf) < $size;
+                                $ct ||= index($buf, "\0") >= 0 ?
+                                                'application/octet-stream' :
+                                                'text/plain; charset=UTF-8';
+                                $res->([200, ['Content-Type', $ct,
+                                                'Content-Length', $size ],
+                                        [ $buf ]]);
+                        }
                 });
         }
 }