]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/NNTP.pm
nntp: pass regexp to split() callers
[public-inbox.git] / lib / PublicInbox / NNTP.pm
index aa0193687dd6bc6cde4e2b9e620a4cd97699c048..3d304c52f521ece7fb5d7c84e7e8c3bbd95960ea 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright (C) 2015-2021 all contributors <meta@public-inbox.org>
+# Copyright (C) all contributors <meta@public-inbox.org>
 # License: AGPL-3.0+ <https://www.gnu.org/licenses/agpl-3.0.txt>
 #
 # Each instance of this represents a NNTP client socket
@@ -65,14 +65,13 @@ sub new ($$$) {
        } else {
                greet($self);
        }
-       $self->update_idle_time;
        $self;
 }
 
 sub args_ok ($$) {
        my ($cb, $argc) = @_;
        my $tot = prototype $cb;
-       my ($nreq, undef) = split(';', $tot);
+       my ($nreq, undef) = split(/;/, $tot);
        $nreq = ($nreq =~ tr/$//) - 1;
        $tot = ($tot =~ tr/$//) - 1;
        ($argc <= $tot && $argc >= $nreq);
@@ -350,7 +349,7 @@ sub cmd_newnews ($$$$;$$) {
        my $ts = eval { parse_time($date, $time, $gmt) };
        return r501 if $@;
        more($self, '230 list of new articles by message-id follows');
-       my ($keep, $skip) = split('!', $newsgroups, 2);
+       my ($keep, $skip) = split(/!/, $newsgroups, 2);
        ngpat2re($keep);
        ngpat2re($skip);
        my @names = grep(!/$skip/, grep(/$keep/,
@@ -651,8 +650,6 @@ sub long_step {
                out($self, " deferred[$fd] aborted - %0.6f", $elapsed);
                $self->close;
        } elsif ($more) { # $self->{wbuf}:
-               $self->update_idle_time;
-
                # COMPRESS users all share the same DEFLATE context.
                # Flush it here to ensure clients don't see
                # each other's data
@@ -1050,7 +1047,6 @@ sub event_step {
 
        return unless $self->flush_write && $self->{sock} && !$self->{long_cb};
 
-       $self->update_idle_time;
        # only read more requests if we've drained the write buffer,
        # otherwise we can be buffering infinitely w/o backpressure
 
@@ -1072,17 +1068,15 @@ sub event_step {
        out($self, "[$fd] %s - %0.6f$pending", $line, now() - $t0);
        return $self->close if $r < 0;
        $self->rbuf_idle($rbuf);
-       $self->update_idle_time;
 
        # maybe there's more pipelined data, or we'll have
        # to register it for socket-readiness notifications
        $self->requeue unless $pending;
 }
 
-# for graceful shutdown in PublicInbox::Daemon:
-sub busy {
-       my ($self, $now) = @_;
-       ($self->{rbuf} || $self->{wbuf} || $self->not_idle_long($now));
+sub busy { # for graceful shutdown in PublicInbox::Daemon:
+       my ($self) = @_;
+       defined($self->{rbuf}) || defined($self->{wbuf})
 }
 
 1;