]> Sergey Matveev's repositories - public-inbox.git/commitdiff
daemon: drop listener sockets ASAP on termination
authorEric Wong <e@80x24.org>
Sat, 5 Mar 2016 05:44:16 +0000 (05:44 +0000)
committerEric Wong <e@80x24.org>
Sat, 5 Mar 2016 05:44:16 +0000 (05:44 +0000)
We do not want to be accepting connections during graceful
shutdown because another new process is likely taking over.
This also allows us to free up the listener case another
(independent) process wants to claim it.

lib/PublicInbox/Daemon.pm

index f0be034c57ef8054f65ac5bf374b61c71d599b4a..c3199cd24f0a9859261408fe479edf535b916544 100644 (file)
@@ -137,6 +137,7 @@ sub worker_quit () {
        # killing again terminates immediately:
        exit unless @listeners;
 
+       $_->close foreach @listeners; # call Danga::Socket::close
        @listeners = ();
 
        # give slow clients 30s to finish reading/writing whatever
@@ -401,7 +402,9 @@ sub daemon_loop ($$) {
        $SIG{USR1} = *reopen_logs;
        $SIG{HUP} = $refresh;
        # this calls epoll_create:
-       PublicInbox::Listener->new($_, $post_accept) for @listeners;
+       @listeners = map {
+               PublicInbox::Listener->new($_, $post_accept)
+       } @listeners;
        Danga::Socket->EventLoop;
        $parent_pipe = undef;
 }