]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/HTTPD/Async.pm
run update-copyrights from gnulib for 2019
[public-inbox.git] / lib / PublicInbox / HTTPD / Async.pm
index 1ffc2565a01c5902030732a351d3269a96b3612c..8e8ece395de065d698b4df19d152cc10d96b93df 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2016-2018 all contributors <meta@public-inbox.org>
+# Copyright (C) 2016-2019 all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # XXX This is a totally unstable API for public-inbox internal use only
@@ -33,13 +33,13 @@ sub new {
        $self;
 }
 
-sub main_cb ($$$) {
-       my ($http, $fh, $bref) = @_;
+sub main_cb ($$) {
+       my ($http, $fh) = @_;
        sub {
                my ($self) = @_;
-               my $r = sysread($self->{sock}, $$bref, 8192);
+               my $r = sysread($self->{sock}, my $buf, 65536);
                if ($r) {
-                       $fh->write($$bref); # may call $http->close
+                       $fh->write($buf); # may call $http->close
                        if ($http->{sock}) { # !closed
                                $self->requeue;
                                # let other clients get some work done, too
@@ -64,7 +64,8 @@ sub async_pass {
        # will automatically close this ($self) object.
        $http->{forward} = $self;
        $fh->write($$bref); # PublicInbox:HTTP::{chunked,identity}_wcb
-       my $cb = $self->{cb} = main_cb($http, $fh, $bref);
+       $$bref = undef; # we're done with this
+       my $cb = $self->{cb} = main_cb($http, $fh);
        $cb->($self); # either hit EAGAIN or ->requeue to keep EPOLLET happy
 }