]> Sergey Matveev's repositories - public-inbox.git/commitdiff
nntpd: hard quit after 30s
authorEric Wong <e@80x24.org>
Thu, 24 Sep 2015 03:37:17 +0000 (03:37 +0000)
committerEric Wong <e@80x24.org>
Thu, 24 Sep 2015 06:58:30 +0000 (06:58 +0000)
We don't want clients hogging server resources and preventing
us from shutting down, so give them 30s to finish whatever
request they're getting.

public-inbox-nntpd

index defb16b15b6493304d9effbec100c64399bfa052..4c1560803e221c279be82a4de40637a6ee06393c 100644 (file)
@@ -195,10 +195,14 @@ sub worker_quit {
        $_->close for @listeners;
        @listeners = ();
 
+       # give slow clients 30s to finish reading/writing whatever
+       Danga::Socket->AddTimer(30, sub { exit });
+
        # drop idle connections and try to quit gracefully
        Danga::Socket->SetPostLoopCallback(sub {
                my ($dmap, undef) = @_;
                my $n = 0;
+
                foreach my $s (values %$dmap) {
                        next unless ref($s) eq 'PublicInbox::NNTP';
                        if ($s->{write_buf_size} || $s->{rbuf}) {