Hopefully this makes the code easier-to-follow for random
readers. This requires a small amount of modification to
our one caller, but this is a new, unstable API (as is
nearly all of our code).
sub psgi_qx {
my ($self, $env, $limiter, $qx_cb) = @_;
- my $qx = PublicInbox::Qspawn::Qx->new($qx_cb);
+ my $qx = PublicInbox::Qspawn::Qx->new;
my $end = sub {
_psgi_finish($self, $env);
- $qx->close;
+ eval { $qx_cb->($qx) };
$qx = undef;
};
my $rpipe;
use warnings;
sub new {
- my ($class, $cb) = @_;
- bless [ '', $cb ], $class;
+ my ($class) = @_;
+ my $buf = '';
+ bless \$buf, $class;
}
+# called by PublicInbox::HTTPD::Async ($fh->write)
sub write {
- $_[0]->[0] .= $_[1];
- undef;
-}
-
-sub close {
- my ($self) = @_;
- my $cb = $self->[1];
- eval { $cb->(\($self->[0])) };
+ ${$_[0]} .= $_[1];
undef;
}
$env->{'qspawn.quiet'} = 1;
my $tree_cb = $env->{'repobrowse.tree_cb'} = sub {
my ($ref) = @_;
- if (ref($ref) eq 'SCALAR') {
+ if (defined $ref) {
$tree = $$ref;
chomp $tree;
}