From 058cc69698d2c0c839043cfa9b868d37c718a9f4 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 2 Feb 2020 06:52:18 +0000 Subject: searchidxshard: rely on autoflush instead of ->flush 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; } -- cgit v1.2.3-24-ge0c7