diff options
author | Eric Wong <e@80x24.org> | 2019-09-14 09:21:14 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-09-14 09:22:14 +0000 |
commit | bb20bc29a831d8f84613d48af729ffaede9d43e2 (patch) | |
tree | 50fd3514e74b87979bcc238a66bfa0f60af358b7 /lib/PublicInbox | |
parent | 44165c19397c576eb0147930c707867e729925e6 (diff) | |
download | public-inbox-bb20bc29a831d8f84613d48af729ffaede9d43e2.tar.gz |
I didn't know PerlIO::scalar existed until a few months ago, but it's been distributed with Perl since 5.8 and doesn't seem to be split out into it's own package on any distro.
Diffstat (limited to 'lib/PublicInbox')
-rw-r--r-- | lib/PublicInbox/Qspawn.pm | 24 |
1 files changed, 4 insertions, 20 deletions
diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm index f2e91ab6..76e48e81 100644 --- a/lib/PublicInbox/Qspawn.pm +++ b/lib/PublicInbox/Qspawn.pm @@ -153,11 +153,12 @@ sub start { # and safe to slurp. sub psgi_qx { my ($self, $env, $limiter, $qx_cb) = @_; - my $qx = PublicInbox::Qspawn::Qx->new; + my $scalar = ''; + open(my $qx, '+>', \$scalar) or die; # PerlIO::scalar my $end = sub { finish($self, $env); - eval { $qx_cb->($qx) }; - $qx = undef; + eval { $qx_cb->(\$scalar) }; + $qx = $scalar = undef; }; my $rpipe; # comes from popen_rd my $async = $env->{'pi-httpd.async'}; @@ -338,21 +339,4 @@ sub setup_rlimit { } } -# captures everything into a buffer and executes a callback when done -package PublicInbox::Qspawn::Qx; -use strict; -use warnings; - -sub new { - my ($class) = @_; - my $buf = ''; - bless \$buf, $class; -} - -# called by PublicInbox::HTTPD::Async ($fh->write) -sub write { - ${$_[0]} .= $_[1]; - undef; -} - 1; |