From ac1ac3b4e2858bcee5a644aac8b6320422ea7383 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 28 Dec 2019 20:55:16 +0000 Subject: ds: use MSG_MORE when wbuf is empty during long responses HTTP::getline_pull and NNTP::long_step will both populate {wbuf} manually to avoid recursion, so we need to account for an empty-but-present {wbuf} while dispatching msg_more(). --- lib/PublicInbox/DS.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 62aa3c2d..8f17f7fb 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -574,15 +574,18 @@ use constant MSG_MORE => ($^O eq 'linux') ? 0x8000 : 0; sub msg_more ($$) { my $self = $_[0]; my $sock = $self->{sock} or return 1; + my $wbuf = $self->{wbuf}; - if (MSG_MORE && !$self->{wbuf} && ref($sock) ne 'IO::Socket::SSL') { + if (MSG_MORE && (!defined($wbuf) || !scalar(@$wbuf)) && + ref($sock) ne 'IO::Socket::SSL') { my $n = send($sock, $_[1], MSG_MORE); if (defined $n) { my $nlen = bytes::length($_[1]) - $n; return 1 if $nlen == 0; # all done! # queue up the unwritten substring: my $tmpio = tmpio($self, \($_[1]), $n) or return 0; - $self->{wbuf} = [ $tmpio ]; + $self->{wbuf} //= $wbuf //= []; + push @$wbuf, $tmpio; epwait($sock, EPOLLOUT|EPOLLONESHOT); return 0; } -- cgit v1.2.3-24-ge0c7