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 1/3] default to CORE::warn in $SIG{__WARN__} handlers
  2020-12-26  1:44  6% ` [PATCH 0/3] extindex --watch support Eric Wong
@ 2020-12-26  1:44  7%   ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2020-12-26  1:44 UTC (permalink / raw)
  To: meta

As with CORE::die and $SIG{__DIE__}, it turns out CORE::warn is
safe to use inside $SIG{__WARN__} handlers without triggering
infinite recursion.  So fall back to reusing CORE::warn instead
of creating a new sub.
---
 lib/PublicInbox/Admin.pm         | 2 +-
 lib/PublicInbox/ExtSearchIdx.pm  | 2 +-
 lib/PublicInbox/InboxWritable.pm | 2 +-
 lib/PublicInbox/Watch.pm         | 6 +++---
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/lib/PublicInbox/Admin.pm b/lib/PublicInbox/Admin.pm
index b468108e..d414e4e2 100644
--- a/lib/PublicInbox/Admin.pm
+++ b/lib/PublicInbox/Admin.pm
@@ -241,7 +241,7 @@ sub index_inbox {
 	}
 	local %SIG = %SIG;
 	setup_signals(\&index_terminate, $ibx);
-	my $warn_cb = $SIG{__WARN__} // sub { print STDERR @_ };
+	my $warn_cb = $SIG{__WARN__} // \&CORE::warn;
 	my $idx = { current_info => $ibx->{inboxdir} };
 	my $warn_ignore = PublicInbox::InboxWritable->can('warn_ignore');
 	local $SIG{__WARN__} = sub {
diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm
index e7fdae48..64ebf6db 100644
--- a/lib/PublicInbox/ExtSearchIdx.pm
+++ b/lib/PublicInbox/ExtSearchIdx.pm
@@ -841,7 +841,7 @@ sub eidx_reindex {
 sub eidx_sync { # main entry point
 	my ($self, $opt) = @_;
 
-	my $warn_cb = $SIG{__WARN__} || sub { print STDERR @_ };
+	my $warn_cb = $SIG{__WARN__} || \&CORE::warn;
 	local $self->{current_info} = '';
 	local $SIG{__WARN__} = sub {
 		$warn_cb->($self->{current_info}, ': ', @_);
diff --git a/lib/PublicInbox/InboxWritable.pm b/lib/PublicInbox/InboxWritable.pm
index 31eb3f15..b1d5caf5 100644
--- a/lib/PublicInbox/InboxWritable.pm
+++ b/lib/PublicInbox/InboxWritable.pm
@@ -292,7 +292,7 @@ sub warn_ignore {
 
 # this expects to be RHS in this assignment: "local $SIG{__WARN__} = ..."
 sub warn_ignore_cb {
-	my $cb = $SIG{__WARN__} // sub { print STDERR @_ };
+	my $cb = $SIG{__WARN__} // \&CORE::warn;
 	sub {
 		return if warn_ignore(@_);
 		$cb->(@_);
diff --git a/lib/PublicInbox/Watch.pm b/lib/PublicInbox/Watch.pm
index e1246096..bc296e01 100644
--- a/lib/PublicInbox/Watch.pm
+++ b/lib/PublicInbox/Watch.pm
@@ -217,7 +217,7 @@ sub _try_path {
 		warn "unmappable dir: $1\n";
 		return;
 	}
-	my $warn_cb = $SIG{__WARN__} || sub { print STDERR @_ };
+	my $warn_cb = $SIG{__WARN__} || \&CORE::warn;
 	local $SIG{__WARN__} = sub {
 		my $pfx = ($_[0] // '') =~ /^([A-Z]: )/g ? $1 : '';
 		$warn_cb->($pfx, "path: $path\n", @_);
@@ -467,7 +467,7 @@ sub imap_fetch_all ($$$) {
 	my $key = $req;
 	$key =~ s/\.PEEK//;
 	my ($uids, $batch);
-	my $warn_cb = $SIG{__WARN__} || sub { print STDERR @_ };
+	my $warn_cb = $SIG{__WARN__} || \&CORE::warn;
 	local $SIG{__WARN__} = sub {
 		my $pfx = ($_[0] // '') =~ /^([A-Z]: )/g ? $1 : '';
 		$batch //= '?';
@@ -929,7 +929,7 @@ sub nntp_fetch_all ($$$) {
 	$beg = $l_art + 1;
 
 	warn "I: $url fetching ARTICLE $beg..$end\n";
-	my $warn_cb = $SIG{__WARN__} || sub { print STDERR @_ };
+	my $warn_cb = $SIG{__WARN__} || \&CORE::warn;
 	my ($err, $art);
 	local $SIG{__WARN__} = sub {
 		my $pfx = ($_[0] // '') =~ /^([A-Z]: )/g ? $1 : '';

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/3] extindex --watch support
  @ 2020-12-26  1:44  6% ` Eric Wong
  2020-12-26  1:44  7%   ` [PATCH 1/3] default to CORE::warn in $SIG{__WARN__} handlers Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2020-12-26  1:44 UTC (permalink / raw)
  To: meta

"public-inbox-extindex --watch --all" is nice, and now maybe
public-inbox-watch or -mda won't /need/ updating to support
extindex.

1/3 is me still learning Perl, brown paper bag on 3/3

Eric Wong (3):
  default to CORE::warn in $SIG{__WARN__} handlers
  extindex: --watch for inotify-based updates
  init: use the return value of rel2abs_collapsed

 lib/PublicInbox/Admin.pm         |   2 +-
 lib/PublicInbox/ExtSearchIdx.pm  | 128 ++++++++++++++++++++++++++++---
 lib/PublicInbox/InboxIdle.pm     |   8 +-
 lib/PublicInbox/InboxWritable.pm |   2 +-
 lib/PublicInbox/OverIdx.pm       |   8 +-
 lib/PublicInbox/V2Writable.pm    |   2 +-
 lib/PublicInbox/Watch.pm         |   6 +-
 script/public-inbox-extindex     |  19 ++++-
 script/public-inbox-init         |   2 +-
 9 files changed, 153 insertions(+), 24 deletions(-)

^ permalink raw reply	[relevance 6%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2020-12-25 10:39     [PATCH 0/7] index + extindex interaction improvements Eric Wong
2020-12-26  1:44  6% ` [PATCH 0/3] extindex --watch support Eric Wong
2020-12-26  1:44  7%   ` [PATCH 1/3] default to CORE::warn in $SIG{__WARN__} handlers 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).