From 482dde8e3fcb44c3461a85f74e87f82f305a8f6e Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Tue, 18 Nov 2014 14:33:07 -0600 Subject: [PATCH] Fix race condition calculating reduced dial timeout --- client.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client.go b/client.go index 0c9ff2e5..3979b396 100644 --- a/client.go +++ b/client.go @@ -409,6 +409,7 @@ func (me *Client) initiateConn(peer Peer, t *torrent) { duplicateConnsAvoided.Add(1) return } + dialTimeout := reducedDialTimeout(dialTimeout, me.halfOpenLimit, len(t.Peers)) t.HalfOpen[addr] = struct{}{} go func() { // Binding to the listen address and dialing via net.Dialer gives @@ -416,7 +417,6 @@ func (me *Client) initiateConn(peer Peer, t *torrent) { // this address so that peers associate our local address with our // listen address. - dialTimeout := reducedDialTimeout(dialTimeout, me.halfOpenLimit, len(t.Peers)) // Initiate connections via TCP and UTP simultaneously. Use the first // one that succeeds. left := 2 -- 2.48.1