]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Log errors closing connection net.Conn's
authorMatt Joiner <anacrolix@gmail.com>
Mon, 18 Sep 2017 02:16:59 +0000 (12:16 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 18 Sep 2017 02:16:59 +0000 (12:16 +1000)
connection.go

index 752f79f42246f196a5b5376a8f1d9ee5354f3185..4655b1363e66b9d5bdc96df5569a8be3608f832b 100644 (file)
@@ -230,8 +230,14 @@ func (cn *connection) Close() {
        cn.discardPieceInclination()
        cn.pieceRequestOrder.Clear()
        if cn.conn != nil {
-               // TODO: This call blocks sometimes, why?
-               go cn.conn.Close()
+               go func() {
+                       // TODO: This call blocks sometimes, why? Maybe it was the Go utp
+                       // implementation?
+                       err := cn.conn.Close()
+                       if err != nil {
+                               log.Printf("error closing connection net.Conn: %s", err)
+                       }
+               }()
        }
 }