From 6e238ee3396719e578d6a90e177a71ce9f8c1ca0 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 2 Jul 2016 21:50:30 +0000 Subject: nntp: respect 3 minute idle time for shutdown This avoids breaking clients on graceful shutdown since NNTP responses should usually be quick. --- lib/PublicInbox/NNTP.pm | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'lib/PublicInbox') diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index b07e1845..56d08385 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -998,10 +998,19 @@ sub watch_read { $rv; } +sub not_idle_long ($$) { + my ($self, $now) = @_; + defined(my $fd = $self->{fd}) or return; + my $ary = $EXPMAP->{$fd} or return; + my $exp_at = $ary->[0] + $EXPTIME; + $exp_at > $now; +} + # for graceful shutdown in PublicInbox::Daemon: -sub busy () { - my ($self) = @_; - ($self->{rbuf} ne '' || $self->{long_res} || $self->{write_buf_size}); +sub busy { + my ($self, $now) = @_; + ($self->{rbuf} ne '' || $self->{long_res} || $self->{write_buf_size} || + not_idle_long($self, $now)); } 1; -- cgit v1.2.3-24-ge0c7