From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id EB7291F463 for ; Sat, 28 Dec 2019 20:55:16 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH] ds: use MSG_MORE when wbuf is empty during long responses Date: Sat, 28 Dec 2019 20:55:16 +0000 Message-Id: <20191228205516.23901-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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(-) 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; }