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 490BC1F461; Mon, 24 Jun 2019 18:28:44 +0000 (UTC) Date: Mon, 24 Jun 2019 18:28:44 +0000 From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 59/57] ds: ->write must not clobber empty wbuf array Message-ID: <20190624182844.GA30587@dcvr> References: <20190624025258.25592-1-e@80x24.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190624025258.25592-1-e@80x24.org> List-Id: 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 4947192..08f4e9e 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; } -- EW