From: Matt Joiner Date: Mon, 12 Feb 2018 13:56:21 +0000 (+1100) Subject: Count errors returned from connection.mainReadLoop X-Git-Tag: v1.0.0~176 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=7dec0a196d076a01a507c4d17b852a3f6add3692;p=btrtrc.git Count errors returned from connection.mainReadLoop --- 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()