ext_msg_ALL($ctx) // sub {
$ctx->{-wcb} = $_[0]; # HTTP server write callback
- if ($ctx->{env}->{'pi-httpd.async'}) {
+ if ($ctx->{env}->{'pi-httpd.app'}) {
require PublicInbox::ConfigIter;
my $iter = PublicInbox::ConfigIter->new(
$ctx->{www}->{pi_cfg},
push @{$ctx->{partial}}, [ $cur, $mids ];
} elsif ($ctx->{again} && length($mid) >= $MIN_PARTIAL_LEN) {
bless $ctx, __PACKAGE__;
- if ($ctx->{env}->{'pi-httpd.async'}) {
+ if ($ctx->{env}->{'pi-httpd.app'}) {
$ctx->event_step;
return;
}
sub new { bless {}, shift } # qspawn filter
-# for Qspawn if using $env->{'pi-httpd.async'}
+# for Qspawn if using $env->{'pi-httpd.client'}
sub attach {
my ($self, $http_out) = @_;
$self->{http_out} = $http_out; # PublicInbox::HTTP::{Chunked,Identity}
sub psgi_response {
# $code may be an HTTP response code (e.g. 200) or a CODE ref (mbox_hdr)
my ($self, $code, $res_hdr) = @_;
- if ($self->{env}->{'pi-httpd.async'}) {
- my $http = $self->{env}->{'psgix.io'}; # PublicInbox::HTTP
+ if (my $http = $self->{env}->{'pi-httpd.client'}) {
$http->{forward} = $self;
sub {
my ($wcb) = @_; # -httpd provided write callback
undef;
}
-# for GetlineResponse (via Qspawn) when NOT using $env->{'pi-httpd.async'}
+# for GetlineResponse (via Qspawn) when NOT using $env->{'pi-httpd.client'}
# Also used for ->getline callbacks
sub translate {
my $self = shift; # $_[1] => input
my $self = shift;
carp @_;
my $env = $self->{env} or return;
- my $http = $env->{'psgix.io'} or return; # client abort
+ my $http = $env->{'pi-httpd.client'} or return; # client abort
eval { $http->close }; # should hit our close
carp "E: error in http->close: $@" if $@;
eval { $self->close }; # just in case...
# this is public-inbox-httpd-specific
sub async_blob_cb { # git->cat_async callback
my ($bref, $oid, $type, $size, $self) = @_;
- my $http = $self->{env}->{'psgix.io'}; # PublicInbox::HTTP
+ my $http = $self->{env}->{'pi-httpd.client'}; # PublicInbox::HTTP
$http->{forward} or return; # client aborted
my $smsg = $self->{smsg} or return bail($self, 'BUG: no smsg');
$type // return
sysseek($input, 0, SEEK_SET) if defined $input;
# note: NOT $self->{sock}, we want our close (+ PublicInbox::DS::close),
# to do proper cleanup:
- $env->{'psgix.io'} = $self; # for ->close or async_pass
+ $env->{'psgix.io'} = $self->{sock}; # for pi-httpd.ckhup
+ $env->{'pi-httpd.client'} = $self; # for ->close or async_pass
my $res = Plack::Util::run_app($env->{'pi-httpd.app'}, $env);
eval {
if (ref($res) eq 'CODE') {
# this to limit git-http-backend(1) parallelism.
# We also check for the truthiness of this to
# detect when to use async paths for slow blobs
- 'pi-httpd.async' => 1,
+ # 'pi-httpd.client' => PublicInbox::HTTP object
'pi-httpd.app' => $self->{app},
'pi-httpd.warn_cb' => $self->{warn_cb},
'pi-httpd.ckhup' => $port ? \&PublicInbox::Daemon::tcp_hup :
$rec = shift @{$self->{run_queue}} or return;
($start_cb, $ctx, $fail_cb) = @$rec;
$ck = $ctx->{env}->{'pi-httpd.ckhup'} or last;
- $ck->($ctx->{env}->{'psgix.io'}->{sock}) or last;
+ $ck->($ctx->{env}->{'psgix.io'}) or last;
$fail_cb->($ctx, 499, 'client disconnected');
}
_do_start $self, $start_cb, $ctx, $fail_cb;
$ctx->write('</pre>', $ctx->_html_end);
return $ctx->close;
}
- PublicInbox::DS::requeue($self) if $ctx->{env}->{'pi-httpd.async'};
+ PublicInbox::DS::requeue($self) if $ctx->{env}->{'pi-httpd.app'};
}
sub emit_msg_diff {
my ($self) = @_;
eval {
my $ctx = $self->{ctx};
- if ($ctx->{env}->{'pi-httpd.async'}) {
+ if ($ctx->{env}->{'pi-httpd.app'}) {
ibx_async_cat($ctx->{ibx}, $self->{smsg}->{blob},
\&diff_msg_i_async, $self);
} else {
sub begin_mail_diff {
my ($self) = @_;
- if ($self->{ctx}->{env}->{'pi-httpd.async'}) {
+ if ($self->{ctx}->{env}->{'pi-httpd.app'}) {
PublicInbox::DS::requeue($self);
} else {
event_step($self) while $self->{smsg};
sub {
$ctx->{-wcb} = $_[0]; # HTTP server callback
($ctx->{www}->{pi_cfg}->ALL ||
- !$ctx->{env}->{'pi-httpd.async'}) ?
+ !$ctx->{env}->{'pi-httpd.app'}) ?
$iter->each_section : $iter->event_step;
}
}
sub _yield_start { # may run later, much later...
my ($self) = @_;
- if ($self->{env}->{'pi-httpd.async'}) {
+ if ($self->{env}->{'pi-httpd.app'}) {
my $rpipe = $self->{rpipe};
PublicInbox::InputStream::consume($rpipe, \&istream_cb, $self);
} else {
# sub for the PSGI server to call
#
# $env->{'qspawn.filter'} - filter object, responds to ->attach for
-# pi-httpd.async and ->translate for generic
+# pi-httpd.client and ->translate for generic
# PSGI servers
#
# $limiter - the Limiter object to use (uses the def_limiter if not given)
# and a string ref of the current buffer. Returns an arrayref
# for PSGI responses. 2-element arrays in PSGI mean the
# body will be streamed, later, via writes (push-based) to
-# psgix.io. 3-element arrays means the body is available
+# pi-httpd.client. 3-element arrays means the body is available
# immediately (or streamed via ->getline (pull-based)).
sub psgi_yield {
my $try = $want->{try_gits} //= [ @{$self->{gits}} ]; # array copy
my $git = $try->[0] // die 'BUG {try_gits} empty';
- if ($self->{psgi_env}->{'pi-httpd.async'}) {
+ if ($self->{psgi_env}->{'pi-httpd.app'}) {
async_check({ git => $git }, $want->{oid_b},
\&ck_existing_cb, [ $self, $want ]);
$git->schedule_cleanup;
# let git disambiguate if oid_want was too short,
# but long enough to be unambiguous:
- if ($self->{psgi_env}->{'pi-httpd.async'}) {
+ if ($self->{psgi_env}->{'pi-httpd.app'}) {
async_check { git => $self->{tmp_git} }, $oid_want,
\&finish_cb, $self
} else {
sub next_step ($) {
# if outside of public-inbox-httpd, caller is expected to be
# looping event_step, anyways
- PublicInbox::DS::requeue($_[0]) if $_[0]->{psgi_env}->{'pi-httpd.async'}
+ PublicInbox::DS::requeue($_[0]) if $_[0]->{psgi_env}->{'pi-httpd.app'}
}
sub mark_found ($$$) {
dbg($self, "index at:\n$mode_b $oid_b_full\t".git_quote($file));
my $tmp_git = $self->{tmp_git} or die 'no git working tree';
- if ($self->{psgi_env}->{'pi-httpd.async'}) {
+ if ($self->{psgi_env}->{'pi-httpd.app'}) {
async_check { git => $tmp_git }, $oid_b_full,
\&ck_size_cb, $self
} else {
if (my $msgs = $want->{try_smsgs}) {
my $smsg = shift @$msgs;
- if ($self->{psgi_env}->{'pi-httpd.async'}) {
+ if ($self->{psgi_env}->{'pi-httpd.app'}) {
return ibx_async_cat($want->{cur_ibx}, $smsg->{blob},
\&extract_diff_async,
[$self, $want, $smsg]);
$self->{found} = {}; # { abbr => [ ::Git, oid, type, size, $di ] }
dbg($self, "solving $oid_want ...");
- if ($env->{'pi-httpd.async'}) {
+ if ($env->{'pi-httpd.app'}) {
PublicInbox::DS::requeue($self);
} else {
event_step($self) while $self->{user_cb};
# favor git(1) over Lg2 (libgit2) for SHA-256 support
my $ctx = ref $arg eq 'ARRAY' ? $arg->[0] : $arg;
$ctx->{git}->cat_async($_, $cb, $arg) for @req;
- if ($ctx->{env}->{'pi-httpd.async'}) {
+ if ($ctx->{env}->{'pi-httpd.app'}) {
$ctx->{git}->watch_async;
} else { # synchronous, generic PSGI
$ctx->{git}->cat_async_wait;
sub do_check_async {
my ($ctx, $cb, @req) = @_;
- if ($ctx->{env}->{'pi-httpd.async'}) {
+ if ($ctx->{env}->{'pi-httpd.app'}) {
async_check($ctx, $_, $cb, $ctx) for @req;
} else { # synchronous, generic PSGI
$ctx->{git}->check_async($_, $cb, $ctx) for @req;
# gzf = PublicInbox::GzipFilter == $ctx
my $gzf = shift(@{$self->{-low_prio_q}}) // return;
PublicInbox::DS::requeue($self) if scalar(@{$self->{-low_prio_q}});
- my $http = $gzf->{env}->{'psgix.io'}; # PublicInbox::HTTP
+ my $http = $gzf->{env}->{'pi-httpd.client'}; # PublicInbox::HTTP
$http->next_step($gzf->can('async_next'));
}
sub scan_attach ($) { # public-inbox-httpd only
my ($ctx) = @_;
- $ctx->{env}->{'psgix.io'}->{forward} = $ctx;
+ $ctx->{env}->{'pi-httpd.client'}->{forward} = $ctx;
$ctx->smsg_blob($ctx->{smsg});
}
return sub { # public-inbox-httpd-only
$ctx->{wcb} = $_[0];
scan_attach($ctx);
- } if $ctx->{env}->{'pi-httpd.async'};
+ } if $ctx->{env}->{'pi-httpd.app'};
# generic PSGI:
$eml = $ctx->{ibx}->smsg_eml($ctx->{smsg});
} elsif (!$ctx->{ibx}->over) {
\&list_match_i, $re, $ctx);
sub {
$ctx->{-wcb} = $_[0]; # HTTP server callback
- $ctx->{env}->{'pi-httpd.async'} ?
+ $ctx->{env}->{'pi-httpd.app'} ?
$iter->event_step : $iter->each_section;
}
}
sub getline_response ($$$$$) {
my ($env, $in, $off, $len, $path) = @_;
my $r = bless {}, __PACKAGE__;
- if ($env->{'pi-httpd.async'}) { # public-inbox-httpd-only mode
+ if (my $http = $env->{'pi-httpd.client'}) { # public-inbox-only mode
$env->{'psgix.no-compress'} = 1; # do not chunk response
- %$r = ( bypass => [$in, $off, $len, $env->{'psgix.io'}] );
+ %$r = ( bypass => [$in, $off, $len, $http] );
} else {
%$r = ( in => $in, off => $off, len => $len, path => $path );
}
$code = 200;
push @$body, "$env->{REMOTE_ADDR} $env->{REMOTE_PORT}";
} elsif ($path eq '/session_reused') {
- my $http = $env->{'psgix.io'}; # PublicInbox::HTTP
- $body = [ $http->{sock}->get_session_reused ? "y\n" : "n\n" ];
+ my $sock = $env->{'psgix.io'}; # IO::Socket::SSL
+ $body = [ $sock->get_session_reused ? "y\n" : "n\n" ];
$code = 200;
} elsif ($path eq '/callback') {
return sub {