* [PATCH 0/7] lei: more process handling fixes
@ 2021-10-14 13:16 6% ` Eric Wong
2021-10-14 13:16 7% ` [PATCH 7/7] lei up --all: send signals to workers, receive errors Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-10-14 13:16 UTC (permalink / raw)
To: meta
"lei up --all" SIGTSTP/CONT/INT handling was totally
broken and now fixed. And we put cat-file processes
into their own pgrp, so it avoids scary errors when
hitting Ctrl-C on -extindex, too.
Automated testing of interactive stuff is tricky, so
it's not being done, currently :<
Eric Wong (7):
lei: use send() perlop for signals
git: async_err shows retried requests properly
git: ->fail invokes current callback
git: cat-file --batch are their own pgrp
lei: TSTP affects all curl and related subprocesses
lei up: actually rely on DESTROY for --all
lei up --all: send signals to workers, receive errors
MANIFEST | 1 +
lib/PublicInbox/AutoReap.pm | 34 +++++++++++++++++++++++++++++++++
lib/PublicInbox/Git.pm | 36 +++++++++++++++++++----------------
lib/PublicInbox/LEI.pm | 14 +++++++-------
lib/PublicInbox/LeiInput.pm | 7 ++++---
lib/PublicInbox/LeiMirror.pm | 8 +++-----
lib/PublicInbox/LeiRemote.pm | 13 +++++--------
lib/PublicInbox/LeiToMail.pm | 2 +-
lib/PublicInbox/LeiUp.pm | 22 ++++++++++++++++++---
lib/PublicInbox/LeiXSearch.pm | 20 +++++++++----------
lib/PublicInbox/TestCommon.pm | 36 +++--------------------------------
script/lei | 4 ++--
12 files changed, 108 insertions(+), 89 deletions(-)
create mode 100644 lib/PublicInbox/AutoReap.pm
^ permalink raw reply [relevance 6%]
* [PATCH 7/7] lei up --all: send signals to workers, receive errors
2021-10-14 13:16 6% ` [PATCH 0/7] lei: more process handling fixes Eric Wong
@ 2021-10-14 13:16 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-10-14 13:16 UTC (permalink / raw)
To: meta
The redispatch mechanism wasn't routing signals and messages
between redispatched workers and script/lei properly. We now
rely on PktOp to do bidirectional message forwarding and
carefully avoiding circular references by using PktOp.
---
lib/PublicInbox/LEI.pm | 7 ++++++-
lib/PublicInbox/LeiUp.pm | 13 ++++++++++++-
2 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index d0905562f616..b6338377328f 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -573,6 +573,7 @@ sub _lei_atfork_child {
POSIX::setpgid(0, $$) // die "setpgid(0, $$): $!";
}
close($_) for (grep(defined, delete @$self{qw(3 old_1 au_done)}));
+ delete $self->{-socks};
if (my $op_c = delete $self->{pkt_op_c}) {
close(delete $op_c->{sock});
}
@@ -1144,7 +1145,9 @@ sub event_step {
if ($buf eq '') {
_drop_wq($self); # EOF, client disconnected
dclose($self);
- } elsif ($buf =~ /\A(?:STOP|CONT)\z/) {
+ $buf = 'TERM';
+ }
+ if ($buf =~ /\A(?:STOP|CONT|TERM)\z/) {
my $sig = "-$buf";
for my $wq (grep(defined, @$self{@WQ_KEYS})) {
$wq->wq_kill($sig) or $wq->wq_kill_old($sig);
@@ -1152,6 +1155,8 @@ sub event_step {
} else {
die "unrecognized client signal: $buf";
}
+ my $s = $self->{-socks} // []; # lei up --all
+ @$s = grep { send($_, $buf, MSG_EOR) } @$s;
};
if (my $err = $@) {
eval { $self->fail($err) };
diff --git a/lib/PublicInbox/LeiUp.pm b/lib/PublicInbox/LeiUp.pm
index 719736e8597e..df65cb9b8474 100644
--- a/lib/PublicInbox/LeiUp.pm
+++ b/lib/PublicInbox/LeiUp.pm
@@ -166,7 +166,15 @@ sub event_step { # runs via PublicInbox::DS::requeue
push(@m, $o) if !@m || $m[-1] !~ s/\n\z/$o\n/;
$cb->(@m);
};
- $l->{-up1} = $self;
+ $l->{-up1} = $self; # for LeiUp1->DESTROY
+ delete @$l{qw(-socks -event_init_done)};
+ my ($op_c, $op_p) = PublicInbox::PktOp->pair;
+ $self->{unref_on_destroy} = $op_c->{sock}; # to cleanup $lei->{-socks}
+ $lei->pkt_ops($op_c->{ops} //= {}); # errors from $l -> script/lei
+ push @{$lei->{-socks}}, $op_c->{sock}; # script/lei signals to $l
+ $l->{sock} = $op_p->{op_p}; # receive signals from op_c->{sock}
+ $op_c = $op_p = undef;
+
eval { $l->dispatch('up', $self->{out}) };
$lei->child_error(0, $@) if $@ || $l->{failed}; # lei->fail()
}
@@ -175,6 +183,9 @@ sub DESTROY {
my ($self) = @_;
my $lei = $self->{lei}; # the original, from lei_up
return if $lei->{daemon_pid} != $$;
+ my $sock = delete $self->{unref_on_destroy};
+ my $s = $lei->{-socks} // [];
+ @$s = grep { $_ != $sock } @$s;
my $out = shift(@{$lei->{-upq}}) or return;
PublicInbox::DS::requeue(nxt($lei, $out, $self->{op_p}));
}
^ permalink raw reply related [relevance 7%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-10-14 4:32 [PATCH 3/3] lei: give workers their own process group Eric Wong
2021-10-14 13:16 6% ` [PATCH 0/7] lei: more process handling fixes Eric Wong
2021-10-14 13:16 7% ` [PATCH 7/7] lei up --all: send signals to workers, receive errors Eric Wong
Code repositories for project(s) associated with this public inbox
https://80x24.org/public-inbox.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).