]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/Daemon.pm
imapd+nntpd: drop timer-based expiration
[public-inbox.git] / lib / PublicInbox / Daemon.pm
index 24dc7791b43de73eaa51e9984c1fc08c3dc92e2b..505235864c0b22166841eb4c3b54c72f3e0abc29 100644 (file)
@@ -6,8 +6,8 @@
 # and/or lossy connections.
 package PublicInbox::Daemon;
 use strict;
-use warnings;
-use Getopt::Long qw/:config gnu_getopt no_ignore_case auto_abbrev/;
+use v5.10.1;
+use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev);
 use IO::Handle; # ->autoflush
 use IO::Socket;
 use POSIX qw(WNOHANG :signal_h);
@@ -15,11 +15,12 @@ use Socket qw(IPPROTO_TCP SOL_SOCKET);
 STDOUT->autoflush(1);
 STDERR->autoflush(1);
 use PublicInbox::DS qw(now);
-use PublicInbox::Syscall qw(SFD_NONBLOCK);
-require PublicInbox::Listener;
+use PublicInbox::Listener;
 use PublicInbox::EOFpipe;
 use PublicInbox::Sigfd;
+use PublicInbox::Git;
 use PublicInbox::GitAsyncCat;
+use PublicInbox::Eml;
 our $SO_ACCEPTFILTER = 0x1000;
 my @CMD;
 my ($set_user, $oldset);
@@ -270,13 +271,11 @@ sub worker_quit { # $_[0] = signal name or number (unused)
                my ($dmap, undef) = @_;
                my $n = 0;
                my $now = now();
-
-               foreach my $s (values %$dmap) {
+               for my $s (values %$dmap) {
                        $s->can('busy') or next;
-                       if ($s->busy($now)) {
+                       if ($s->busy) {
                                ++$n;
-                       } else {
-                               # close as much as possible, early as possible
+                       } else { # close as much as possible, early as possible
                                $s->close;
                        }
                }
@@ -513,7 +512,7 @@ EOF
                },
                CHLD => \&reap_children,
        };
-       my $sigfd = PublicInbox::Sigfd->new($sig, 0);
+       my $sigfd = PublicInbox::Sigfd->new($sig);
        local @SIG{keys %$sig} = values(%$sig) unless $sigfd;
        PublicInbox::DS::sig_setmask($oldset) if !$sigfd;
        while (1) { # main loop
@@ -630,26 +629,19 @@ sub daemon_loop ($$$$) {
                # this calls epoll_create:
                PublicInbox::Listener->new($_, $tls_cb || $post_accept)
        } @listeners;
-       my $sigfd = PublicInbox::Sigfd->new($sig, SFD_NONBLOCK);
-       local @SIG{keys %$sig} = values(%$sig) unless $sigfd;
-       if (!$sigfd) {
-               # wake up every second to accept signals if we don't
-               # have signalfd or IO::KQueue:
-               PublicInbox::DS::sig_setmask($oldset);
-               PublicInbox::DS->SetLoopTimeout(1000);
-       }
-       PublicInbox::DS->EventLoop;
+       PublicInbox::DS::event_loop($sig, $oldset);
 }
 
 sub run ($$$;$) {
        my ($default, $refresh, $post_accept, $tlsd) = @_;
-       local $SIG{PIPE} = 'IGNORE';
        daemon_prepare($default);
        my $af_default = $default =~ /:8080\z/ ? 'httpready' : undef;
        my $for_destroy = daemonize();
 
        # localize GCF2C for tests:
        local $PublicInbox::GitAsyncCat::GCF2C;
+       local $PublicInbox::Git::async_warn = 1;
+       local $SIG{__WARN__} = PublicInbox::Eml::warn_ignore_cb();
 
        daemon_loop($refresh, $post_accept, $tlsd, $af_default);
        PublicInbox::DS->Reset;