]> Sergey Matveev's repositories - public-inbox.git/commitdiff
qspawn: drop "qspawn.filter" support, for now
authorEric Wong <e@80x24.org>
Wed, 25 Dec 2019 07:50:46 +0000 (07:50 +0000)
committerEric Wong <e@80x24.org>
Thu, 26 Dec 2019 10:48:19 +0000 (10:48 +0000)
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
lib/PublicInbox/Qspawn.pm

index 750a8c536183e0abeb2cd0eba60b54ab341e6de4..bcabc04a62645dc37292d2386f9292256e776840 100644 (file)
@@ -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 {
index 9e16123424b962e7c2fbc2fc30c6e692d99fd666..d1a34beac89ffd89c38083a0526be6e534395b8d 100644 (file)
@@ -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.