Skip to content

Commit dabd0e0

Browse files
authored
Fix it twice (#5381)
Fixes #5365 ## Change Fix the issue in two ways: 1. Only use `- 1` if `supportedConcurrentThreads` is greater than 1. 2. Swap the order of setting min and max thread counts on the pool so that setting the minimum thread count to 1 overrides a "bad" allowed thread count of 0 (there are better ways to not do something than creating a thread pool that isn't allowed any threads).
1 parent 3267d50 commit dabd0e0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/AppInstallerCLICore/ContextOrchestrator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ namespace AppInstaller::CLI::Execution
5858
const auto supportedConcurrentThreads = std::thread::hardware_concurrency();
5959
const UINT32 maxDownloadThreads = 3;
6060
const UINT32 operationThreads = 1;
61-
const UINT32 downloadThreads = std::min(supportedConcurrentThreads ? supportedConcurrentThreads - 1 : 1, maxDownloadThreads);
61+
const UINT32 downloadThreads = std::min(supportedConcurrentThreads > 1 ? supportedConcurrentThreads - 1 : 1, maxDownloadThreads);
6262

6363
AddCommandQueue(COMDownloadCommand::CommandName, downloadThreads);
6464
AddCommandQueue(OperationCommandQueueName, operationThreads);
@@ -207,8 +207,8 @@ namespace AppInstaller::CLI::Execution
207207
SetThreadpoolCallbackPool(&m_threadPoolCallbackEnviron, m_threadPool.get());
208208
SetThreadpoolCallbackCleanupGroup(&m_threadPoolCallbackEnviron, m_threadPoolCleanupGroup.get(), nullptr);
209209

210-
THROW_LAST_ERROR_IF(!SetThreadpoolThreadMinimum(m_threadPool.get(), 1));
211210
SetThreadpoolThreadMaximum(m_threadPool.get(), m_allowedThreads);
211+
THROW_LAST_ERROR_IF(!SetThreadpoolThreadMinimum(m_threadPool.get(), 1));
212212
}
213213

214214
OrchestratorQueue::~OrchestratorQueue()

0 commit comments

Comments
 (0)