Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
cbe80237
Commit
cbe80237
authored
Jan 13, 2015
by
Juan Batiz-Benet
Browse files
p2p/net/swarm: dial timeout to 10s + dialer
parent
9982e251
Changes
1
Hide whitespace changes
Inline
Side-by-side
net/swarm/swarm_dial.go
View file @
cbe80237
...
@@ -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
*
3
0
var
DialTimeout
time
.
Duration
=
time
.
Second
*
1
0
// 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
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment