From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 6A1451F4BC for ; Mon, 24 Jun 2019 02:56:51 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 36/57] nntp: wait for writability before sending greeting Date: Mon, 24 Jun 2019 02:52:37 +0000 Message-Id: <20190624025258.25592-37-e@80x24.org> In-Reply-To: <20190624025258.25592-1-e@80x24.org> References: <20190624025258.25592-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: This will be needed for NNTPS support, since we need to negotiate the TLS connection before writing the greeting and we can reuse the existing buffer layer to enqueue writes. --- lib/PublicInbox/NNTP.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm index 468a22f5..a18641d3 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -24,7 +24,7 @@ use constant { r225 => '225 Headers follow (multi-line)', r430 => '430 No article with that message-id', }; -use PublicInbox::Syscall qw(EPOLLIN EPOLLONESHOT); +use PublicInbox::Syscall qw(EPOLLOUT EPOLLONESHOT); use Errno qw(EAGAIN); my @OVERVIEW = qw(Subject From Date Message-ID References Xref); @@ -98,9 +98,11 @@ sub expire_old () { sub new ($$$) { my ($class, $sock, $nntpd) = @_; my $self = fields::new($class); - $self->SUPER::new($sock, EPOLLIN | EPOLLONESHOT); + $self->SUPER::new($sock, EPOLLOUT | EPOLLONESHOT); $self->{nntpd} = $nntpd; - res($self, '201 ' . $nntpd->{servername} . ' ready - post via email'); + my $greet = "201 $nntpd->{servername} ready - post via email\r\n"; + open my $fh, '<:scalar', \$greet or die "open :scalar: $!"; + $self->{wbuf} = [ $fh ]; $self->{rbuf} = ''; update_idle_time($self); $expt ||= PublicInbox::EvCleanup::later(*expire_old); -- EW