From c30b4427b340aeb242273a7b890fbd7e50132f51 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Mon, 24 Jun 2019 18:18:18 +0000 Subject: [PATCH] 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. --- lib/PublicInbox/DS.pm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm index 4947192f..08f4e9e8 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; } -- 2.44.0