]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: remove INT/QUIT/TERM handlers, fix daemon EOF
authorEric Wong <e@80x24.org>
Thu, 21 Jan 2021 19:46:20 +0000 (19:46 +0000)
committerEric Wong <e@80x24.org>
Fri, 22 Jan 2021 20:18:01 +0000 (16:18 -0400)
The signal handlers on the client side were unnecessary,
all we need is to handle socket EOF properly in the daemon
by killing xsearch and l2m workers.

lib/PublicInbox/IPC.pm
lib/PublicInbox/LEI.pm
script/lei

index 24f45e036d99058b0dd08d77810fa08f00322c7f..dbb87e4ebedb006dbaa22d11786fd8d2cc686d3d 100644 (file)
@@ -408,6 +408,7 @@ sub DESTROY {
        my $ppid = $self->{-wq_ppid};
        wq_kill($self) if $ppid && $ppid == $$;
        wq_close($self);
+       wq_wait_old($self);
        ipc_worker_stop($self);
 }
 
index 11ea385f2a1976619a873f585a72aed0e1dfc06d..ccfc16496fe17fd0c189f0571e2b5af93650a12c 100644 (file)
@@ -767,7 +767,14 @@ sub accept_dispatch { # Listener {post_accept} callback
 
 sub dclose {
        my ($self) = @_;
-       delete $self->{lxs}; # stops LeiXSearch queries
+       for my $f (qw(lxs l2m)) {
+               my $wq = delete $self->{$f} or next;
+               if ($wq->wq_kill) {
+                       $self->wq_close
+               } elsif ($wq->wq_kill_old) {
+                       $wq->wq_wait_old;
+               }
+       }
        close(delete $self->{1}) if $self->{1}; # may reap_compress
        $self->close if $self->{sock}; # PublicInbox::DS::close
 }
index a4a0217bfa3237ca0f684a012bcbf98740abd7e1..8dcea56290d8d35fa0550e3b190fa632cdac1259 100755 (executable)
@@ -81,11 +81,6 @@ Falling back to (slow) one-shot mode
        while (my ($k, $v) = each %ENV) { $buf .= "\0$k=$v" }
        $buf .= "\0\0";
        $send_cmd->($sock, [ 0, 1, 2, fileno($dh) ], $buf, MSG_EOR);
-       $SIG{TERM} = $SIG{INT} = $SIG{QUIT} = sub {
-               my ($sig) = @_; # 'TERM', not an integer :<
-               $SIG{$sig} = 'DEFAULT';
-               kill($sig, $$); # exit($signo + 128)
-       };
        my $x_it_code = 0;
        while (1) {
                my (@fds) = $recv_cmd->($sock, $buf, 4096 * 33);