* [PATCH] githttpbackend: avoid copying PSGI env
@ 2023-01-03 0:03 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2023-01-03 0:03 UTC (permalink / raw)
To: meta
We can stash qspawn.wcb before we fallback to WwwCoderepo to
ensure the qspawn re-dispatch works as expected. This is still
hacky and I want to tweak it further down the line. Meanwhile,
lets make it less expensive to do hacky things...
---
lib/PublicInbox/GitHTTPBackend.pm | 10 ++++------
lib/PublicInbox/ViewVCS.pm | 8 ++++----
2 files changed, 8 insertions(+), 10 deletions(-)
diff --git a/lib/PublicInbox/GitHTTPBackend.pm b/lib/PublicInbox/GitHTTPBackend.pm
index e84d4ff8..5b879871 100644
--- a/lib/PublicInbox/GitHTTPBackend.pm
+++ b/lib/PublicInbox/GitHTTPBackend.pm
@@ -149,13 +149,11 @@ sub parse_cgi_headers { # {parse_hdr} for Qspawn
# This makes qspawn skip ->async_pass and causes
# PublicInbox::HTTPD::Async::event_step to close shortly after
if ($code == 404 && $ctx->{www} && !$ctx->{_coderepo_tried}++) {
- my %ctx = %$ctx;
- $ctx{env} = +{ %{$ctx->{env}} };
- delete $ctx->{env}->{'qspawn.wcb'};
+ my $wcb = delete $ctx->{env}->{'qspawn.wcb'};
$ctx->{env}->{'plack.skip-deflater'} = 1; # prevent 2x gzip
- my $res = $ctx->{www}->coderepo->srv(\%ctx);
- # for ->psgi_return_init_cb:
- $ctx->{env}->{'qspawn.wcb'} = $ctx{env}->{'qspawn.wcb'};
+ my $res = $ctx->{www}->coderepo->srv($ctx);
+ # for ->psgi_return_init_cb
+ $ctx->{env}->{'qspawn.wcb'} = $wcb;
$res; # CODE or ARRAY ref
} else {
[ $code, \@h ]
diff --git a/lib/PublicInbox/ViewVCS.pm b/lib/PublicInbox/ViewVCS.pm
index 02e98768..99ee2c11 100644
--- a/lib/PublicInbox/ViewVCS.pm
+++ b/lib/PublicInbox/ViewVCS.pm
@@ -100,7 +100,7 @@ sub stream_large_blob ($$) {
my $cmd = ['git', "--git-dir=$git->{git_dir}", 'cat-file', $type, $oid];
my $qsp = PublicInbox::Qspawn->new($cmd);
my $env = $ctx->{env};
- $env->{'qspawn.wcb'} = delete $ctx->{-wcb};
+ $env->{'qspawn.wcb'} = $ctx->{-wcb};
$qsp->psgi_return($env, undef, \&stream_blob_parse_hdr, $ctx);
}
@@ -282,7 +282,7 @@ possible to have multiple root commits when merging independent histories.
Every commit references one top-level <dfn id=tree>tree</dfn> object.</pre>
EOM
- delete($ctx->{env}->{'qspawn.wcb'})->($ctx->html_done($x));
+ delete($ctx->{-wcb})->($ctx->html_done($x));
}
sub stream_patch_parse_hdr { # {parse_hdr} for Qspawn
@@ -312,7 +312,7 @@ sub show_patch ($$) {
qw(format-patch -1 --stdout -C),
"--signature=git format-patch -1 --stdout -C $oid", $oid);
my $qsp = PublicInbox::Qspawn->new(\@cmd);
- $ctx->{env}->{'qspawn.wcb'} = delete $ctx->{-wcb};
+ $ctx->{env}->{'qspawn.wcb'} = $ctx->{-wcb};
$ctx->{patch_oid} = $oid;
$qsp->psgi_return($ctx->{env}, undef, \&stream_patch_parse_hdr, $ctx);
}
@@ -333,7 +333,7 @@ sub show_commit ($$) {
my $e = { GIT_DIR => $git->{git_dir} };
my $qsp = PublicInbox::Qspawn->new($cmd, $e, { -C => "$ctx->{-tmp}" });
$qsp->{qsp_err} = \($ctx->{-qsp_err} = '');
- $ctx->{env}->{'qspawn.wcb'} = delete $ctx->{-wcb};
+ $ctx->{env}->{'qspawn.wcb'} = $ctx->{-wcb};
$ctx->{git} = $git;
$qsp->psgi_qx($ctx->{env}, undef, \&show_commit_start, $ctx);
}
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2023-01-03 0:02 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-03 0:03 [PATCH] githttpbackend: avoid copying PSGI env Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).