]> Sergey Matveev's repositories - public-inbox.git/commitdiff
qspawn: consistently return 500 on premature EOF
authorEric Wong <e@80x24.org>
Fri, 6 Jan 2023 10:10:52 +0000 (10:10 +0000)
committerEric Wong <e@80x24.org>
Fri, 6 Jan 2023 10:24:16 +0000 (10:24 +0000)
If {parse_hdr} callback doesn't handle it, we need to break the
loop if the CGI process dies prematurely.  This doesn't fix a
currently known problem, but theoretically a SIGKILL could hit
(cgit || git-http-backend) while -netd or -httpd survives.

lib/PublicInbox/Qspawn.pm

index 7984e35a80510ffdf09cbb7f5e325ecd9eb764a0..5d3ec30926cdb5be848c0a38df738428af4ecbc9 100644 (file)
@@ -210,6 +210,13 @@ sub rd_hdr ($) {
                        if ($@) {
                                warn "parse_hdr: $@";
                                $ret = [ 500, [], [ "Internal error\n" ] ];
+                       } elsif (!defined($ret) && !$r) {
+                               my $cmd = $self->{cmd} // [ '(?)' ];
+                               my $env = $self->{psgi_env};
+                               warn <<EOM;
+EOF parsing headers from @$cmd ($self->{psgi_env}->{REQUEST_URI})
+EOM
+                               $ret = [ 500, [], [ "Internal error\n" ] ];
                        }
                } else {
                        # caller should notify us when it's ready: