* [PATCH 0/2] public-inbox-watch fixes @ 2023-03-26 10:52 Eric Wong 2023-03-26 10:52 ` [PATCH 1/2] watch: avoid Mail::IMAPClient errors when disconnected Eric Wong 2023-03-26 10:52 ` [PATCH 2/2] watch: do not recreate signalfd on SIGHUP Eric Wong 0 siblings, 2 replies; 3+ messages in thread 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 [flat|nested] 3+ messages in thread
* [PATCH 1/2] watch: avoid Mail::IMAPClient errors when disconnected 2023-03-26 10:52 [PATCH 0/2] public-inbox-watch fixes Eric Wong @ 2023-03-26 10:52 ` Eric Wong 2023-03-26 10:52 ` [PATCH 2/2] watch: do not recreate signalfd on SIGHUP Eric Wong 1 sibling, 0 replies; 3+ messages in thread From: Eric Wong @ 2023-03-26 10:52 UTC (permalink / raw) To: meta No point in issuing LOGOUT commands and causing Mail::IMAPClient to spew a giant backtrace when we're unconnected. --- lib/PublicInbox/Watch.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/PublicInbox/Watch.pm b/lib/PublicInbox/Watch.pm index 8482100c..810fb63b 100644 --- a/lib/PublicInbox/Watch.pm +++ b/lib/PublicInbox/Watch.pm @@ -254,9 +254,10 @@ sub quit { %{$self->{opendirs}} = (); _done_for_now($self); quit_done($self); - if (my $idle_mic = $self->{idle_mic}) { + if (my $idle_mic = delete $self->{idle_mic}) { + return unless $idle_mic->IsConnected && $idle_mic->Socket; eval { $idle_mic->done }; - if ($@) { + if ($@ && $idle_mic->IsConnected && $idle_mic->Socket) { warn "IDLE DONE error: $@\n"; eval { $idle_mic->disconnect }; warn "IDLE LOGOUT error: $@\n" if $@; ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] watch: do not recreate signalfd on SIGHUP 2023-03-26 10:52 [PATCH 0/2] public-inbox-watch fixes Eric Wong 2023-03-26 10:52 ` [PATCH 1/2] watch: avoid Mail::IMAPClient errors when disconnected Eric Wong @ 2023-03-26 10:52 ` Eric Wong 1 sibling, 0 replies; 3+ messages in thread 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 [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-03-26 10:52 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2023-03-26 10:52 [PATCH 0/2] public-inbox-watch fixes Eric Wong 2023-03-26 10:52 ` [PATCH 1/2] watch: avoid Mail::IMAPClient errors when disconnected Eric Wong 2023-03-26 10:52 ` [PATCH 2/2] watch: do not recreate signalfd on SIGHUP Eric Wong
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).