]> Sergey Matveev's repositories - public-inbox.git/commitdiff
lei: do not unlink socket path at exit
authorEric Wong <e@80x24.org>
Thu, 14 Jan 2021 07:06:17 +0000 (19:06 -1200)
committerEric Wong <e@80x24.org>
Thu, 14 Jan 2021 23:14:08 +0000 (23:14 +0000)
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
t/lei.t

index 2889fa76f9cd2107e9a9f1e6282d0b0aa8ba6c61..7a1df0bbf742570d66de2c33ed1080a4df83982a 100644 (file)
@@ -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 3ebaade6d0b1e534db94b3113d56d0267fe7226f..240735bf7df8b72ff8c04b9e87165937d733c181 100644 (file)
--- 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");