about summary refs log tree commit homepage
path: root/lib/PublicInbox/Qspawn.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-10-05 22:29:40 +0000
committerEric Wong <e@80x24.org>2022-10-07 07:27:26 +0000
commit26037c85f73de67197af1987e4c0fa4786ac1e31 (patch)
tree52d7f462fe42bd091fca039dc2956c0707ff5a4f /lib/PublicInbox/Qspawn.pm
parent9fe2348fc4a3462b2de0483b1a1f4baf6edff14c (diff)
downloadpublic-inbox-26037c85f73de67197af1987e4c0fa4786ac1e31.tar.gz
We can't rely on 3-element array response when calling
WwwCoderepo for ViewVCS endpoints since that uses Qspawn
internally.  Thus, we have to allow two Qspawn objects to run in
parallel and ensure `qspawn.wcb' only gets called once, so we
end up duplicating the entire $ctx to ensure this.
Diffstat (limited to 'lib/PublicInbox/Qspawn.pm')
-rw-r--r--lib/PublicInbox/Qspawn.pm8
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm
index cea34fc3..ef9db43e 100644
--- a/lib/PublicInbox/Qspawn.pm
+++ b/lib/PublicInbox/Qspawn.pm
@@ -225,19 +225,19 @@ sub psgi_return_init_cb {
         my ($self) = @_;
         my $r = rd_hdr($self) or return;
         my $env = $self->{psgi_env};
-        my $filter = delete $env->{'qspawn.filter'} //
-                PublicInbox::GzipFilter::qsp_maybe($r->[1], $env);
+        my $filter = delete($env->{'qspawn.filter'}) // (ref($r) eq 'ARRAY' ?
+                PublicInbox::GzipFilter::qsp_maybe($r->[1], $env) : undef);
 
         my $wcb = delete $env->{'qspawn.wcb'};
         my $async = delete $self->{async}; # PublicInbox::HTTPD::Async
-        if (scalar(@$r) == 3) { # error
+        if (ref($r) ne 'ARRAY' || scalar(@$r) == 3) { # error
                 if ($async) { # calls rpipe->close && ->event_step
                         $async->close; # PublicInbox::HTTPD::Async::close
                 } else {
                         $self->{rpipe}->close;
                         event_step($self);
                 }
-                $wcb->($r);
+                $wcb->($r) if ref($r) eq 'ARRAY';
         } elsif ($async) {
                 # done reading headers, handoff to read body
                 my $fh = $wcb->($r); # scalar @$r == 2