From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id DD7F61F406 for ; Fri, 27 Oct 2023 01:14:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1698369283; bh=jZzCvirvUaXlXgwekcles1Y4Ct25B4v0pMEyMx7oVv4=; h=From:To:Subject:Date:From; b=O+xjuoYXQHvEPj/vCXk04q1enU59MovxnVb/w6iVmSK3Lc4NrBSFm8cgkJizqOlio skl2UPgBG8b/eCjcDs/+dkaMP8q2Lnt1yWoa8jBCaCH1es4RaTopGzQsM49XG2EeE3 2E83PbveD1c0E3TVSeb0dHtJR1h+aTrCdxOkNFAY= From: Eric Wong To: spew@80x24.org Subject: [PATCH 1/8] lei: don't exit lei-daemon on ovv_begin failure Date: Fri, 27 Oct 2023 01:14:36 +0000 Message-ID: <20231027011443.3709841-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: When ->ovv_begin is called in LeiXSearch->do_query in the top-level lei-daemon process, $lei->{pkt_op_p} still exists. We must make sure we're exiting the correct process since lei->out can call lei->fail and lei->fail calls lei->x_it. As to how I caused ->ovv_begin failures and how to reproduce them, that's for another commit. --- lib/PublicInbox/LEI.pm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 7bc7b2dc..e060bcbe 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -40,6 +40,7 @@ $GLP_PASS->configure(qw(gnu_getopt no_ignore_case auto_abbrev pass_through)); our (%PATH2CFG, # persistent for socket daemon $MDIR2CFGPATH, # /path/to/maildir => { /path/to/config => [ ino watches ] } $OPT, # shared between optparse and opt_dash callback (for Getopt::Long) +$daemon_pid ); # TBD: this is a documentation mechanism to show a subcommand @@ -486,7 +487,7 @@ sub x_it ($$) { stop_pager($self); if ($self->{pkt_op_p}) { # worker => lei-daemon $self->{pkt_op_p}->pkt_do('x_it', $code); - exit($code >> 8); + exit($code >> 8) if $$ != $daemon_pid; } elsif ($self->{sock}) { # lei->daemon => lei(1) client send($self->{sock}, "x_it $code", 0); } elsif ($quit == \&CORE::exit) { # an admin (one-shot) command @@ -1341,8 +1342,8 @@ sub lazy_start { my $pid = fork; return if $pid; $0 = "lei-daemon $path"; - local %PATH2CFG; - local $MDIR2CFGPATH; + local (%PATH2CFG, $MDIR2CFGPATH); + local $daemon_pid = $$; $listener->blocking(0); my $exit_code; my $pil = PublicInbox::Listener->new($listener, \&accept_dispatch);