user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 2/2] watch: do not recreate signalfd on SIGHUP
  2023-03-26 10:52  5% [PATCH 0/2] public-inbox-watch fixes Eric Wong
@ 2023-03-26 10:52  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2023-03-26 10:52 UTC (permalink / raw)
  To: meta

The normal method by which PublicInbox::DS::event_loop sets up
signals once needs some coercing to work with -watch.
Otherwise, we'll end up wasting FDs every time somebody reloads
-watch via SIGHUP.
---
 lib/PublicInbox/Watch.pm  | 5 +++--
 script/public-inbox-watch | 1 +
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/PublicInbox/Watch.pm b/lib/PublicInbox/Watch.pm
index 810fb63b..693c7181 100644
--- a/lib/PublicInbox/Watch.pm
+++ b/lib/PublicInbox/Watch.pm
@@ -528,7 +528,8 @@ sub watch_nntp_init ($$) {
 sub watch { # main entry point
 	my ($self, $sig, $oldset) = @_;
 	$self->{oldset} = $oldset;
-	$self->{sig} = $sig;
+	my $first_sig;
+	$self->{sig} //= ($first_sig = $sig);
 	my $poll = {}; # intvl_seconds => [ uri1, uri2 ]
 	watch_imap_init($self, $poll) if $self->{imap};
 	watch_nntp_init($self, $poll) if $self->{nntp};
@@ -538,7 +539,7 @@ sub watch { # main entry point
 	}
 	watch_fs_init($self) if $self->{mdre};
 	local @PublicInbox::DS::post_loop_do = (sub { !$self->quit_done });
-	PublicInbox::DS::event_loop($sig, $oldset); # calls ->event_step
+	PublicInbox::DS::event_loop($first_sig, $oldset); # calls ->event_step
 	_done_for_now($self);
 }
 
diff --git a/script/public-inbox-watch b/script/public-inbox-watch
index 4c50461f..2fb27343 100755
--- a/script/public-inbox-watch
+++ b/script/public-inbox-watch
@@ -27,6 +27,7 @@ my $reload = sub {
 	$watch->quit;
 	$watch = PublicInbox::Watch->new(PublicInbox::Config->new);
 	if ($watch) {
+		$watch->{sig} = $prev->{sig}; # prevent redundant signalfd
 		warn "# reloaded\n";
 	} else {
 		warn("E: reloading failed\n");

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/2] public-inbox-watch fixes
@ 2023-03-26 10:52  5% Eric Wong
  2023-03-26 10:52  7% ` [PATCH 2/2] watch: do not recreate signalfd on SIGHUP Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2023-03-26 10:52 UTC (permalink / raw)
  To: meta

Forcing myself to use the IMAP stuff more...

Eric Wong (2):
  watch: avoid Mail::IMAPClient errors when disconnected
  watch: do not recreate signalfd on SIGHUP

 lib/PublicInbox/Watch.pm  | 10 ++++++----
 script/public-inbox-watch |  1 +
 2 files changed, 7 insertions(+), 4 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-03-26 10:52  5% [PATCH 0/2] public-inbox-watch fixes Eric Wong
2023-03-26 10:52  7% ` [PATCH 2/2] watch: do not recreate signalfd on SIGHUP 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).