From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-2.9 required=3.0 tests=ALL_TRUSTED,AWL,BAYES_00, RP_MATCHES_RCVD shortcircuit=no autolearn=unavailable version=3.3.2 X-Original-To: meta@public-inbox.org Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id C6312633829 for ; Sat, 5 Mar 2016 06:07:44 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 3/4] daemon: avoid cyclic references for once-used callbacks Date: Sat, 5 Mar 2016 06:07:39 +0000 Message-Id: <20160305060740.13472-4-e@80x24.org> In-Reply-To: <20160305060740.13472-1-e@80x24.org> References: <20160305060740.13472-1-e@80x24.org> List-Id: 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 | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm index c3199cd..30411e1 100644 --- a/lib/PublicInbox/Daemon.pm +++ b/lib/PublicInbox/Daemon.pm @@ -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); }; } -- EW