From 42bb1574bf35a18f037d4ca8b0e6696192d301df Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 10 Jun 2019 01:33:30 +0000 Subject: ds: simplify write buffer accounting Keeping track of write_buf_size was redundant and pointless when we can simply check the number of elements in the buffer array. Multiple sources of truth leads to confusion; confusion leads to bugs. Finally, rename the prefixes to 'wbuf' to ensure we loudly (instead of silently) break any external dependencies being ported over from Danga::Socket, as further changes are pending. --- lib/PublicInbox/HTTP.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox/HTTP.pm') diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm index 977614b4..fd103251 100644 --- a/lib/PublicInbox/HTTP.pm +++ b/lib/PublicInbox/HTTP.pm @@ -260,7 +260,7 @@ sub getline_cb ($$$) { $write->($buf); # may close in PublicInbox::DS::write unless ($self->{closed}) { my $next = $self->{pull}; - if ($self->{write_buf_size}) { + if (scalar @{$self->{wbuf}}) { $self->write($next); } else { PublicInbox::EvCleanup::asap($next); @@ -315,7 +315,7 @@ use constant MSG_MORE => ($^O eq 'linux') ? 0x8000 : 0; sub more ($$) { my $self = $_[0]; return if $self->{closed}; - if (MSG_MORE && !$self->{write_buf_size}) { + if (MSG_MORE && !scalar(@{$self->{wbuf}})) { my $n = send($self->{sock}, $_[1], MSG_MORE); if (defined $n) { my $nlen = length($_[1]) - $n; @@ -487,7 +487,7 @@ sub close { # for graceful shutdown in PublicInbox::Daemon: sub busy () { my ($self) = @_; - ($self->{rbuf} ne '' || $self->{env} || $self->{write_buf_size}); + ($self->{rbuf} ne '' || $self->{env} || scalar(@{$self->{wbuf}})); } 1; -- cgit v1.2.3-24-ge0c7