]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/SearchIdxShard.pm
nntpd: remove redundant {groups} shortcut
[public-inbox.git] / lib / PublicInbox / SearchIdxShard.pm
index 1333b30529e857b5fb205dc4b24e0c8275b30e66..dcfeb0beec76c1c9e452cfad24a118e62c1cc007 100644 (file)
@@ -10,6 +10,7 @@ use parent qw(PublicInbox::SearchIdx);
 use bytes qw(length);
 use IO::Handle (); # autoflush
 use PublicInbox::Eml;
+use PublicInbox::Sigfd;
 
 sub new {
        my ($class, $v2w, $shard) = @_; # v2w may be ExtSearchIdx
@@ -29,9 +30,13 @@ sub spawn_worker {
        my ($r, $w);
        pipe($r, $w) or die "pipe failed: $!\n";
        $w->autoflush(1);
+       my $oldset = PublicInbox::Sigfd::block_signals();
        my $pid = fork;
        defined $pid or die "fork failed: $!\n";
        if ($pid == 0) {
+               # these signals are localized in parent
+               $SIG{$_} = 'IGNORE' for (qw(TERM INT QUIT));
+               PublicInbox::Sigfd::sig_setmask($oldset);
                my $bnote = $v2w->atfork_child;
                close $w or die "failed to close: $!";
 
@@ -44,6 +49,7 @@ sub spawn_worker {
                die "unexpected MM $self->{mm}" if $self->{mm};
                exit;
        }
+       PublicInbox::Sigfd::sig_setmask($oldset);
        $self->{pid} = $pid;
        $self->{w} = $w;
        close $r or die "failed to close: $!";
@@ -77,11 +83,13 @@ sub shard_worker_loop ($$$$$) {
                } elsif ($line =~ s/\A\+X //) {
                        my ($len, $docid, $oid, $eidx_key) =
                                                        split(/ /, $line, 4);
+                       chomp $eidx_key;
                        $self->add_eidx_info($docid, $oid, $eidx_key,
                                                        eml($r, $len));
                } elsif ($line =~ s/\A-X //) {
                        my ($len, $docid, $oid, $eidx_key) =
                                                        split(/ /, $line, 4);
+                       chomp $eidx_key;
                        $self->remove_eidx_info($docid, $oid, $eidx_key,
                                                        eml($r, $len));
                } else {