From 7dec0a196d076a01a507c4d17b852a3f6add3692 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 13 Feb 2018 00:56:21 +1100 Subject: [PATCH] Count errors returned from connection.mainReadLoop --- connection.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/connection.go b/connection.go index 4e919c5f..bf448574 100644 --- a/connection.go +++ b/connection.go @@ -960,7 +960,14 @@ func (c *connection) onReadRequest(r request) error { // Processes incoming bittorrent messages. The client lock is held upon entry // and exit. Returning will end the connection. -func (c *connection) mainReadLoop() error { +func (c *connection) mainReadLoop() (err error) { + defer func() { + if err != nil { + torrent.Add("connection.mainReadLoop returned with error", 1) + } else { + torrent.Add("connection.mainReadLoop returned with no error", 1) + } + }() t := c.t cl := t.cl @@ -970,10 +977,7 @@ func (c *connection) mainReadLoop() error { Pool: t.chunkPool, } for { - var ( - msg pp.Message - err error - ) + var msg pp.Message func() { cl.mu.Unlock() defer cl.mu.Lock() -- 2.50.0