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 A01151FD45 for ; Sun, 2 Feb 2020 06:52:23 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 5/9] searchidxshard: rely on autoflush instead of ->flush Date: Sun, 2 Feb 2020 06:52:18 +0000 Message-Id: <20200202065222.14966-6-e@yhbt.net> In-Reply-To: <20200202065222.14966-1-e@yhbt.net> References: <20200202065222.14966-1-e@yhbt.net> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: It reduces the number of ops and simplifies the code, slightly. Add a missing IO::Handle import while we're at it, to be explicit about which methods we use. --- lib/PublicInbox/SearchIdxShard.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm index b22e51dc..0522ecea 100644 --- a/lib/PublicInbox/SearchIdxShard.pm +++ b/lib/PublicInbox/SearchIdxShard.pm @@ -7,6 +7,7 @@ package PublicInbox::SearchIdxShard; use strict; use warnings; use base qw(PublicInbox::SearchIdx); +use IO::Handle (); # autoflush sub new { my ($class, $v2writable, $shard) = @_; @@ -24,6 +25,7 @@ sub spawn_worker { pipe($r, $w) or die "pipe failed: $!\n"; binmode $r, ':raw'; binmode $w, ':raw'; + $w->autoflush(1); my $pid = fork; defined $pid or die "fork failed: $!\n"; if ($pid == 0) { @@ -83,7 +85,6 @@ sub index_raw { if (my $w = $self->{w}) { print $w "$bytes $artnum $oid $mid0\n", $$msgref or die "failed to write shard $!\n"; - $w->flush or die "failed to flush: $!\n"; } else { $$msgref = undef; $self->begin_txn_lazy; @@ -100,7 +101,6 @@ sub remote_barrier { my ($self) = @_; if (my $w = $self->{w}) { print $w "barrier\n" or die "failed to print: $!"; - $w->flush or die "failed to flush: $!"; } else { $self->commit_txn_lazy; }