]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Fix a UTP Conn leak, on unencrypted followup dial attempts
authorMatt Joiner <anacrolix@gmail.com>
Wed, 2 Mar 2016 12:27:46 +0000 (23:27 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 2 Mar 2016 12:27:46 +0000 (23:27 +1100)
I would guess that TCP ones were cleaned up by GC.

client.go

index f60a4607458bbb6a8c139ddeedffc42922b36e8e..dabf0de4e604740cc8e95f474308946f00ad4c51 100644 (file)
--- a/client.go
+++ b/client.go
@@ -733,7 +733,8 @@ func (me *Client) noLongerHalfOpen(t *torrent, addr string) {
        me.openNewConns(t)
 }
 
-// Performs initiator handshakes and returns a connection.
+// Performs initiator handshakes and returns a connection. Returns nil
+// *connection if no connection for valid reasons.
 func (me *Client) handshakesConnection(nc net.Conn, t *torrent, encrypted, utp bool) (c *connection, err error) {
        c = newConnection()
        c.conn = nc
@@ -782,7 +783,7 @@ func (me *Client) establishOutgoingConn(t *torrent, addr string) (c *connection,
                return
        }
        c, err = me.handshakesConnection(nc, t, false, utp)
-       if err != nil {
+       if err != nil || c == nil {
                nc.Close()
        }
        return