* [PATCH v2] daemon: quiet Email::Address::XS warnings properly
2024-02-02 9:24 6% [PATCH] daemon: quiet Email::Address::XS warnings properly Eric Wong
@ 2024-02-07 22:49 7% ` Eric Wong
0 siblings, 0 replies; 5+ results
From: Eric Wong @ 2024-02-07 22:49 UTC (permalink / raw)
To: meta
Eric Wong <e@80x24.org> wrote:
> index a2c1ed6e..7aee5c72 100644
> --- a/lib/PublicInbox/Daemon.pm
> +++ b/lib/PublicInbox/Daemon.pm
> @@ -698,7 +701,6 @@ sub run {
> # localize GCF2C for tests:
> local $PublicInbox::GitAsyncCat::GCF2C;
> local $PublicInbox::Git::async_warn = 1;
> - local $SIG{__WARN__} = PublicInbox::Eml::warn_ignore_cb();
> local %WORKER_SIG = %WORKER_SIG;
> local %POST_ACCEPT;
That 2nd hunk is still necessary due to ->event_step callbacks
from asynchronous git blob retrievals. It wasn't 100% correct,
since it can put warnings in the wrong file, though...
--------8<-------
Subject: [PATCH] daemon: quiet Email::Address::XS warnings properly
Setting $SIG{__WARN__} at the top-level no longer has any effect
since we localize $SIG{__WARN__} when entering ->event_step on
a per-listener basis.
Fixes: 60d262483a4d (daemon: use per-listener SIG{__WARN__} callbacks, 2022-08-08)
---
lib/PublicInbox/Daemon.pm | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index a2c1ed6e..e578f2e8 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -143,8 +143,11 @@ sub load_mod ($;$$) {
$tlsd->{$f} = $logs{$p} //= open_log_path(my $fh, $p);
warn "# $scheme://$addr $f=$p\n";
}
+ # for per-listener $SIG{__WARN__}:
my $err = $tlsd->{err};
- $tlsd->{warn_cb} = sub { print $err @_ }; # for local $SIG{__WARN__}
+ $tlsd->{warn_cb} = sub {
+ print $err @_ unless PublicInbox::Eml::warn_ignore(@_)
+ };
$opt->{'multi-accept'} and
$xn{'multi-accept'} = $opt->{'multi-accept'}->[-1];
\%xn;
^ permalink raw reply related [relevance 7%]
* [PATCH] daemon: quiet Email::Address::XS warnings properly
@ 2024-02-02 9:24 6% Eric Wong
2024-02-07 22:49 7% ` [PATCH v2] " Eric Wong
0 siblings, 1 reply; 5+ results
From: Eric Wong @ 2024-02-02 9:24 UTC (permalink / raw)
To: meta
Setting $SIG{__WARN__} at the top-level no longer has any effect
since we localize $SIG{__WARN__} when entering ->event_step on
a per-listener basis.
Fixes: 60d262483a4d (daemon: use per-listener SIG{__WARN__} callbacks, 2022-08-08)
---
lib/PublicInbox/Daemon.pm | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index a2c1ed6e..7aee5c72 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -143,8 +143,11 @@ sub load_mod ($;$$) {
$tlsd->{$f} = $logs{$p} //= open_log_path(my $fh, $p);
warn "# $scheme://$addr $f=$p\n";
}
+ # for per-listener $SIG{__WARN__}:
my $err = $tlsd->{err};
- $tlsd->{warn_cb} = sub { print $err @_ }; # for local $SIG{__WARN__}
+ $tlsd->{warn_cb} = sub {
+ print $err @_ unless PublicInbox::Eml::warn_ignore(@_)
+ };
$opt->{'multi-accept'} and
$xn{'multi-accept'} = $opt->{'multi-accept'}->[-1];
\%xn;
@@ -698,7 +701,6 @@ sub run {
# localize GCF2C for tests:
local $PublicInbox::GitAsyncCat::GCF2C;
local $PublicInbox::Git::async_warn = 1;
- local $SIG{__WARN__} = PublicInbox::Eml::warn_ignore_cb();
local %WORKER_SIG = %WORKER_SIG;
local %POST_ACCEPT;
^ permalink raw reply related [relevance 6%]
* [PATCH] daemon: rely on $SIG{__WARN__} for error output
@ 2022-08-10 15:58 4% Eric Wong
0 siblings, 0 replies; 5+ results
From: Eric Wong @ 2022-08-10 15:58 UTC (permalink / raw)
To: meta
warn/carp usage is unavoidable given Perl itself and standard
libraries, so just rely on localized $SIG{__WARN__} from
60d262483a4d6ddf (daemon: use per-listener SIG{__WARN__} callbacks, 2022-08-08)
for all error reporting.
While we're in the area, make some of the error handling more
consistent between IMAP/NNTP/POP3.
---
lib/PublicInbox/DS.pm | 4 ++--
lib/PublicInbox/DSdeflate.pm | 2 +-
lib/PublicInbox/IMAP.pm | 12 +++---------
lib/PublicInbox/NNTP.pm | 10 ++--------
lib/PublicInbox/POP3.pm | 9 ++-------
5 files changed, 10 insertions(+), 27 deletions(-)
diff --git a/lib/PublicInbox/DS.pm b/lib/PublicInbox/DS.pm
index 5e8a6a66..26840662 100644
--- a/lib/PublicInbox/DS.pm
+++ b/lib/PublicInbox/DS.pm
@@ -660,8 +660,8 @@ sub long_step {
if ($@ || !$self->{sock}) { # something bad happened...
delete $self->{long_cb};
my $elapsed = now() - $t0;
- $@ and $self->err("%s during long response[$fd] - %0.6f",
- $@, $elapsed);
+ $@ and warn("$@ during long response[$fd] - ",
+ sprintf('%0.6f', $elapsed),"\n");
$self->out(" deferred[$fd] aborted - %0.6f", $elapsed);
$self->close;
} elsif ($more) { # $self->{wbuf}:
diff --git a/lib/PublicInbox/DSdeflate.pm b/lib/PublicInbox/DSdeflate.pm
index 639690e2..539adf0f 100644
--- a/lib/PublicInbox/DSdeflate.pm
+++ b/lib/PublicInbox/DSdeflate.pm
@@ -46,7 +46,7 @@ sub enable {
my ($class, $self) = @_;
my ($in, $err) = Compress::Raw::Zlib::Inflate->new(%IN_OPT);
if ($err != Z_OK) {
- $self->err("Inflate->new failed: $err");
+ warn("Inflate->new failed: $err\n");
return;
}
bless $self, $class;
diff --git a/lib/PublicInbox/IMAP.pm b/lib/PublicInbox/IMAP.pm
index 2be1b763..0a65d87c 100644
--- a/lib/PublicInbox/IMAP.pm
+++ b/lib/PublicInbox/IMAP.pm
@@ -1165,17 +1165,11 @@ sub process_line ($$) {
my $err = $@;
if ($err && $self->{sock}) {
$l =~ s/\r?\n//s;
- err($self, 'error from: %s (%s)', $l, $err);
+ warn("error from: $l ($err)\n");
$tag //= '*';
- $res = "$tag BAD program fault - command not performed\r\n";
+ $res = \"$tag BAD program fault - command not performed\r\n";
}
- return 0 unless defined $res;
- $self->write($res);
-}
-
-sub err ($$;@) {
- my ($self, $fmt, @args) = @_;
- printf { $self->{imapd}->{err} } $fmt."\n", @args;
+ defined($res) ? $self->write($res) : 0;
}
sub out ($$;@) {
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index ef01f448..ceaf05f6 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -72,9 +72,8 @@ sub process_line ($$) {
my $res = eval { $req->($self, @args) };
my $err = $@;
if ($err && $self->{sock}) {
- local $/ = "\n";
- chomp($l);
- err($self, 'error from: %s (%s)', $l, $err);
+ $l =~ s/\r?\n//s;
+ warn("error from: $l ($err)\n");
$res = \"503 program fault - command not performed\r\n";
}
defined($res) ? $self->write($res) : 0;
@@ -945,11 +944,6 @@ sub cmd_xpath ($$) {
'223 '.join(' ', sort(@paths))."\r\n";
}
-sub err ($$;@) {
- my ($self, $fmt, @args) = @_;
- printf { $self->{nntpd}->{err} } $fmt."\n", @args;
-}
-
sub out ($$;@) {
my ($self, $fmt, @args) = @_;
printf { $self->{nntpd}->{out} } $fmt."\n", @args;
diff --git a/lib/PublicInbox/POP3.pm b/lib/PublicInbox/POP3.pm
index c993e558..82df257c 100644
--- a/lib/PublicInbox/POP3.pm
+++ b/lib/PublicInbox/POP3.pm
@@ -45,11 +45,6 @@ use constant {
# XXX FIXME: duplicated stuff from NNTP.pm and IMAP.pm
-sub err ($$;@) {
- my ($self, $fmt, @args) = @_;
- printf { $self->{pop3d}->{err} } $fmt."\n", @args;
-}
-
sub out ($$;@) {
my ($self, $fmt, @args) = @_;
printf { $self->{pop3d}->{out} } $fmt."\n", @args;
@@ -364,8 +359,8 @@ sub process_line ($$) {
\"-ERR command not recognized\r\n";
my $err = $@;
if ($err && $self->{sock}) {
- chomp($l);
- err($self, 'error from: %s (%s)', $l, $err);
+ $l =~ s/\r?\n//s;
+ warn("error from: $l ($err)\n");
$res = \"-ERR program fault - command not performed\r\n";
}
defined($res) ? $self->write($res) : 0;
^ permalink raw reply related [relevance 4%]
* [PATCH 0/5] daemon/netd-related improvements
@ 2022-08-08 23:53 5% Eric Wong
2022-08-08 23:53 5% ` [PATCH 2/5] daemon: use per-listener SIG{__WARN__} callbacks Eric Wong
0 siblings, 1 reply; 5+ results
From: Eric Wong @ 2022-08-08 23:53 UTC (permalink / raw)
To: meta
A few minor quality-of-life improvements I've noticed while
running -netd on public-inbox.org
Eric Wong (5):
daemon: use default address + well-known ports for scheme
daemon: use per-listener SIG{__WARN__} callbacks
daemon: cleanup internal data structures
imap: mailboxes list across listeners
imapd|nntpd: drop ->base_url preload
lib/PublicInbox/Daemon.pm | 103 +++++++++++++++++++-------------------
lib/PublicInbox/HTTP.pm | 2 +-
lib/PublicInbox/HTTPD.pm | 1 +
lib/PublicInbox/IMAP.pm | 2 +-
lib/PublicInbox/IMAPD.pm | 50 +++++++++---------
lib/PublicInbox/NNTP.pm | 2 +-
lib/PublicInbox/NNTPD.pm | 1 -
lib/PublicInbox/POP3.pm | 1 +
8 files changed, 84 insertions(+), 78 deletions(-)
^ permalink raw reply [relevance 5%]
* [PATCH 2/5] daemon: use per-listener SIG{__WARN__} callbacks
2022-08-08 23:53 5% [PATCH 0/5] daemon/netd-related improvements Eric Wong
@ 2022-08-08 23:53 5% ` Eric Wong
0 siblings, 0 replies; 5+ results
From: Eric Wong @ 2022-08-08 23:53 UTC (permalink / raw)
To: meta
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.
---
lib/PublicInbox/Daemon.pm | 2 ++
lib/PublicInbox/HTTP.pm | 2 +-
lib/PublicInbox/HTTPD.pm | 1 +
lib/PublicInbox/IMAP.pm | 2 +-
lib/PublicInbox/NNTP.pm | 2 +-
lib/PublicInbox/POP3.pm | 1 +
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,
^ permalink raw reply related [relevance 5%]
Results 1-5 of 5 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2022-08-08 23:53 5% [PATCH 0/5] daemon/netd-related improvements Eric Wong
2022-08-08 23:53 5% ` [PATCH 2/5] daemon: use per-listener SIG{__WARN__} callbacks Eric Wong
2022-08-10 15:58 4% [PATCH] daemon: rely on $SIG{__WARN__} for error output Eric Wong
2024-02-02 9:24 6% [PATCH] daemon: quiet Email::Address::XS warnings properly Eric Wong
2024-02-07 22:49 7% ` [PATCH v2] " 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).