diff options
| author | Josh Ferrell <josh@vector35.com> | 2026-03-20 13:42:27 -0400 |
|---|---|---|
| committer | Josh Ferrell <josh@vector35.com> | 2026-03-20 16:25:43 -0400 |
| commit | 22a29f05cf59645a589f63a70269205bb6e9fa83 (patch) | |
| tree | 1a3c5d6331fb2e0b07b87ef0fd16f562a39951a8 /http.cpp | |
| parent | c425acdb51f6b1dfcfd6e5ff56a4c3967507ccba (diff) | |
Do not retry http requests if we are shutting down
Diffstat (limited to 'http.cpp')
| -rw-r--r-- | http.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
@@ -411,15 +411,23 @@ namespace BinaryNinja::Http LogDebug("* Error: %s", instance->GetError().c_str()); } - // Request failed, grab its error and try again + // Request failed, grab its error and try again unless we're shutting down response.error = instance->GetError(); - if (retry == HTTP_MAX_RETRIES || context.cancelled) + if (retry == HTTP_MAX_RETRIES || context.cancelled || BNIsShutdownRequested()) break; size_t backoff = 1000 * HTTP_BACKOFF_FACTOR * (2 * pow(2, retry - 1)); retry += 1; LogWarn("Attempt %d to %s %s failed, trying again in %zums\n", retry, request.m_method.data(), request.m_url.data(), backoff); - std::this_thread::sleep_for(std::chrono::milliseconds(backoff)); + + // Wait in blocks of 100ms so we can check for shutdown + for (size_t currentWait = 0; currentWait < backoff; currentWait += 100) + { + // If we're shutting down, return the error result instead of waiting to retry + if (BNIsShutdownRequested()) + return result; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } } if (getenv("BN_DEBUG_HTTP")) |
