From b3a92d698b876eb06da7d514e93ff45f9e9f6314 Mon Sep 17 00:00:00 2001 From: Nate Maninger Date: Sat, 2 Mar 2024 21:01:29 -0800 Subject: [PATCH] downloader: remove inner dequeue loop --- renterd/downloader/downloader.go | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/renterd/downloader/downloader.go b/renterd/downloader/downloader.go index e477f78..4de0d44 100644 --- a/renterd/downloader/downloader.go +++ b/renterd/downloader/downloader.go @@ -176,17 +176,15 @@ func (bd *BlockDownloader) downloadWorker(ctx context.Context, n int) { case <-bd.ch: } - for { - bd.mu.Lock() - if bd.queue.Len() == 0 { - bd.mu.Unlock() - break - } - - task := heap.Pop(bd.queue).(*blockResponse) + bd.mu.Lock() + if bd.queue.Len() == 0 { bd.mu.Unlock() - bd.doDownloadTask(task, log.With(zap.String("key", task.key))) + continue } + + task := heap.Pop(bd.queue).(*blockResponse) + bd.mu.Unlock() + bd.doDownloadTask(task, log.With(zap.String("key", task.key))) } }