From f233800d169c9ccaea1d2a4bdccf9dee6853d82b Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Fri, 25 Sep 2015 02:27:54 +0000 Subject: nntp: prefix FD on every log line This can help us track down what request patterns clients will perform when we have multiple clients. --- 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 7e2c2abd..3490a098 100644 --- a/lib/PublicInbox/NNTP.pm +++ b/lib/PublicInbox/NNTP.pm @@ -492,11 +492,12 @@ sub long_response ($$$$) { my ($self, $beg, $end, $cb) = @_; die "BUG: nested long response" if $self->{long_res}; + my $fd = $self->{fd}; + 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 # work while we are stream a response to them $self->watch_read(0); - my $fd = fileno $self->{sock}; my $t0 = now(); $self->{long_res} = sub { # limit our own running time for fairness with other @@ -885,10 +886,11 @@ sub event_read { while ($r > 0 && $self->{rbuf} =~ s/\A\s*([^\r\n]+)\r?\n//) { my $line = $1; my $t0 = now(); + my $fd = $self->{fd}; $r = eval { $self->process_line($line) }; my $d = $self->{long_res} ? - ' deferred['.fileno($self->{sock}).']' : ''; - out($self, "$line - %0.6f$d", now() - $t0); + " deferred[$fd]" : ''; + out($self, "[$fd] $line - %0.6f$d", now() - $t0); } return $self->close if $r < 0; -- cgit v1.2.3-24-ge0c7