]> Sergey Matveev's repositories - public-inbox.git/blobdiff - lib/PublicInbox/NNTP.pm
nntp: listgroup_range_i: remove useless `map' op
[public-inbox.git] / lib / PublicInbox / NNTP.pm
index e4ca7d1462e292d1127f8f1abe02731b1c7d2afd..ab6eb525106d9046ca5f1f898787582210dba7b5 100644 (file)
@@ -29,7 +29,6 @@ use constant {
        r225 => "225 Headers follow (multi-line)\r\n",
        r430 => '430 No article with that message-id',
 };
-use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT);
 use Errno qw(EAGAIN);
 my $ONE_MSGID = qr/\A$MID_EXTRACT\z/;
 my @OVERVIEW = qw(Subject From Date Message-ID References);
@@ -47,25 +46,11 @@ HDR\r
 OVER\r
 COMPRESS DEFLATE\r
 
-sub greet ($) { $_[0]->write($_[0]->{nntpd}->{greet}) };
-
-sub new ($$$) {
-       my ($class, $sock, $nntpd) = @_;
-       my $self = bless { nntpd => $nntpd }, $class;
-       my $ev = EPOLLIN;
-       my $wbuf;
-       if ($sock->can('accept_SSL') && !$sock->accept_SSL) {
-               return CORE::close($sock) if $! != EAGAIN;
-               $ev = PublicInbox::TLS::epollbit() or return CORE::close($sock);
-               $wbuf = [ \&PublicInbox::DS::accept_tls_step, \&greet ];
-       }
-       $self->SUPER::new($sock, $ev | EPOLLONESHOT);
-       if ($wbuf) {
-               $self->{wbuf} = $wbuf;
-       } else {
-               greet($self);
-       }
-       $self;
+sub do_greet ($) { $_[0]->write($_[0]->{nntpd}->{greet}) };
+
+sub new {
+       my ($cls, $sock, $nntpd) = @_;
+       (bless { nntpd => $nntpd }, $cls)->greet($sock)
 }
 
 sub args_ok ($$) {
@@ -204,7 +189,7 @@ sub listgroup_range_i {
        my ($self, $beg, $end) = @_;
        my $r = $self->{ibx}->mm(1)->msg_range($beg, $end, 'num');
        scalar(@$r) or return;
-       $self->msg_more(join('', map { "$_->[0]\r\n" } @$r));
+       $self->msg_more(join("\r\n", @$r, ''));
        1;
 }
 
@@ -650,17 +635,8 @@ sub long_step {
                out($self, " deferred[$fd] aborted - %0.6f", $elapsed);
                $self->close;
        } elsif ($more) { # $self->{wbuf}:
-               # COMPRESS users all share the same DEFLATE context.
-               # Flush it here to ensure clients don't see
-               # each other's data
-               $self->zflush;
-
-               # no recursion, schedule another call ASAP, but only after
-               # all pending writes are done.  autovivify wbuf:
-               my $new_size = push(@{$self->{wbuf}}, \&long_step);
-
-               # wbuf may be populated by $cb, no need to rearm if so:
-               $self->requeue if $new_size == 1;
+               # control passed to ibx_async_cat if $more == \undef
+               $self->requeue_once if !ref($more);
        } else { # all done!
                delete $self->{long_cb};
                $self->write(\".\r\n");
@@ -983,8 +959,6 @@ sub cmd_compress ($$) {
        undef
 }
 
-sub zflush {} # overridden by NNTPdeflate
-
 sub cmd_xpath ($$) {
        my ($self, $mid) = @_;
        return r501 unless $mid =~ $ONE_MSGID;