Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
go-dms3
Commits
68618f3f
Commit
68618f3f
authored
10 years ago
by
Brian Tiger Chow
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(net) use Do to respect the caller's context
parent
ed247ec1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
2 deletions
+7
-2
net/net.go
net/net.go
+7
-2
No files found.
net/net.go
View file @
68618f3f
...
...
@@ -5,6 +5,7 @@ import (
mux
"github.com/jbenet/go-ipfs/net/mux"
swarm
"github.com/jbenet/go-ipfs/net/swarm"
peer
"github.com/jbenet/go-ipfs/peer"
util
"github.com/jbenet/go-ipfs/util"
ctxc
"github.com/jbenet/go-ipfs/util/ctxcloser"
context
"github.com/jbenet/go-ipfs/Godeps/_workspace/src/code.google.com/p/go.net/context"
...
...
@@ -56,9 +57,13 @@ func NewIpfsNetwork(ctx context.Context, listen []ma.Multiaddr, local peer.Peer,
// Listen handles incoming connections on given Multiaddr.
// func (n *IpfsNetwork) Listen(*ma.Muliaddr) error {}
// DialPeer attempts to establish a connection to a given peer
// DialPeer attempts to establish a connection to a given peer.
// Respects the context.
func
(
n
*
IpfsNetwork
)
DialPeer
(
ctx
context
.
Context
,
p
peer
.
Peer
)
error
{
_
,
err
:=
n
.
swarm
.
Dial
(
p
)
err
:=
util
.
Do
(
ctx
,
func
()
error
{
_
,
err
:=
n
.
swarm
.
Dial
(
p
)
return
err
})
return
err
}
...
...
This diff is collapsed.
Click to expand it.
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