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
c5223963
Commit
c5223963
authored
May 26, 2021
by
Adin Schmahmann
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fullrt: abort bulk sending earlier if the context is cancelled
parent
8cce6568
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
fullrt/dht.go
fullrt/dht.go
+4
-0
No files found.
fullrt/dht.go
View file @
c5223963
...
@@ -977,6 +977,10 @@ func (dht *FullRT) bulkMessageSend(ctx context.Context, keys []peer.ID, fn func(
...
@@ -977,6 +977,10 @@ func (dht *FullRT) bulkMessageSend(ctx context.Context, keys []peer.ID, fn func(
go
func
()
{
go
func
()
{
defer
wg
.
Done
()
defer
wg
.
Done
()
for
_
,
key
:=
range
chunk
{
for
_
,
key
:=
range
chunk
{
if
ctx
.
Err
()
!=
nil
{
break
}
sendsSoFar
:=
atomic
.
AddUint64
(
&
numSends
,
1
)
sendsSoFar
:=
atomic
.
AddUint64
(
&
numSends
,
1
)
if
onePctKeys
>
0
&&
sendsSoFar
%
onePctKeys
==
0
{
if
onePctKeys
>
0
&&
sendsSoFar
%
onePctKeys
==
0
{
logger
.
Infof
(
"bulk sending goroutine: %.1f%% done - %d/%d done"
,
100
*
float64
(
sendsSoFar
)
/
float64
(
len
(
sortedKeys
)),
sendsSoFar
,
len
(
sortedKeys
))
logger
.
Infof
(
"bulk sending goroutine: %.1f%% done - %d/%d done"
,
100
*
float64
(
sendsSoFar
)
/
float64
(
len
(
sortedKeys
)),
sendsSoFar
,
len
(
sortedKeys
))
...
...
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