winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 9c5c5db1f42355b0d08b657f6cf1f0c7d681dfa6
parent 88ff15d2dead16aa6e4953560e94cd6e05e9c4ae
Author: JohnMcPMS <johnmcp@microsoft.com>
Date:   Sun, 24 Sep 2023 10:06:01 -0700

Add a bit of randomness to the wait time after source update failure (#3661)


Diffstat:
Msrc/AppInstallerRepositoryCore/RepositorySource.cpp | 7++++++-
Msrc/AppInstallerRepositoryCore/pch.h | 1+
2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/AppInstallerRepositoryCore/RepositorySource.cpp b/src/AppInstallerRepositoryCore/RepositorySource.cpp @@ -53,7 +53,12 @@ namespace AppInstaller::Repository CATCH_LOG(); AICLI_LOG(Repo, Info, << "Source add/update failed, waiting a bit and retrying: " << details.Name); - std::this_thread::sleep_for(2s); + + // Add a bit of randomness to the retry wait time + std::default_random_engine randomEngine(std::random_device{}()); + std::uniform_int_distribution<long long> distribution(2000, 10000); + + std::this_thread::sleep_for(std::chrono::milliseconds(distribution(randomEngine))); // If this one fails, maybe the problem is persistent. result = (factory.get()->*member)(details, progress); diff --git a/src/AppInstallerRepositoryCore/pch.h b/src/AppInstallerRepositoryCore/pch.h @@ -55,6 +55,7 @@ #include <map> #include <memory> #include <optional> +#include <random> #include <set> #include <string> #include <string_view>