From 26037c85f73de67197af1987e4c0fa4786ac1e31 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Wed, 5 Oct 2022 22:29:40 +0000 Subject: www: cgit: fall back to WwwCoderepo on 404s 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. --- lib/PublicInbox/Qspawn.pm | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'lib/PublicInbox/Qspawn.pm') 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 -- cgit v1.2.3-24-ge0c7