From c175fab5a648ee5a8be03d947e50aec7c128b0a3 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Wed, 2 Mar 2016 23:27:46 +1100 Subject: [PATCH] Fix a UTP Conn leak, on unencrypted followup dial attempts I would guess that TCP ones were cleaned up by GC. --- client.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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 -- 2.48.1