From: Matt Joiner Date: Tue, 18 Nov 2014 20:33:07 +0000 (-0600) Subject: Fix race condition calculating reduced dial timeout X-Git-Tag: v1.0.0~1513 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=482dde8e3fcb44c3461a85f74e87f82f305a8f6e;p=btrtrc.git Fix race condition calculating reduced dial timeout --- 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