]> Sergey Matveev's repositories - public-inbox.git/commitdiff
daemon: set $now time for NNTP shutdown
authorEric Wong <e@80x24.org>
Mon, 12 Dec 2016 12:14:02 +0000 (12:14 +0000)
committerEric Wong <e@80x24.org>
Mon, 12 Dec 2016 12:14:02 +0000 (12:14 +0000)
commit 6e238ee3396719e578d6a90e177a71ce9f8c1ca0
("nntp: respect 3 minute idle time for shutdown")
was incomplete, and needed this change to Daemon
to be effective.

In the future, there will be more common code between
NNTP.pm and HTTP.pm

lib/PublicInbox/Daemon.pm

index 795ab8222950e57d9df5727720f304a7977ae4e3..37aa41879929e9e7ae95206d9bc448830dfa785e 100644 (file)
@@ -9,6 +9,7 @@ use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
 use IO::Handle;
 use IO::Socket;
 use Cwd qw/abs_path/;
+use Time::HiRes qw(clock_gettime CLOCK_MONOTONIC);
 STDOUT->autoflush(1);
 STDERR->autoflush(1);
 require Danga::Socket;
@@ -181,10 +182,11 @@ sub worker_quit {
        Danga::Socket->SetPostLoopCallback(sub {
                my ($dmap, undef) = @_;
                my $n = 0;
+               my $now = clock_gettime(CLOCK_MONOTONIC);
 
                foreach my $s (values %$dmap) {
                        $s->can('busy') or next;
-                       if ($s->busy) {
+                       if ($s->busy($now)) {
                                ++$n;
                        } else {
                                # close as much as possible, early as possible