about summary refs log tree commit homepage
path: root/lib
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2022-08-08 23:53:08 +0000
committerEric Wong <e@80x24.org>2022-08-09 16:41:51 +0000
commit60d262483a4d6ddf295f5124aed3672866795ee5 (patch)
tree191993a87300db06ce44ff566142e37b1ec67f28 /lib
parent86389293edbe3273b3ff0f61cbeb9cb6a0dfe2f2 (diff)
downloadpublic-inbox-60d262483a4d6ddf295f5124aed3672866795ee5.tar.gz
This allows "-l $ADDRESS?err=/path/to/err.log to isolate normal
warn() (and carp()) messages for a particular listen address to
track down errors more easily.
Diffstat (limited to 'lib')
-rw-r--r--lib/PublicInbox/Daemon.pm2
-rw-r--r--lib/PublicInbox/HTTP.pm2
-rw-r--r--lib/PublicInbox/HTTPD.pm1
-rw-r--r--lib/PublicInbox/IMAP.pm2
-rw-r--r--lib/PublicInbox/NNTP.pm2
-rw-r--r--lib/PublicInbox/POP3.pm1
6 files changed, 7 insertions, 3 deletions
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index 0043d21e..bb140640 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -134,6 +134,8 @@ sub load_mod ($;$$) {
                 $tlsd->{$f} = $logs{$p} //= open_log_path(my $fh, $p);
                 warn "# $scheme://$addr $f=$p\n";
         }
+        my $err = $tlsd->{err};
+        $tlsd->{warn_cb} = sub { print $err @_ }; # for local $SIG{__WARN__}
         \%xn;
 }
 
diff --git a/lib/PublicInbox/HTTP.pm b/lib/PublicInbox/HTTP.pm
index 3d4e3499..0dba425d 100644
--- a/lib/PublicInbox/HTTP.pm
+++ b/lib/PublicInbox/HTTP.pm
@@ -69,7 +69,7 @@ sub new ($$$) {
 
 sub event_step { # called by PublicInbox::DS
         my ($self) = @_;
-
+        local $SIG{__WARN__} = $self->{srv_env}->{'pi-httpd.warn_cb'};
         return unless $self->flush_write && $self->{sock};
 
         # only read more requests if we've drained the write buffer,
diff --git a/lib/PublicInbox/HTTPD.pm b/lib/PublicInbox/HTTPD.pm
index e531ee70..bae7281b 100644
--- a/lib/PublicInbox/HTTPD.pm
+++ b/lib/PublicInbox/HTTPD.pm
@@ -47,6 +47,7 @@ sub env_for ($$$) {
                 # detect when to use async paths for slow blobs
                 'pi-httpd.async' => \&pi_httpd_async,
                 'pi-httpd.app' => $self->{app},
+                'pi-httpd.warn_cb' => $self->{warn_cb},
         }
 }
 
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index 605c5e51..2be1b763 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -1186,7 +1186,7 @@ sub out ($$;@) {
 # callback used by PublicInbox::DS for any (e)poll (in/out/hup/err)
 sub event_step {
         my ($self) = @_;
-
+        local $SIG{__WARN__} = $self->{imapd}->{warn_cb};
         return unless $self->flush_write && $self->{sock} && !$self->{long_cb};
 
         # only read more requests if we've drained the write buffer,
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 524784cb..ef01f448 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -958,7 +958,7 @@ sub out ($$;@) {
 # callback used by PublicInbox::DS for any (e)poll (in/out/hup/err)
 sub event_step {
         my ($self) = @_;
-
+        local $SIG{__WARN__} = $self->{nntpd}->{warn_cb};
         return unless $self->flush_write && $self->{sock} && !$self->{long_cb};
 
         # only read more requests if we've drained the write buffer,
diff --git a/lib/PublicInbox/POP3.pm b/lib/PublicInbox/POP3.pm
index 7469922b..53fb2e05 100644
--- a/lib/PublicInbox/POP3.pm
+++ b/lib/PublicInbox/POP3.pm
@@ -351,6 +351,7 @@ sub process_line ($$) {
 # callback used by PublicInbox::DS for any (e)poll (in/out/hup/err)
 sub event_step {
         my ($self) = @_;
+        local $SIG{__WARN__} = $self->{pop3d}->{warn_cb};
         return unless $self->flush_write && $self->{sock} && !$self->{long_cb};
 
         # only read more requests if we've drained the write buffer,