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/NNTP.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/NNTP.pm')
-rw-r--r-- | lib/PublicInbox/NNTP.pm | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 0a473e42..d9097cc7 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -644,7 +644,7 @@ sub long_response ($$) { out($self, " deferred[$fd] aborted - %0.6f", now() - $t0); } - } elsif ($more) { # scalar @{$self->{wbuf}}: + } elsif ($more) { # $self->{wbuf}: # no recursion, schedule another call ASAP # but only after all pending writes are done update_idle_time($self); @@ -950,7 +950,7 @@ use constant MSG_MORE => ($^O eq 'linux') ? 0x8000 : 0; sub do_more ($$) { my ($self, $data) = @_; - if (MSG_MORE && !scalar(@{$self->{wbuf}})) { + if (MSG_MORE && !$self->{wbuf}) { my $n = send($self->{sock}, $data, MSG_MORE); if (defined $n) { my $dlen = length($data); @@ -963,15 +963,11 @@ sub do_more ($$) { sub event_step { my ($self) = @_; - return unless $self->{sock}; - my $wbuf = $self->{wbuf}; - if (@$wbuf) { - update_idle_time($self); - $self->write(undef); - return if !$self->{sock} || scalar(@$wbuf); - } + return unless $self->flush_write && $self->{sock}; return if $self->{long_res}; + + update_idle_time($self); # only read more requests if we've drained the write buffer, # otherwise we can be buffering infinitely w/o backpressure @@ -1035,7 +1031,7 @@ sub not_idle_long ($$) { sub busy { my ($self, $now) = @_; ($self->{rbuf} ne '' || $self->{long_res} || - scalar(@{$self->{wbuf}}) || not_idle_long($self, $now)); + $self->{wbuf} || not_idle_long($self, $now)); } 1; |