]> Sergey Matveev's repositories - public-inbox.git/commitdiff
daemon: avoid cyclic references for once-used callbacks
authorEric Wong <e@80x24.org>
Sat, 5 Mar 2016 05:52:14 +0000 (05:52 +0000)
committerEric Wong <e@80x24.org>
Sat, 5 Mar 2016 05:53:16 +0000 (05:53 +0000)
Not that these subs are repeatedly created, but this makes
the code easier-to-review and these callbacks are idempotent
anyways.

lib/PublicInbox/Daemon.pm

index c3199cd24f0a9859261408fe479edf535b916544..30411e13d5977b71fed743e0f765fcba289ee5a9 100644 (file)
@@ -109,6 +109,7 @@ sub daemonize () {
        # The upgrade will create the ".oldbin" pid file in the
        # same directory as the given pid file.
        $uid and $set_user = sub {
+               $set_user = undef;
                Net::Server::Daemonize::set_user($uid, $gid);
        };
 
@@ -128,6 +129,7 @@ sub daemonize () {
                write_pid($pid_file);
                my $unlink_pid = $$;
                $cleanup = sub {
+                       $cleanup = undef; # avoid cyclic reference
                        unlink_pid_file_safe_ish($unlink_pid, $pid_file);
                };
        }