From: Matt Joiner Date: Wed, 2 Mar 2016 12:27:46 +0000 (+1100) Subject: Fix a UTP Conn leak, on unencrypted followup dial attempts X-Git-Tag: v1.0.0~835 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=c175fab5a648ee5a8be03d947e50aec7c128b0a3;p=btrtrc.git Fix a UTP Conn leak, on unencrypted followup dial attempts I would guess that TCP ones were cleaned up by GC. --- diff --git a/client.go b/client.go index f60a4607..dabf0de4 100644 --- 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