From: Eric Wong <e@80x24.org>
To: meta@public-inbox.org
Subject: [PATCH] ds: use a dummy poller during Reset
Date: Tue, 10 Oct 2023 10:09:04 +0000 [thread overview]
Message-ID: <20231010100904.351568-1-e@80x24.org> (raw)
commit 1897c3be1ed644a05f96ed06cde4a9cc2ad0e5a4
(ds: Reset: replace Poller object early, 2023-10-04)
was not effective at eliminating the following message
at daemon shutdown:
Can't call method "FILENO" on an undefined value at
.../PublicInbox/Select.pm line 34 during global destruction.
This seems down to some tied objects having unpredictable
destruction order. So use a dummy class to ensure its ep_*
methods never call the tied `FILENO' method at all since
dropping the Poller object will release any resources it holds.
---
lib/PublicInbox/DS.pm | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 26cc83f0..eefbdcc3 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -67,12 +67,12 @@ Reset all state
=cut
sub Reset {
+ $Poller = bless [], 'PublicInbox::DummyPoller';
do {
$in_loop = undef; # first in case DESTROY callbacks use this
# clobbering $Poller may call DSKQXS::DESTROY,
# we must always have this set to something to avoid
# needing branches before ep_del/ep_mod calls (via ->close).
- $Poller = PublicInbox::Select->new;
%DescriptorMap = (); # likely to call ep_del
@Timers = ();
%UniqTimer = ();
@@ -82,7 +82,6 @@ sub Reset {
@$cur_runq = () if $cur_runq;
$nextq = $ToClose = undef; # may call ep_del
%AWAIT_PIDS = ();
- $Poller = PublicInbox::Select->new;
} while (@Timers || $nextq || keys(%AWAIT_PIDS) ||
$ToClose || keys(%DescriptorMap) ||
@post_loop_do || keys(%UniqTimer) ||
@@ -738,6 +737,14 @@ sub awaitpid {
}
}
+package PublicInbox::DummyPoller; # only used during Reset
+use v5.12;
+
+sub ep_del {}
+no warnings 'once';
+*ep_add = \&ep_del;
+*ep_mod = \&ep_del;
+
1;
=head1 AUTHORS (Danga::Socket)
reply other threads:[~2023-10-10 10:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20231010100904.351568-1-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).