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
p2p
go-p2p-kad-dht
Commits
4d542cbb
Commit
4d542cbb
authored
Jun 09, 2016
by
Jeromy Johnson
Committed by
GitHub
Jun 09, 2016
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2826 from ipfs/fix/dht-ctx-respect
respect contexts while reading messages in dht
parents
2b3334c4
cd34bf85
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
1 deletion
+15
-1
dht_net.go
dht_net.go
+15
-1
No files found.
dht_net.go
View file @
4d542cbb
...
...
@@ -214,7 +214,7 @@ func (ms *messageSender) SendRequest(ctx context.Context, pmes *pb.Message) (*pb
log
.
Event
(
ctx
,
"dhtSentMessage"
,
ms
.
dht
.
self
,
ms
.
p
,
pmes
)
mes
:=
new
(
pb
.
Message
)
if
err
:=
ms
.
r
.
ReadMsg
(
mes
);
err
!=
nil
{
if
err
:=
ms
.
ctx
ReadMsg
(
ctx
,
mes
);
err
!=
nil
{
ms
.
s
.
Close
()
ms
.
s
=
nil
return
nil
,
err
...
...
@@ -227,3 +227,17 @@ func (ms *messageSender) SendRequest(ctx context.Context, pmes *pb.Message) (*pb
return
mes
,
nil
}
func
(
ms
*
messageSender
)
ctxReadMsg
(
ctx
context
.
Context
,
mes
*
pb
.
Message
)
error
{
errc
:=
make
(
chan
error
,
1
)
go
func
()
{
errc
<-
ms
.
r
.
ReadMsg
(
mes
)
}()
select
{
case
err
:=
<-
errc
:
return
err
case
<-
ctx
.
Done
()
:
return
ctx
.
Err
()
}
}
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