From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 43B671FA17 for ; Thu, 14 Jan 2021 07:06:28 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 04/14] lei: do not unlink socket path at exit Date: Wed, 13 Jan 2021 19:06:17 -1200 Message-Id: <20210114070627.18195-5-e@80x24.org> In-Reply-To: <20210114070627.18195-1-e@80x24.org> References: <20210114070627.18195-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This matches existing -httpd/-nntpd/-imapd daemon behavior. >From what I can recall, it is less racy for the process doing bind(2) to unlink it if stale. --- lib/PublicInbox/LEI.pm | 1 - t/lei.t | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/LEI.pm b/lib/PublicInbox/LEI.pm index 2889fa76..7a1df0bb 100644 --- a/lib/PublicInbox/LEI.pm +++ b/lib/PublicInbox/LEI.pm @@ -789,7 +789,6 @@ sub lazy_start { local $quit = sub { $exit_code //= shift; my $listener = $l or exit($exit_code); - unlink($path) if defined($path); # closing eof_w triggers \&noop wakeup $eof_w = $l = $path = undef; $listener->close; # DS::close diff --git a/t/lei.t b/t/lei.t index 3ebaade6..240735bf 100644 --- a/t/lei.t +++ b/t/lei.t @@ -237,13 +237,13 @@ SKIP: { # real socket kill(0, $pid) or last; tick(); } - ok(!-S $sock, 'sock gone'); + ok(-S $sock, 'sock still exists'); ok(!kill(0, $pid), 'pid gone after stop'); ok($lei->(qw(daemon-pid)), 'daemon-pid'); chomp(my $new_pid = $out); ok(kill(0, $new_pid), 'new pid is running'); - ok(-S $sock, 'sock exists again'); + ok(-S $sock, 'sock still exists'); for my $sig (qw(-0 -CHLD)) { ok($lei->('daemon-kill', $sig), "handles $sig");