From: Eric Wong Date: Mon, 24 Jun 2019 18:18:18 +0000 (+0000) Subject: ds: ->write must not clobber empty wbuf array X-Git-Tag: v1.2.0~156^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c30b4427b340aeb242273a7b890fbd7e50132f51;p=thirdparty%2Fpublic-inbox.git ds: ->write must not clobber empty wbuf array We need to account for ->write(CODE) calls doing ->write(SCALARREF), otherwise flush_write may see the wrong ->{wbuf} field. --- diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 4947192f8..08f4e9e8a 100644 --- a/lib/PublicInbox/DS.pm +++ b/lib/PublicInbox/DS.pm @@ -505,7 +505,10 @@ sub write { return $self->close; } my $tmpio = tmpio($self, $bref, $written) or return 0; - $self->{wbuf} = [ $tmpio ]; + + # wbuf may be an empty array if we're being called inside + # ->flush_write via CODE bref: + push @{$self->{wbuf} ||= []}, $tmpio; watch($self, EPOLLOUT|EPOLLONESHOT); return 0; }