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-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 2405E1FB06 for ; Tue, 15 Dec 2020 02:02:26 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 9/9] searchidxshard: simplify newline elimination Date: Tue, 15 Dec 2020 02:02:24 +0000 Message-Id: <20201215020224.11739-10-e@80x24.org> In-Reply-To: <20201215020224.11739-1-e@80x24.org> References: <20201215020224.11739-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This overdue change fixes {current_info} to not inject a newline into every warning message. Simpler code helps us avoid bugs and the need to make fixes like commit 44de182766037948d62bc2a8ba924de2264dd5fc ("searchidxshard: chomp $eidx_key from pipe"). --- lib/PublicInbox/SearchIdxShard.pm | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/lib/PublicInbox/SearchIdxShard.pm b/lib/PublicInbox/SearchIdxShard.pm index ee00858b..2e654769 100644 --- a/lib/PublicInbox/SearchIdxShard.pm +++ b/lib/PublicInbox/SearchIdxShard.pm @@ -69,33 +69,31 @@ sub shard_worker_loop ($$$$$) { $0 = "shard[$shard]"; $self->begin_txn_lazy; while (my $line = readline($r)) { + chomp $line; $v2w->{current_info} = "[$shard] $line"; - if ($line eq "commit\n") { + if ($line eq 'commit') { $self->commit_txn_lazy; - } elsif ($line eq "close\n") { + } elsif ($line eq 'close') { $self->idx_release; - } elsif ($line eq "barrier\n") { + } elsif ($line eq 'barrier') { $self->commit_txn_lazy; # no need to lock < 512 bytes is atomic under POSIX print $bnote "barrier $shard\n" or die "write failed for barrier $!\n"; - } elsif ($line =~ /\AD ([0-9]+)\n\z/s) { + } elsif ($line =~ /\AD ([0-9]+)\z/s) { $self->remove_by_docid($1 + 0); } elsif ($line =~ s/\A\+X //) { my ($len, $docid, $eidx_key) = split(/ /, $line, 3); - chomp $eidx_key; $self->add_eidx_info($docid, $eidx_key, eml($r, $len)); } elsif ($line =~ s/\A-X //) { my ($len, $docid, $eidx_key) = split(/ /, $line, 3); - chomp $eidx_key; $self->remove_eidx_info($docid, $eidx_key, eml($r, $len)); - } elsif ($line =~ s/\AO ([^\n]+)\n//) { + } elsif ($line =~ s/\AO ([^\n]+)//) { my $over_fn = $1; $over_fn =~ tr/\0/\n/; $self->over_check(PublicInbox::Over->new($over_fn)); } else { - chomp $line; my $eidx_key; if ($line =~ s/\AX=(.+)\0//) { $eidx_key = $1;