From 07905164401b96a80b5cfe4731016d1e44f83b60 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 18 Sep 2017 13:40:36 +1000 Subject: [PATCH] Only run connection.Close once Avoids unnecessary error messages for net.Conn.Close --- connection.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/connection.go b/connection.go index 4655b136..9b102eb8 100644 --- a/connection.go +++ b/connection.go @@ -226,7 +226,9 @@ func priorityBitmapHeadAsSlice(pb *prioritybitmap.PriorityBitmap, n int) (ret [] } func (cn *connection) Close() { - cn.closed.Set() + if !cn.closed.Set() { + return + } cn.discardPieceInclination() cn.pieceRequestOrder.Clear() if cn.conn != nil {