@cryptotaxi247 / kubo / commits / 8de8ed084

p2p/net/swarm: dial timeout to 10s + dialer

Juan Batiz-Benet committed Jan 13, 2015 at 03:47 UTC 8de8ed0842ecf44eab786917aece4b68647f2aed
1 file changed +8 -1
p2p/net/swarm/swarm_dial.go
+8 -1
@@ -3,6 +3,7 @@ package swarm
3 import (
4 "errors"
5 "fmt"
6 + "net"
7 "sync"
8 "time"
9
@@ -13,6 +14,7 @@ import (
14
15 context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
16 ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
17 + manet "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net"
18 )
19
20 // dialAttempts governs how many times a goroutine will try to dial a given peer.
@@ -21,7 +23,7 @@ const dialAttempts = 3
23 // DialTimeout is the amount of time each dial attempt has. We can think about making
24 // this larger down the road, or putting more granular timeouts (i.e. within each
25 // subcomponent of Dial)
24 -var DialTimeout time.Duration = time.Second * 30
26 +var DialTimeout time.Duration = time.Second * 10
27
28 // dialsync is a small object that helps manage ongoing dials.
29 // this way, if we receive many simultaneous dial requests, one
@@ -185,6 +187,11 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) {
187
188 // open connection to peer
189 d := &conn.Dialer{
190 + Dialer: manet.Dialer{
191 + Dialer: net.Dialer{
192 + Timeout: DialTimeout,
193 + },
194 + },
195 LocalPeer: s.local,
196 LocalAddrs: localAddrs,
197 PrivateKey: sk,