-# Copyright (C) 2015 all contributors <meta@public-inbox.org>
-# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
+# Copyright (C) 2015-2018 all contributors <meta@public-inbox.org>
+# License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
# contains common daemon code for the nntpd and httpd servers.
# This may be used for read-only IMAP server if we decide to implement it.
package PublicInbox::Daemon;
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;
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
@listeners = map {
PublicInbox::Listener->new($_, $post_accept)
} @listeners;
+ PublicInbox::EvCleanup::enable();
Danga::Socket->EventLoop;
$parent_pipe = undef;
}