]> Sergey Matveev's repositories - public-inbox.git/commitdiff
nntp: prefix FD on every log line
authorEric Wong <e@80x24.org>
Fri, 25 Sep 2015 02:27:54 +0000 (02:27 +0000)
committerEric Wong <e@80x24.org>
Fri, 25 Sep 2015 02:29:07 +0000 (02:29 +0000)
This can help us track down what request patterns clients
will perform when we have multiple clients.

lib/PublicInbox/NNTP.pm

index 7e2c2abdb624da5ac72649c9b52b2f9d84984dca..3490a09879ea4df021f7368c38c79df6edc5c693 100644 (file)
@@ -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;