Commit cbe80237 authored by Juan Batiz-Benet's avatar Juan Batiz-Benet
Browse files

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

parent 9982e251
...@@ -3,6 +3,7 @@ package swarm ...@@ -3,6 +3,7 @@ package swarm
import ( import (
"errors" "errors"
"fmt" "fmt"
"net"
"sync" "sync"
"time" "time"
...@@ -13,6 +14,7 @@ import ( ...@@ -13,6 +14,7 @@ import (
context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context" context "github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr" ma "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr"
manet "github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/go-multiaddr-net"
) )
// dialAttempts governs how many times a goroutine will try to dial a given peer. // dialAttempts governs how many times a goroutine will try to dial a given peer.
...@@ -21,7 +23,7 @@ const dialAttempts = 3 ...@@ -21,7 +23,7 @@ const dialAttempts = 3
// DialTimeout is the amount of time each dial attempt has. We can think about making // DialTimeout is the amount of time each dial attempt has. We can think about making
// this larger down the road, or putting more granular timeouts (i.e. within each // this larger down the road, or putting more granular timeouts (i.e. within each
// subcomponent of Dial) // subcomponent of Dial)
var DialTimeout time.Duration = time.Second * 30 var DialTimeout time.Duration = time.Second * 10
// dialsync is a small object that helps manage ongoing dials. // dialsync is a small object that helps manage ongoing dials.
// this way, if we receive many simultaneous dial requests, one // 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) { ...@@ -185,6 +187,11 @@ func (s *Swarm) dial(ctx context.Context, p peer.ID) (*Conn, error) {
// open connection to peer // open connection to peer
d := &conn.Dialer{ d := &conn.Dialer{
Dialer: manet.Dialer{
Dialer: net.Dialer{
Timeout: DialTimeout,
},
},
LocalPeer: s.local, LocalPeer: s.local,
LocalAddrs: localAddrs, LocalAddrs: localAddrs,
PrivateKey: sk, PrivateKey: sk,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment