From 22a29f05cf59645a589f63a70269205bb6e9fa83 Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Fri, 20 Mar 2026 13:42:27 -0400 Subject: Do not retry http requests if we are shutting down --- http.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'http.cpp') diff --git a/http.cpp b/http.cpp index 6292f952..ed861f8d 100644 --- a/http.cpp +++ b/http.cpp @@ -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")) -- cgit v1.3.1