]> Sergey Matveev's repositories - public-inbox.git/commitdiff
daemon: unlink .oldbin PID file correctly
authorEric Wong <e@yhbt.net>
Sun, 22 Mar 2020 08:58:49 +0000 (08:58 +0000)
committerEric Wong <e@yhbt.net>
Tue, 24 Mar 2020 22:00:45 +0000 (22:00 +0000)
We need to track the PID file having ".oldbin" appended
to it while a SIGUSR2 upgrade is in progress and ensure
it is unlinked on SIGQUIT.

lib/PublicInbox/Daemon.pm
t/httpd-unix.t

index 3d582e355ed70d40f6b9689f791f5e08f0c81d67..4ff7cad493990d81c6ce4d2e896f63cfe7a87032 100644 (file)
@@ -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)
@@ -663,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;
index 02f5e4a9a7077515f40f6bd7558a0aaca06bf99f..a0fe1e31c97541c37b3ded69e0de68b4d8db9399 100644 (file)
@@ -163,6 +163,7 @@ SKIP: {
        # drop the old parent
        kill('QUIT', $old_pid) or die "QUIT failed: $!";
        delay_until(sub { !kill(0, $old_pid) });
+       ok(!-f "$pid_file.oldbin", '.oldbin PID file gone');
 
        # drop the new child
        check_sock($unix);