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
83ea98ed
Commit
83ea98ed
authored
Feb 19, 2015
by
Jeromy
Browse files
fix weird race condition in goprocess that caused a few panics
parent
1f0bbc47
Changes
1
Hide whitespace changes
Inline
Side-by-side
net/swarm/swarm_dial.go
View file @
83ea98ed
...
...
@@ -17,7 +17,6 @@ import (
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"
process
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess"
procctx
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/context"
ratelimit
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/github.com/jbenet/goprocess/ratelimit"
)
...
...
@@ -384,7 +383,7 @@ func (s *Swarm) dialAddrs(ctx context.Context, d *conn.Dialer, p peer.ID, remote
// to end early.
go
func
()
{
// rate limiting just in case. at most 10 addrs at once.
limiter
:=
ratelimit
.
NewRateLimiter
(
proc
ctx
.
WithContext
(
ctx
),
10
)
limiter
:=
ratelimit
.
NewRateLimiter
(
proc
ess
.
Background
(
),
10
)
limiter
.
Go
(
func
(
worker
process
.
Process
)
{
// permute addrs so we try different sets first each time.
for
_
,
i
:=
range
rand
.
Perm
(
len
(
remoteAddrs
))
{
...
...
@@ -402,6 +401,9 @@ func (s *Swarm) dialAddrs(ctx context.Context, d *conn.Dialer, p peer.ID, remote
})
}
})
<-
ctx
.
Done
()
limiter
.
Close
()
}()
// wair fot the results.
...
...
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