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
f6a336cc
Commit
f6a336cc
authored
Feb 09, 2015
by
Juan Batiz-Benet
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #766 from jbenet/ctx-done-fixes
ctx.Done fixes
parents
931cff2c
1811f1ef
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
3 deletions
+14
-3
p2p/crypto/secio/rw.go
p2p/crypto/secio/rw.go
+8
-2
p2p/net/conn/dial.go
p2p/net/conn/dial.go
+6
-1
No files found.
p2p/crypto/secio/rw.go
View file @
f6a336cc
...
...
@@ -224,7 +224,10 @@ func writeMsgCtx(ctx context.Context, w msgio.Writer, msg proto.Message) ([]byte
done
:=
make
(
chan
error
)
go
func
(
m
[]
byte
)
{
err
:=
w
.
WriteMsg
(
m
)
done
<-
err
select
{
case
done
<-
err
:
case
<-
ctx
.
Done
()
:
}
}(
enc
)
select
{
...
...
@@ -243,7 +246,10 @@ func readMsgCtx(ctx context.Context, r msgio.Reader, p proto.Message) ([]byte, e
go
func
()
{
var
err
error
msg
,
err
=
r
.
ReadMsg
()
done
<-
err
select
{
case
done
<-
err
:
case
<-
ctx
.
Done
()
:
}
}()
select
{
...
...
p2p/net/conn/dial.go
View file @
f6a336cc
...
...
@@ -44,7 +44,12 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
// do it async to ensure we respect don contexteone
go
func
()
{
defer
func
()
{
done
<-
struct
{}{}
}()
defer
func
()
{
select
{
case
done
<-
struct
{}{}
:
case
<-
ctx
.
Done
()
:
}
}()
c
,
err
:=
newSingleConn
(
ctx
,
d
.
LocalPeer
,
remote
,
maconn
)
if
err
!=
nil
{
...
...
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