about summary refs log tree commit homepage
path: root/lib/PublicInbox/DS.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-06-24 18:18:18 +0000
committerEric Wong <e@80x24.org>2019-06-24 18:26:04 +0000
commitc30b4427b340aeb242273a7b890fbd7e50132f51 (patch)
treeb7850cc4cd739156e690a096c0bde4a19f1bf585 /lib/PublicInbox/DS.pm
parentac2173434be2be4baba51db6dac7351833cdcdeb (diff)
downloadpublic-inbox-c30b4427b340aeb242273a7b890fbd7e50132f51.tar.gz
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.
Diffstat (limited to 'lib/PublicInbox/DS.pm')
-rw-r--r--lib/PublicInbox/DS.pm5
1 files changed, 4 insertions, 1 deletions
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;
     }