about summary refs log tree commit homepage
path: root/lib/PublicInbox/NNTP.pm
diff options
context:
space:
mode:
authorEric Wong <e@80x24.org>2019-06-24 02:52:42 +0000
committerEric Wong <e@80x24.org>2019-06-24 05:26:27 +0000
commit595854982a59f369ab605794f05c046c86253468 (patch)
treea09a07b6178fc16a80af8591f352ff9bd72bdce0 /lib/PublicInbox/NNTP.pm
parentb3e4b3b3c67b9df7868518978e721417b0aa7c9c (diff)
downloadpublic-inbox-595854982a59f369ab605794f05c046c86253468.tar.gz
This is in accordance with TLS standards and will be needed
to support session caching/reuse in the future.  However, we
don't issue shutdown(2) since we know not to inadvertantly
share our sockets with other processes.
Diffstat (limited to 'lib/PublicInbox/NNTP.pm')
-rw-r--r--lib/PublicInbox/NNTP.pm12
1 files changed, 9 insertions, 3 deletions
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 8840adbb..53de2bca 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -74,11 +74,17 @@ sub expire_old () {
         my $exp = $EXPTIME;
         my $old = $now - $exp;
         my $nr = 0;
+        my $closed = 0;
         my %new;
         while (my ($fd, $v) = each %$EXPMAP) {
                 my ($idle_time, $nntp) = @$v;
                 if ($idle_time < $old) {
-                        $nntp->close; # idempotent
+                        if ($nntp->shutdn) {
+                                $closed++;
+                        } else {
+                                ++$nr;
+                                $new{$fd} = $v;
+                        }
                 } else {
                         ++$nr;
                         $new{$fd} = $v;
@@ -91,7 +97,7 @@ sub expire_old () {
                 $expt = undef;
                 # noop to kick outselves out of the loop ASAP so descriptors
                 # really get closed
-                PublicInbox::EvCleanup::asap(sub {});
+                PublicInbox::EvCleanup::asap(sub {}) if $closed;
         }
 }
 
@@ -410,7 +416,7 @@ sub cmd_post ($) {
 sub cmd_quit ($) {
         my ($self) = @_;
         res($self, '205 closing connection - goodbye!');
-        $self->close;
+        $self->shutdn;
         undef;
 }