]> Sergey Matveev's repositories - public-inbox.git/commitdiff
git-http-backend: check EINTR as well as EAGAIN
authorEric Wong <e@80x24.org>
Mon, 7 Mar 2016 19:10:33 +0000 (19:10 +0000)
committerEric Wong <e@80x24.org>
Fri, 29 Apr 2016 18:50:59 +0000 (18:50 +0000)
The blocking PSGI server may cause EINTR to be hit, here.

lib/PublicInbox/GitHTTPBackend.pm

index a7cac100d02631c2d683456cd3eaa59b1caae69c..30efa839ac3abb2cd0b8692478c29c8839df13dd 100644 (file)
@@ -205,18 +205,18 @@ sub serve_smart {
                ref($dumb) eq 'ARRAY' ? $res->($dumb) : $dumb->($res);
        };
        my $fail = sub {
-               my ($e) = @_;
-               if ($e eq 'EAGAIN') {
+               if ($!{EAGAIN} || $!{EINTR}) {
                        select($vin, undef, undef, undef) if defined $vin;
                        # $vin is undef on async, so this is a noop on EAGAIN
                        return;
                }
+               my $e = $!;
                $end->();
                $err->print("git http-backend ($git_dir): $e\n");
        };
        my $cb = sub { # read git-http-backend output and stream to client
                my $r = $rpipe ? $rpipe->sysread($buf, 8192, length($buf)) : 0;
-               return $fail->($!{EAGAIN} ? 'EAGAIN' : $!) unless defined $r;
+               return $fail->() unless defined $r;
                return $end->() if $r == 0; # EOF
                if ($fh) { # stream body from git-http-backend to HTTP client
                        $fh->write($buf);