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 0/7] lei bugfixes and other fixes
@ 2021-09-22  2:24  7% Eric Wong
  2021-09-22  2:24  5% ` [PATCH 2/7] treewide: fix %SIG localization, harder Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-09-22  2:24 UTC (permalink / raw)
  To: meta

How did I forget 2/7 for all these months? :<

6/7 took a while for me to figure out, I only noticed it
because of background processes running after MUA exit
(from "lei up --mua=... MFOLDER"), but I got 4/7 and 7/7
fixes out of it.

Eric Wong (7):
  ipc: do not add "0" to $0 of solo workers
  treewide: fix %SIG localization, harder
  script/lei: describe purpose of sleep loop
  lei: dclose: do not close unnecessarily
  inbox: do not waste hash slot on httpbackend_limiter
  lei up: avoid excessively parallel --all
  lei: drop redundant WQ EOF callbacks

 lib/PublicInbox/Admin.pm        |  2 +-
 lib/PublicInbox/ExtSearchIdx.pm |  4 +-
 lib/PublicInbox/IPC.pm          |  7 +--
 lib/PublicInbox/Inbox.pm        | 10 ++--
 lib/PublicInbox/LEI.pm          |  3 +-
 lib/PublicInbox/LeiImportKw.pm  |  8 +--
 lib/PublicInbox/LeiMirror.pm    | 10 +---
 lib/PublicInbox/LeiNoteEvent.pm |  8 +--
 lib/PublicInbox/LeiPmdir.pm     |  8 +--
 lib/PublicInbox/LeiUp.pm        | 86 +++++++++++++++++++++------------
 lib/PublicInbox/TestCommon.pm   |  3 +-
 lib/PublicInbox/Watch.pm        |  4 +-
 lib/PublicInbox/Xapcmd.pm       |  8 +--
 script/lei                      |  2 +-
 script/public-inbox-clone       |  2 +-
 t/run.perl                      |  1 +
 16 files changed, 86 insertions(+), 80 deletions(-)

^ permalink raw reply	[relevance 7%]

* [PATCH 2/7] treewide: fix %SIG localization, harder
  2021-09-22  2:24  7% [PATCH 0/7] lei bugfixes and other fixes Eric Wong
@ 2021-09-22  2:24  5% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-09-22  2:24 UTC (permalink / raw)
  To: meta

This fixes the occasional t/lei-sigpipe.t infinite loop
under "make check-run".

Link: http://nntp.perl.org/group/perl.perl5.porters/258784
  <CAHhgV8hPbcmkzWizp6Vijw921M5BOXixj4+zTh3nRS9vRBYk8w@mail.gmail.com>
Followup-to: b552bb9150775fe4 ("daemon+watch: fix localization of %SIG for non-signalfd users")
---
 lib/PublicInbox/Admin.pm        | 2 +-
 lib/PublicInbox/ExtSearchIdx.pm | 4 ++--
 lib/PublicInbox/IPC.pm          | 4 ++--
 lib/PublicInbox/TestCommon.pm   | 3 ++-
 lib/PublicInbox/Watch.pm        | 4 +++-
 lib/PublicInbox/Xapcmd.pm       | 8 ++++----
 t/run.perl                      | 1 +
 7 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/lib/PublicInbox/Admin.pm b/lib/PublicInbox/Admin.pm
index 9ff59bca..20964f9c 100644
--- a/lib/PublicInbox/Admin.pm
+++ b/lib/PublicInbox/Admin.pm
@@ -274,7 +274,7 @@ sub index_inbox {
 	if (my $pr = $opt->{-progress}) {
 		$pr->("indexing $ibx->{inboxdir} ...\n");
 	}
-	local %SIG = %SIG;
+	local @SIG{keys %SIG} = values %SIG;
 	setup_signals(\&index_terminate, $ibx);
 	my $idx = { current_info => $ibx->{inboxdir} };
 	local $SIG{__WARN__} = sub {
diff --git a/lib/PublicInbox/ExtSearchIdx.pm b/lib/PublicInbox/ExtSearchIdx.pm
index e0ba6c32..6b29789a 100644
--- a/lib/PublicInbox/ExtSearchIdx.pm
+++ b/lib/PublicInbox/ExtSearchIdx.pm
@@ -1272,7 +1272,7 @@ sub event_step { # PublicInbox::DS::requeue callback
 
 sub eidx_watch { # public-inbox-extindex --watch main loop
 	my ($self, $opt) = @_;
-	local %SIG = %SIG;
+	local @SIG{keys %SIG} = values %SIG;
 	for my $sig (qw(HUP USR1 TSTP QUIT INT TERM)) {
 		$SIG{$sig} = sub { warn "SIG$sig ignored while scanning\n" };
 	}
@@ -1307,7 +1307,7 @@ sub eidx_watch { # public-inbox-extindex --watch main loop
 	$sig->{QUIT} = $sig->{INT} = $sig->{TERM} = $quit;
 	my $sigfd = PublicInbox::Sigfd->new($sig,
 					$PublicInbox::Syscall::SFD_NONBLOCK);
-	%SIG = (%SIG, %$sig) if !$sigfd;
+	@SIG{keys %$sig} = values(%$sig) if !$sigfd;
 	local $self->{-watch_sync} = $sync; # for ->on_inbox_unlock
 	if (!$sigfd) {
 		# wake up every second to accept signals if we don't
diff --git a/lib/PublicInbox/IPC.pm b/lib/PublicInbox/IPC.pm
index 1c699d76..3e29def8 100644
--- a/lib/PublicInbox/IPC.pm
+++ b/lib/PublicInbox/IPC.pm
@@ -115,7 +115,7 @@ sub ipc_worker_spawn {
 			$fields //= {};
 			local @$self{keys %$fields} = values(%$fields);
 			my $on_destroy = $self->ipc_atfork_child;
-			local %SIG = %SIG;
+			local @SIG{keys %SIG} = values %SIG;
 			PublicInbox::DS::sig_setmask($sigset);
 			ipc_worker_loop($self, $r_req, $w_res);
 		};
@@ -361,7 +361,7 @@ sub _wq_worker_start ($$$$) {
 			$fields //= {};
 			local @$self{keys %$fields} = values(%$fields);
 			my $on_destroy = $self->ipc_atfork_child;
-			local %SIG = %SIG;
+			local @SIG{keys %SIG} = values %SIG;
 			PublicInbox::DS::sig_setmask($oldset);
 			wq_worker_loop($self, $bcast2);
 		};
diff --git a/lib/PublicInbox/TestCommon.pm b/lib/PublicInbox/TestCommon.pm
index 9e152394..92a7db36 100644
--- a/lib/PublicInbox/TestCommon.pm
+++ b/lib/PublicInbox/TestCommon.pm
@@ -317,7 +317,8 @@ sub run_script ($;$$) {
 		# note: "local *STDIN = *STDIN;" and so forth did not work in
 		# old versions of perl
 		local %ENV = $env ? (%ENV, %$env) : %ENV;
-		local %SIG = %SIG;
+		local @SIG{keys %SIG} = map { undef } values %SIG;
+		local $SIG{FPE} = 'IGNORE'; # Perl default
 		local $0 = join(' ', @$cmd);
 		my $orig_io = _prepare_redirects($fhref);
 		my $cwdfh = $lei_cwdfh;
diff --git a/lib/PublicInbox/Watch.pm b/lib/PublicInbox/Watch.pm
index 387eb6d2..0523ad03 100644
--- a/lib/PublicInbox/Watch.pm
+++ b/lib/PublicInbox/Watch.pm
@@ -384,7 +384,9 @@ sub watch_atfork_child ($) {
 	delete $self->{poll_pids};
 	delete $self->{opendirs};
 	PublicInbox::DS->Reset;
-	%SIG = (%SIG, %{$self->{sig}}, CHLD => 'DEFAULT');
+	my $sig = delete $self->{sig};
+	$sig->{CHLD} = 'DEFAULT';
+	@SIG{keys %$sig} = values %$sig;
 	PublicInbox::DS::sig_setmask($self->{oldset});
 }
 
diff --git a/lib/PublicInbox/Xapcmd.pm b/lib/PublicInbox/Xapcmd.pm
index 588e7b94..b962fa84 100644
--- a/lib/PublicInbox/Xapcmd.pm
+++ b/lib/PublicInbox/Xapcmd.pm
@@ -149,7 +149,7 @@ sub process_queue {
 
 	# run in parallel:
 	my %pids;
-	local %SIG = %SIG;
+	local @SIG{keys %SIG} = values %SIG;
 	setup_signals(\&kill_pids, \%pids);
 	while (@$queue) {
 		while (scalar(keys(%pids)) < $max && scalar(@$queue)) {
@@ -285,7 +285,7 @@ sub run {
 		PublicInbox::SearchIdx::load_xapian_writable();
 	}
 
-	local %SIG = %SIG;
+	local @SIG{keys %SIG} = values %SIG;
 	setup_signals();
 	$ibx->with_umask(\&_run, $ibx, $cb, $opt);
 }
@@ -343,7 +343,7 @@ sub compact ($$) { # cb_spawn callback
 	$pr->("$pfx `".join(' ', @$cmd)."'\n") if $pr;
 	push @$cmd, $src, $dst;
 	my ($rd, $pid);
