connection.go | 14 +++++++++----- diff --git a/connection.go b/connection.go index 4e919c5faecc468bbfe5c000bc0bfc2dedacc0d4..bf4485746b2057dbe333d9524507bf640ff2a05f 100644 --- a/connection.go +++ b/connection.go @@ -960,7 +960,14 @@ } // 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 @@ MaxLength: 256 * 1024, Pool: t.chunkPool, } for { - var ( - msg pp.Message - err error - ) + var msg pp.Message func() { cl.mu.Unlock() defer cl.mu.Lock()