about summary refs log tree commit
diff options
context:
space:
mode:
authorEric Wong <e@yhbt.net>2020-02-02 06:52:18 +0000
committerEric Wong <e@yhbt.net>2020-02-02 17:29:54 +0000
commit058cc69698d2c0c839043cfa9b868d37c718a9f4 (patch)
treeb71d3e4789b540ef8a809093f747e5333da14cbf
parentb02b2a5d7cb5a811f041febd09d625bdc1af1d8e (diff)
downloadpublic-inbox-058cc69698d2c0c839043cfa9b868d37c718a9f4.tar.gz
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.
-rw-r--r--lib/PublicInbox/SearchIdxShard.pm4
1 files 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;
         }