From c4fab7d1dca07e197df18f0b7b39dcca34095af2 Mon Sep 17 00:00:00 2001 From: Nemoumbra Date: Tue, 11 Aug 2026 03:50:48 +0300 Subject: [PATCH] Removed unnecessary waiting --- Common/Net/HTTPClient.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Common/Net/HTTPClient.cpp b/Common/Net/HTTPClient.cpp index a2743f0213..d8ebb90cf9 100644 --- a/Common/Net/HTTPClient.cpp +++ b/Common/Net/HTTPClient.cpp @@ -154,6 +154,17 @@ bool Connection::Connect(int maxTries, double timeout, bool *cancelConnect) { } } + if (sockets.empty()) { + // No need to call 'select' if we don't have any plausible sockets. + if (cancelConnect && *cancelConnect) { + WARN_LOG(Log::Net, "connect: cancelled (2): %s:%d", host_.c_str(), port_); + break; + } + sleep_ms(1, "connect"); + continue; + } + // There is at least 1 socket candidate. + int selectResult = 0; long timeoutHalfSeconds = floor(2 * timeout); while (timeoutHalfSeconds >= 0 && selectResult == 0) {