From 99e9eb00a1d4323d8f3be994531a0428cc2520bd Mon Sep 17 00:00:00 2001 From: Zlatin Balevsky Date: Mon, 24 May 2021 11:53:29 +0100 Subject: [PATCH] reduce the request q size if the file has few pieces --- .../main/groovy/com/muwire/core/download/Downloader.groovy | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/groovy/com/muwire/core/download/Downloader.groovy b/core/src/main/groovy/com/muwire/core/download/Downloader.groovy index d9165970..b1cc7e42 100644 --- a/core/src/main/groovy/com/muwire/core/download/Downloader.groovy +++ b/core/src/main/groovy/com/muwire/core/download/Downloader.groovy @@ -107,7 +107,7 @@ public class Downloader { queueSize++ if (pieceSizePow2 < 18) queueSize++ - this.queueSize = queueSize + this.queueSize = Math.min(this.nPieces - 1, queueSize) } public synchronized InfoHash getInfoHash() { @@ -427,7 +427,7 @@ public class Downloader { sentAnyRequests = true } } - if (!sentAnyRequests) + if (!sentAnyRequests && queueSize > 0) break; endpoint.getOutputStream().flush() }