-	local %SIG = %SIG;
+	local @SIG{keys %SIG} = values %SIG;
 	setup_signals(\&kill_compact, \$pid);
 	($rd, $pid) = popen_rd($cmd, undef, $rdr);
 	while (<$rd>) {
@@ -428,7 +428,7 @@ sub cpdb ($$) { # cb_spawn callback
 	}
 
 	my ($tmp, $ft);
-	local %SIG = %SIG;
+	local @SIG{keys %SIG} = values %SIG;
 	if ($opt->{compact}) {
 		my ($dir) = ($new =~ m!(.*?/)[^/]+/*\z!);
 		same_fs_or_die($dir, $new);
diff --git a/t/run.perl b/t/run.perl
index e5ee0ade..0fe6d08b 100755
--- a/t/run.perl
+++ b/t/run.perl
@@ -168,6 +168,7 @@ my $start_worker = sub {
 	my $pid = fork // DIE "fork: $!";
 	if ($pid == 0) {
 		close $wr if $wr;
+		$SIG{USR1} = undef; # undo parent $SIG{USR1}
 		$worker = $$;
 		while (1) {
 			my $r = sysread($rd, my $buf, UINT_SIZE);

^ permalink raw reply related	[relevance 5%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-09-22  2:24  7% [PATCH 0/7] lei bugfixes and other fixes Eric Wong
2021-09-22  2:24  5% ` [PATCH 2/7] treewide: fix %SIG localization, harder 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).