From 799027bdc9eb7b6c3cbb72eb906464365bfdc223 Mon Sep 17 00:00:00 2001 From: Guogang Li Date: Thu, 25 Sep 2025 08:56:56 -0700 Subject: [PATCH] Improve Hotspot connection retry logic. PiperOrigin-RevId: 811370302 --- .../apple/Mediums/Hotspot/GNCHotspotMedium.m | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/platform/implementation/apple/Mediums/Hotspot/GNCHotspotMedium.m b/internal/platform/implementation/apple/Mediums/Hotspot/GNCHotspotMedium.m index e15c5e10..ca6e4131 100644 --- a/internal/platform/implementation/apple/Mediums/Hotspot/GNCHotspotMedium.m +++ b/internal/platform/implementation/apple/Mediums/Hotspot/GNCHotspotMedium.m @@ -109,7 +109,16 @@ static const UInt8 kConnectionToHostTimeoutInSeconds = 10; dispatch_semaphore_signal(semaphore_internal); }]; if (dispatch_semaphore_wait(semaphore_internal, timeout) != 0) { + // Timeout to connect to the hotspot. Technically, we should not reach here because the + // completion handler will be called even if it times out. But adding this log for debugging + // purpose. GNCLoggerError(@"Connecting to %@ timeout in %d seconds", ssid, kConnectionTimeoutInSeconds); + break; + } + + if (connected) { + // Connected to the hotspot, no need to retry. + break; } }