reduce the request q size if the file has few pieces

head-request
Zlatin Balevsky 2021-05-24 11:53:29 +01:00
parent 4cff64133e
commit 99e9eb00a1
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 2 additions and 2 deletions

View File

@ -107,7 +107,7 @@ public class Downloader {
queueSize++ queueSize++
if (pieceSizePow2 < 18) if (pieceSizePow2 < 18)
queueSize++ queueSize++
this.queueSize = queueSize this.queueSize = Math.min(this.nPieces - 1, queueSize)
} }
public synchronized InfoHash getInfoHash() { public synchronized InfoHash getInfoHash() {
@ -427,7 +427,7 @@ public class Downloader {
sentAnyRequests = true sentAnyRequests = true
} }
} }
if (!sentAnyRequests) if (!sentAnyRequests && queueSize > 0)
break; break;
endpoint.getOutputStream().flush() endpoint.getOutputStream().flush()
} }