diff options
author | Eric Wong <e@80x24.org> | 2019-06-24 02:52:09 +0000 |
---|---|---|
committer | Eric Wong <e@80x24.org> | 2019-06-24 05:26:25 +0000 |
commit | 0e1c3fe09a06faf24f7bca159020f69730f1275a (patch) | |
tree | 40bb7f5b2317abf9d36f52db5f3aaf31efbabeba /lib/PublicInbox/HTTP.pm | |
parent | fdf67396c179a64154eaa6c10ac255d61ed39c01 (diff) | |
download | public-inbox-0e1c3fe09a06faf24f7bca159020f69730f1275a.tar.gz |
We don't need write buffering unless we encounter slow clients requesting large responses. So don't waste a hash slot or (empty) arrayref for it.
Diffstat (limited to 'lib/PublicInbox/HTTP.pm')
-rw-r--r-- | lib/PublicInbox/HTTP.pm | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index dff59286..9a43069f 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -67,11 +67,8 @@ sub new ($$$) { sub event_step { # called by PublicInbox::DS my ($self) = @_; - my $wbuf = $self->{wbuf}; - if (@$wbuf) { - $self->write(undef); - return if !$self->{sock} || scalar(@$wbuf); - } + return unless $self->flush_write && $self->{sock}; + # only read more requests if we've drained the write buffer, # otherwise we can be buffering infinitely w/o backpressure @@ -268,7 +265,7 @@ sub getline_cb ($$$) { $write->($buf); # may close in PublicInbox::DS::write if ($self->{sock}) { my $next = $self->{pull}; - if (scalar @{$self->{wbuf}}) { + if ($self->{wbuf}) { $self->write($next); } else { PublicInbox::EvCleanup::asap($next); @@ -323,7 +320,7 @@ use constant MSG_MORE => ($^O eq 'linux') ? 0x8000 : 0; sub more ($$) { my $self = $_[0]; return unless $self->{sock}; - if (MSG_MORE && !scalar(@{$self->{wbuf}})) { + if (MSG_MORE && !$self->{wbuf}) { my $n = send($self->{sock}, $_[1], MSG_MORE); if (defined $n) { my $nlen = length($_[1]) - $n; @@ -490,7 +487,7 @@ sub close { # for graceful shutdown in PublicInbox::Daemon: sub busy () { my ($self) = @_; - ($self->{rbuf} ne '' || $self->{env} || scalar(@{$self->{wbuf}})); + ($self->{rbuf} ne '' || $self->{env} || $self->{wbuf}); } 1; |