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-10 02:07:26 +0000
committerEric Wong <e@80x24.org>2019-06-10 05:05:15 +0000
commitdbf0cad365839a99e8582d6e26ce40c02508155d (patch)
treed11bb44cb03bd916ff639a5533ac1ffa60370845 /lib/PublicInbox/NNTP.pm
parent30ab5cf82b9d47242640f748a0f9a088ca783e32 (diff)
downloadpublic-inbox-dbf0cad365839a99e8582d6e26ce40c02508155d.tar.gz
Storing the file descriptor was redundant as we can quickly call
fileno($self->{sock}) and not have to store an extra hash table
entry.  Multiple sources of truth leads to confusion, confusion
leads to bugs.
Diffstat (limited to 'lib/PublicInbox/NNTP.pm')
-rw-r--r--lib/PublicInbox/NNTP.pm10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/PublicInbox/NNTP.pm b/lib/PublicInbox/NNTP.pm
index b62c2187..7729399a 100644
--- a/lib/PublicInbox/NNTP.pm
+++ b/lib/PublicInbox/NNTP.pm
@@ -66,7 +66,8 @@ sub next_tick () {
 
 sub update_idle_time ($) {
         my ($self) = @_;
-        my $fd = $self->{fd};
+        my $sock = $self->{sock} or return;
+        my $fd = fileno($sock);
         defined $fd and $EXPMAP->{$fd} = [ now(), $self ];
 }
 
@@ -595,7 +596,7 @@ sub long_response ($$) {
         my ($self, $cb) = @_;
         die "BUG: nested long response" if $self->{long_res};
 
-        my $fd = $self->{fd};
+        my $fd = fileno($self->{sock});
         defined $fd or return;
         # make sure we disable reading during a long response,
         # clients should not be sending us stuff and making us do more
@@ -963,7 +964,7 @@ sub event_read {
                 my $line = $1;
                 return $self->close if $line =~ /[[:cntrl:]]/s;
                 my $t0 = now();
-                my $fd = $self->{fd};
+                my $fd = fileno($self->{sock});
                 $r = eval { process_line($self, $line) };
                 my $d = $self->{long_res} ?
                         " deferred[$fd]" : '';
@@ -995,7 +996,8 @@ sub check_read {
 
 sub not_idle_long ($$) {
         my ($self, $now) = @_;
-        defined(my $fd = $self->{fd}) or return;
+        my $sock = $self->{sock} or return;
+        defined(my $fd = fileno($sock)) or return;
         my $ary = $EXPMAP->{$fd} or return;
         my $exp_at = $ary->[0] + $EXPTIME;
         $exp_at > $now;