about summary refs log tree commit homepage
path: root/lib/PublicInbox/LEI.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2023-10-27 01:14:35 +0000
committerEric Wong <e@80x24.org>2023-10-27 09:14:35 +0000
commit041f9a6a2954fa0c531745b7d1c35c07ab7f9bca (patch)
tree3968874457482d016c21d4eaa989e76825745e22 /lib/PublicInbox/LEI.pm
parenta9208bbb88d003e8a56d9828a43a18bf855ce6f4 (diff)
downloadpublic-inbox-041f9a6a2954fa0c531745b7d1c35c07ab7f9bca.tar.gz
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 avoiding how I caused ->ovv_begin failures to begin with,
that's for a much bigger change...
Diffstat (limited to 'lib/PublicInbox/LEI.pm')
-rw-r--r--lib/PublicInbox/LEI.pm7
1 files 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);