about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2021-04-30 09:24:33 +0000
committerEric Wong <e@80x24.org>2021-04-30 19:59:44 +0000
commit8bb96e2da15ce323024be8de8b89bc386ee33339 (patch)
tree26415e3e91485aa5f57a61b56be1a7496a9b2580
parent77ce8b2a15495f7144e806e0747cb13e2ab7fe27 (diff)
downloadpublic-inbox-8bb96e2da15ce323024be8de8b89bc386ee33339.tar.gz
This ensures hitting Ctrl-C on a long-running "lei convert" or
similar will stop the WQ worker, even after we've closed
the WQ socketpair in the daemon.
-rw-r--r--lib/PublicInbox/LEI.pm9
1 files changed, 8 insertions, 1 deletions
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 52ce8ec2..3468094f 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -387,7 +387,14 @@ my @WQ_KEYS = qw(lxs l2m wq1); # internal workers
 
 sub _drop_wq {
         my ($self) = @_;
-        for my $wq (grep(defined, delete(@$self{@WQ_KEYS}))) { $wq->DESTROY }
+        for my $wq (grep(defined, delete(@$self{@WQ_KEYS}))) {
+                if ($wq->wq_kill) {
+                        $wq->wq_close(0, undef, $self);
+                } elsif ($wq->wq_kill_old) {
+                        $wq->wq_wait_old(undef, $self);
+                }
+                $wq->DESTROY;
+        }
 }
 
 # pronounced "exit": x_it(1 << 8) => exit(1); x_it(13) => SIGPIPE