Only run connection.Close once

Avoids unnecessary error messages for net.Conn.Close
This commit is contained in:
Matt Joiner 2017-09-18 13:40:36 +10:00
parent 19adb2cac3
commit 0790516440
1 changed files with 3 additions and 1 deletions

View File

@ -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 {