Skip to content

Commit 02fcf7b

Browse files
authored
Merge pull request #327 from DeterminateSystems/sep-cole/nix-268-3152s-limit-the-number-of-active-curl-handles-breaks-http
filetransfer: don't allow the queue size to be 0
2 parents 7319060 + 116b10a commit 02fcf7b

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/libstore/filetransfer.cc

Lines changed: 7 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())
@@ -780,6 +783,9 @@ struct curlFileTransfer : public FileTransfer
780783

781784
void workerThreadMain()
782785
{
786+
/* NOTE(cole-h): the maxQueueSize needs to be >0 or else things will hang */
787+
assert(maxQueueSize > 0);
788+
783789
/* Cause this thread to be notified on SIGINT. */
784790
#ifndef _WIN32 // TODO need graceful async exit support on Windows?
785791
auto callback = createInterruptCallback([&]() { stopWorkerThread(); });

0 commit comments

Comments
 (0)