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 BA644633824 for ; Sat, 5 Mar 2016 06:07:44 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 2/4] daemon: drop listener sockets ASAP on termination Date: Sat, 5 Mar 2016 06:07:38 +0000 Message-Id: <20160305060740.13472-3-e@80x24.org> In-Reply-To: <20160305060740.13472-1-e@80x24.org> References: <20160305060740.13472-1-e@80x24.org> List-Id: 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 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/PublicInbox/Daemon.pm b/lib/PublicInbox/Daemon.pm index f0be034..c3199cd 100644 --- a/lib/PublicInbox/Daemon.pm +++ b/lib/PublicInbox/Daemon.pm @@ -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; } -- EW