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.
my $ppid = $self->{-wq_ppid};
wq_kill($self) if $ppid && $ppid == $$;
wq_close($self);
my $ppid = $self->{-wq_ppid};
wq_kill($self) if $ppid && $ppid == $$;
wq_close($self);
ipc_worker_stop($self);
}
ipc_worker_stop($self);
}
sub dclose {
my ($self) = @_;
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
}
close(delete $self->{1}) if $self->{1}; # may reap_compress
$self->close if $self->{sock}; # PublicInbox::DS::close
}
while (my ($k, $v) = each %ENV) { $buf .= "\0$k=$v" }
$buf .= "\0\0";
$send_cmd->($sock, [ 0, 1, 2, fileno($dh) ], $buf, MSG_EOR);
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);
my $x_it_code = 0;
while (1) {
my (@fds) = $recv_cmd->($sock, $buf, 4096 * 33);