From: Eric Wong <e@80x24.org>
Date: Fri, 28 Jun 2019 18:55:09 +0000 (+0000)
Subject: parentpipe: make the ->close call more obvious
X-Git-Tag: v1.2.0~143
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=945ef964037cbac81bf8fdea269037098da094f9;p=public-inbox.git

parentpipe: make the ->close call more obvious

We can close directly in event_step without bad side effects,
and then we also don't need to take a reason arg from worker_quit,
since we weren't logging it anywhere.
---

diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index cf011a20..2b7ac266 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -252,13 +252,11 @@ sub daemonize () {
 
 
 sub worker_quit {
-	my ($reason) = @_;
 	# killing again terminates immediately:
 	exit unless @listeners;
 
 	$_->close foreach @listeners; # call PublicInbox::DS::close
 	@listeners = ();
-	$reason->close if ref($reason) eq 'PublicInbox::ParentPipe';
 
 	my $proc_name;
 	my $warn = 0;
@@ -590,7 +588,7 @@ sub daemon_loop ($$$$) {
 	} else {
 		reopen_logs();
 		$set_user->() if $set_user;
-		$SIG{USR2} = sub { worker_quit('USR2') if upgrade() };
+		$SIG{USR2} = sub { worker_quit() if upgrade() };
 		$refresh->();
 	}
 	$uid = $gid = undef;
diff --git a/lib/PublicInbox/ParentPipe.pm b/lib/PublicInbox/ParentPipe.pm
index 6ef51c1a..2e2abb5f 100644
--- a/lib/PublicInbox/ParentPipe.pm
+++ b/lib/PublicInbox/ParentPipe.pm
@@ -19,6 +19,9 @@ sub new ($$$) {
 }
 
 # master process died, time to call worker_quit ourselves
-sub event_step { $_[0]->{cb}->($_[0]) }
+sub event_step {
+	$_[0]->close; # PublicInbox::DS::close
+	$_[0]->{cb}->();
+}
 
 1;