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
1dbefd3f
Commit
1dbefd3f
authored
May 27, 2020
by
Adin Schmahmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: lookup context cancellation race condition
parent
3d294c7a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
0 deletions
+9
-0
query.go
query.go
+9
-0
No files found.
query.go
View file @
1dbefd3f
...
...
@@ -117,10 +117,12 @@ func (dht *IpfsDHT) runLookupWithFollowup(ctx context.Context, target string, qu
}
// wait for all queries to complete before returning, aborting ongoing queries if we've been externally stopped
followupsCompleted
:=
0
processFollowUp
:
for
i
:=
0
;
i
<
len
(
queryPeers
);
i
++
{
select
{
case
<-
doneCh
:
followupsCompleted
++
if
stopFn
()
{
cancelFollowUp
()
if
i
<
len
(
queryPeers
)
-
1
{
...
...
@@ -130,10 +132,17 @@ processFollowUp:
}
case
<-
ctx
.
Done
()
:
lookupRes
.
completed
=
false
cancelFollowUp
()
break
processFollowUp
}
}
if
!
lookupRes
.
completed
{
for
i
:=
followupsCompleted
;
i
<
len
(
queryPeers
);
i
++
{
<-
doneCh
}
}
return
lookupRes
,
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