From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 0E2931F887 for ; Wed, 25 Dec 2019 07:51:07 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 12/30] qspawn: drop "qspawn.filter" support, for now Date: Wed, 25 Dec 2019 07:50:46 +0000 Message-Id: <20191225075104.22184-13-e@80x24.org> In-Reply-To: <20191225075104.22184-1-e@80x24.org> References: <20191225075104.22184-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This feature was added in preparation for future changes that have yet to materialize after nearly 3 years. We can re-add it if needed in the future. --- lib/PublicInbox/GetlineBody.pm | 6 +++--- lib/PublicInbox/Qspawn.pm | 21 +-------------------- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/lib/PublicInbox/GetlineBody.pm b/lib/PublicInbox/GetlineBody.pm index 750a8c53..bcabc04a 100644 --- a/lib/PublicInbox/GetlineBody.pm +++ b/lib/PublicInbox/GetlineBody.pm @@ -13,13 +13,13 @@ use strict; use warnings; sub new { - my ($class, $rpipe, $end, $end_arg, $buf, $filter) = @_; + my ($class, $rpipe, $end, $end_arg, $buf) = @_; bless { rpipe => $rpipe, end => $end, end_arg => $end_arg, buf => $buf, - filter => $filter || 0, + filter => 0, }, $class; } @@ -36,7 +36,7 @@ sub getline { my $buf = delete $self->{buf}; # initial buffer $buf = $self->{rpipe}->getline unless defined $buf; $self->{filter} = -1 unless defined $buf; # set EOF for next call - $filter ? $filter->($buf) : $buf; + $buf; } sub close { diff --git a/lib/PublicInbox/Qspawn.pm b/lib/PublicInbox/Qspawn.pm index 9e161234..d1a34bea 100644 --- a/lib/PublicInbox/Qspawn.pm +++ b/lib/PublicInbox/Qspawn.pm @@ -27,7 +27,6 @@ package PublicInbox::Qspawn; use strict; use warnings; use PublicInbox::Spawn qw(popen_rd); -require Plack::Util; # n.b.: we get EAGAIN with public-inbox-httpd, and EINTR on other PSGI servers use Errno qw(EAGAIN EINTR); @@ -197,19 +196,6 @@ sub psgi_qx { start($self, $limiter, \&psgi_qx_start); } -# create a filter for "push"-based streaming PSGI writes used by HTTPD::Async -sub filter_fh ($$) { - my ($fh, $filter) = @_; - Plack::Util::inline_object( - close => sub { - $fh->write($filter->(undef)); - $fh->close; - }, - write => sub { - $fh->write($filter->($_[0])); - }); -} - # this is called on pipe EOF to reap the process, may be called # via PublicInbox::DS event loop OR via GetlineBody for generic # PSGI servers. @@ -251,7 +237,6 @@ 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'}; my $wcb = delete $env->{'qspawn.wcb'}; my $async = delete $self->{async}; if (scalar(@$r) == 3) { # error @@ -266,7 +251,6 @@ sub psgi_return_init_cb { } elsif ($async) { # done reading headers, handoff to read body my $fh = $wcb->($r); # scalar @$r == 2 - $fh = filter_fh($fh, $filter) if $filter; $self->{fh} = $fh; $async->async_pass($env->{'psgix.io'}, $fh, delete($self->{hdr_buf})); @@ -274,7 +258,7 @@ sub psgi_return_init_cb { require PublicInbox::GetlineBody; $r->[2] = PublicInbox::GetlineBody->new($self->{rpipe}, \&event_step, $self, - ${$self->{hdr_buf}}, $filter); + ${$self->{hdr_buf}}); $wcb->($r); } @@ -304,9 +288,6 @@ sub psgi_return_start { # may run later, much later... # psgi_return will return an anonymous # sub for the PSGI server to call # -# $env->{'qspawn.filter'} - filter callback, receives a string as input, -# undef on EOF -# # $limiter - the Limiter object to use (uses the def_limiter if not given) # # $parse_hdr - Initial read function; often for parsing CGI header output.