* [PATCH 02/13] lei: use cached $daemon_pid when possible
2023-11-09 10:09 5% [PATCH 00/13] misc error handling stuff and simplifications Eric Wong
@ 2023-11-09 10:09 7% ` Eric Wong
0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-11-09 10:09 UTC (permalink / raw)
To: meta
->lei_daemon_pid can only be called in the top-level daemon
process when $daemon_pid is valid, so avoid a getpid(2) syscall
in those cases.
---
lib/PublicInbox/LEI.pm | 2 +-
lib/PublicInbox/LeiUp.pm | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm
index 2832db63..f32e5bbc 100644
--- a/lib/PublicInbox/LEI.pm
+++ b/lib/PublicInbox/LEI.pm
@@ -927,7 +927,7 @@ sub _config {
run_wait($cmd, \%env, \%opt) ? ($err_ok ? undef : fail($self, $?)) : 1;
}
-sub lei_daemon_pid { puts shift, $$ }
+sub lei_daemon_pid { puts shift, $daemon_pid }
sub lei_daemon_kill {
my ($self) = @_;
diff --git a/lib/PublicInbox/LeiUp.pm b/lib/PublicInbox/LeiUp.pm
index cd2337b4..0faa180d 100644
--- a/lib/PublicInbox/LeiUp.pm
+++ b/lib/PublicInbox/LeiUp.pm
@@ -11,6 +11,7 @@ use PublicInbox::LeiSavedSearch; # OverIdx
use PublicInbox::DS;
use PublicInbox::PktOp;
use PublicInbox::LeiFinmsg;
+use PublicInbox::LEI;
my $REMOTE_RE = qr!\A(?:imap|http)s?://!i; # http(s) will be for JMAP
sub up1 ($$) {
@@ -92,7 +93,6 @@ sub redispatch_all ($$) {
$op_c->{ops} = { '' => [ $lei->can('dclose'), $lei ] };
my @first_batch = splice(@$upq, 0, $j); # initial parallelism
$lei->{-upq} = $upq;
- $lei->{daemon_pid} = $$;
$lei->event_step_init; # wait for client disconnects
for my $out (@first_batch) {
PublicInbox::DS::requeue(
@@ -212,8 +212,8 @@ sub event_step { # runs via PublicInbox::DS::requeue
sub DESTROY {
my ($self) = @_;
+ return if ($PublicInbox::LEI::daemon_pid // -1) != $$;
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;
^ permalink raw reply related [relevance 7%]
* [PATCH 00/13] misc error handling stuff and simplifications
@ 2023-11-09 10:09 5% Eric Wong
2023-11-09 10:09 7% ` [PATCH 02/13] lei: use cached $daemon_pid when possible Eric Wong
0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-11-09 10:09 UTC (permalink / raw)
To: meta
1-4 were things I noticed while chasing the lei SIGPIPE handling
fix. 5-7 are things I noticed while testing on Dragonfly and
NetBSD. 8 was noticed randomly while working on a new mirror,
and the last few complete the work which let me get rid of tied
IO handles in favor of using the PublicInbox::IO subclass.
Eric Wong (13):
lei_xsearch: put query in process title for debugging
lei: use cached $daemon_pid when possible
lei: reuse FDs atfork and close explicitly
lei_up: use v5.12
net_nntp_socks: more comments around how it works
lei ls-mail-source: gracefully handle network failures
net: retry on EINTR and check for {quit} flag
lei_mirror: note missing local manifests are non-fatal
ipc: simplify partial sendmsg fallback
lei_input: always close single `eml' inputs
xapcmd: get rid of scalar wantarray popen_rd
lei: get rid of autoreap usage
spawn: get rid of wantarray popen_rd/popen_wr
lib/PublicInbox/IPC.pm | 13 ++------
lib/PublicInbox/LEI.pm | 11 ++++---
lib/PublicInbox/LeiInput.pm | 26 +++++++--------
lib/PublicInbox/LeiLsMailSource.pm | 6 ++--
lib/PublicInbox/LeiMirror.pm | 5 +--
lib/PublicInbox/LeiRemote.pm | 14 ++++----
lib/PublicInbox/LeiUp.pm | 10 +++---
lib/PublicInbox/LeiXSearch.pm | 27 ++++++++-------
lib/PublicInbox/NetNNTPSocks.pm | 12 ++++---
lib/PublicInbox/NetReader.pm | 53 +++++++++++++++++++++---------
lib/PublicInbox/Spawn.pm | 6 ++--
lib/PublicInbox/TestCommon.pm | 23 ++++++++++++-
lib/PublicInbox/Watch.pm | 2 +-
lib/PublicInbox/Xapcmd.pm | 12 +++----
t/io.t | 8 +----
t/ipc.t | 7 ++++
t/lei-import.t | 27 +++++++++++++++
17 files changed, 163 insertions(+), 99 deletions(-)
^ permalink raw reply [relevance 5%]
Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2023-11-09 10:09 5% [PATCH 00/13] misc error handling stuff and simplifications Eric Wong
2023-11-09 10:09 7% ` [PATCH 02/13] lei: use cached $daemon_pid when possible 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).