Skip to content

Commit 116b10a

Browse files
committed
filetransfer: don't allow the queue size to be 0
This inadvertently caused file transfers to hang when used in conjunction with `http-connections = 0`: the worker checks if the in-progress items and items we've added to the incoming queue are larger than the max queue size, which was previously defined to be 5x the value of `http-connections. Well, as you can probably tell, 5*0=0, and unless the `.size()` of any of these containers became negative, we would always wait another 100ms instead of processing the incoming queue. Because `http-connections = 0` is a special value to signal, roughly, "as much possible" (mostly depends on how cURL handles it, but this is probably approximately right), we default to `std::thread::hardware_concurrency()` (as is done in a couple other places; specifically, this is what the ThreadPool constructor does for a value of `0`). There may be a better fix, but this works for now, and is approximately right.
1 parent 56e5d9f commit 116b10a

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/libstore/filetransfer.cc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -731,7 +731,10 @@ struct curlFileTransfer : public FileTransfer
731731

732732
std::thread workerThread;
733733

734-
const size_t maxQueueSize = fileTransferSettings.httpConnections.get() * 5;
734+
const size_t maxQueueSize =
735+
(fileTransferSettings.httpConnections.get() ? fileTransferSettings.httpConnections.get()
736+
: std::max(1U, std::thread::hardware_concurrency()))
737+
* 5;
735738

736739
curlFileTransfer()
737740
: mt19937(rd())

0 commit comments

Comments
 (0)