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
46b21cf5
Commit
46b21cf5
authored
Feb 09, 2015
by
Juan Batiz-Benet
Browse files
ctx.Done fixes
thanks @whyrusleeping for finding these.
parent
8a81975c
Changes
2
Hide whitespace changes
Inline
Side-by-side
crypto/secio/rw.go
View file @
46b21cf5
...
@@ -224,7 +224,10 @@ func writeMsgCtx(ctx context.Context, w msgio.Writer, msg proto.Message) ([]byte
...
@@ -224,7 +224,10 @@ func writeMsgCtx(ctx context.Context, w msgio.Writer, msg proto.Message) ([]byte
done
:=
make
(
chan
error
)
done
:=
make
(
chan
error
)
go
func
(
m
[]
byte
)
{
go
func
(
m
[]
byte
)
{
err
:=
w
.
WriteMsg
(
m
)
err
:=
w
.
WriteMsg
(
m
)
done
<-
err
select
{
case
done
<-
err
:
case
<-
ctx
.
Done
()
:
}
}(
enc
)
}(
enc
)
select
{
select
{
...
@@ -243,7 +246,10 @@ func readMsgCtx(ctx context.Context, r msgio.Reader, p proto.Message) ([]byte, e
...
@@ -243,7 +246,10 @@ func readMsgCtx(ctx context.Context, r msgio.Reader, p proto.Message) ([]byte, e
go
func
()
{
go
func
()
{
var
err
error
var
err
error
msg
,
err
=
r
.
ReadMsg
()
msg
,
err
=
r
.
ReadMsg
()
done
<-
err
select
{
case
done
<-
err
:
case
<-
ctx
.
Done
()
:
}
}()
}()
select
{
select
{
...
...
net/conn/dial.go
View file @
46b21cf5
...
@@ -44,7 +44,12 @@ func (d *Dialer) Dial(ctx context.Context, raddr ma.Multiaddr, remote peer.ID) (
...
@@ -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
// do it async to ensure we respect don contexteone
go
func
()
{
go
func
()
{
defer
func
()
{
done
<-
struct
{}{}
}()
defer
func
()
{
select
{
case
done
<-
struct
{}{}
:
case
<-
ctx
.
Done
()
:
}
}()
c
,
err
:=
newSingleConn
(
ctx
,
d
.
LocalPeer
,
remote
,
maconn
)
c
,
err
:=
newSingleConn
(
ctx
,
d
.
LocalPeer
,
remote
,
maconn
)
if
err
!=
nil
{
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