X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FDaemon.pm;h=4ff7cad493990d81c6ce4d2e896f63cfe7a87032;hb=decbb9936a25dfedf6ecd916d8e0403f06217ec9;hp=15d8bd31438f37ee00b34105a29444c2beb8d4a1;hpb=9689c65f42c0acc9021953b29ce55730c4cd841d;p=public-inbox.git
diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm
index 15d8bd31..4ff7cad4 100644
--- a/lib/PublicInbox/Daemon.pm
+++ b/lib/PublicInbox/Daemon.pm
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2019 all contributors
+# Copyright (C) 2015-2020 all contributors
# License: AGPL-3.0+
# contains common daemon code for the nntpd and httpd servers.
# This may be used for read-only IMAP server if we decide to implement it.
@@ -247,7 +247,7 @@ sub daemonize () {
write_pid($pid_file);
# for ->DESTROY:
- bless { pid => $$, pid_file => $pid_file }, __PACKAGE__;
+ bless { pid => $$, pid_file => \$pid_file }, __PACKAGE__;
}
sub worker_quit { # $_[0] = signal name or number (unused)
@@ -403,6 +403,9 @@ sub upgrade { # $_[0] = signal name or number (unused)
$ENV{LISTEN_FDS} = scalar @listeners;
$ENV{LISTEN_PID} = $$;
foreach my $s (@listeners) {
+ # @listeners are globs with workers, PI::L w/o workers
+ $s = $s->{sock} if ref($s) eq 'PublicInbox::Listener';
+
my $fl = fcntl($s, F_GETFD, 0);
fcntl($s, F_SETFD, $fl &= ~FD_CLOEXEC);
}
@@ -602,11 +605,10 @@ sub daemon_loop ($$$$) {
WINCH => 'IGNORE',
CHLD => \&PublicInbox::DS::enqueue_reap,
};
- my $parent_pipe;
if ($worker_processes > 0) {
$refresh->(); # preload by default
my $fh = master_loop(); # returns if in child process
- $parent_pipe = PublicInbox::ParentPipe->new($fh, *worker_quit);
+ PublicInbox::ParentPipe->new($fh, \&worker_quit);
} else {
reopen_logs();
$set_user->() if $set_user;
@@ -661,7 +663,7 @@ sub write_pid ($) {
}
sub DESTROY {
- unlink_pid_file_safe_ish($_[0]->{pid}, $_[0]->{pid_file});
+ unlink_pid_file_safe_ish($_[0]->{pid}, ${$_[0]->{pid_file}});
}
1;