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:46 +0000
committerEric Wong <e@80x24.org>2019-06-24 05:26:27 +0000
commit6ea82fb5d6cd5ae6813f3700fe915ab9110086ea (patch)
tree485e5e470c048eeeff2c5701891abae6631d38be /lib/PublicInbox/NNTP.pm
parentca6b59974a0f2e24a1d569d118b55c4fc66ff7a3 (diff)
downloadpublic-inbox-6ea82fb5d6cd5ae6813f3700fe915ab9110086ea.tar.gz
No need to allocate a new PerlIO::scalar filehandle for every
client, instead we can now pass the same CODE reference which
calls DS->write on a reused string reference.
Diffstat (limited to 'lib/PublicInbox/NNTP.pm')
-rw-r--r--lib/PublicInbox/NNTP.pm6
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index 53de2bca..12ce4e68 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -101,6 +101,8 @@ sub expire_old () {
         }
 }
 
+sub greet ($) { $_[0]->write($_[0]->{nntpd}->{greet}) };
+
 sub new ($$$) {
         my ($class, $sock, $nntpd) = @_;
         my $self = fields::new($class);
@@ -113,9 +115,7 @@ sub new ($$$) {
         }
         $self->SUPER::new($sock, $ev);
         $self->{nntpd} = $nntpd;
-        my $greet = "201 $nntpd->{servername} ready - post via email\r\n";
-        open my $fh, '<:scalar',  \$greet or die "open :scalar: $!";
-        push @$wbuf, $fh;
+        push @$wbuf, \&greet;
         $self->{wbuf} = $wbuf;
         $self->{rbuf} = '';
         update_idle_time($self);