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
e397e521
Commit
e397e521
authored
Feb 11, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #772 from jbenet/dial-respect-ctx
p2p/net/conn: respect context on dialing
parents
6f166529
5171d3df
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
8 additions
and
8 deletions
+8
-8
p2p/net/conn/dial.go
p2p/net/conn/dial.go
+8
-8
No files found.
p2p/net/conn/dial.go
View file @
e397e521
...
@@ -31,13 +31,6 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
...
@@ -31,13 +31,6 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
logdial
[
"encrypted"
]
=
(
d
.
PrivateKey
!=
nil
)
// log wether this will be an encrypted dial or not.
logdial
[
"encrypted"
]
=
(
d
.
PrivateKey
!=
nil
)
// log wether this will be an encrypted dial or not.
defer
log
.
EventBegin
(
ctx
,
"connDial"
,
logdial
)
.
Done
()
defer
log
.
EventBegin
(
ctx
,
"connDial"
,
logdial
)
.
Done
()
maconn
,
err
:=
d
.
rawConnDial
(
ctx
,
raddr
,
remote
)
if
err
!=
nil
{
logdial
[
"dial"
]
=
"failure"
logdial
[
"error"
]
=
err
return
nil
,
err
}
var
connOut
Conn
var
connOut
Conn
var
errOut
error
var
errOut
error
done
:=
make
(
chan
struct
{})
done
:=
make
(
chan
struct
{})
...
@@ -51,8 +44,15 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
...
@@ -51,8 +44,15 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
}
}
}()
}()
maconn
,
err
:=
d
.
rawConnDial
(
ctx
,
raddr
,
remote
)
if
err
!=
nil
{
errOut
=
err
return
}
c
,
err
:=
newSingleConn
(
ctx
,
d
.
LocalPeer
,
remote
,
maconn
)
c
,
err
:=
newSingleConn
(
ctx
,
d
.
LocalPeer
,
remote
,
maconn
)
if
err
!=
nil
{
if
err
!=
nil
{
maconn
.
Close
()
errOut
=
err
errOut
=
err
return
return
}
}
...
@@ -75,8 +75,8 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
...
@@ -75,8 +75,8 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
select
{
select
{
case
<-
ctx
.
Done
()
:
case
<-
ctx
.
Done
()
:
maconn
.
Close
()
logdial
[
"error"
]
=
ctx
.
Err
()
logdial
[
"error"
]
=
ctx
.
Err
()
logdial
[
"dial"
]
=
"failure"
return
nil
,
ctx
.
Err
()
return
nil
,
ctx
.
Err
()
case
<-
done
:
case
<-
done
:
// whew, finished.
// whew, finished.
...
...
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