Commit c5223963 authored by Adin Schmahmann's avatar Adin Schmahmann

fullrt: abort bulk sending earlier if the context is cancelled

parent 8cce6568
...@@ -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))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment