From dd237591f9fa61e163ecdbbaa14645ad021e21f6 Mon Sep 17 00:00:00 2001 From: nohle Date: Tue, 9 Nov 2021 11:15:31 -0800 Subject: [PATCH] Request IP and port only after creating WifiLan server socket PiperOrigin-RevId: 408657640 --- cpp/core/internal/wifi_lan_bwu_handler.cc | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/cpp/core/internal/wifi_lan_bwu_handler.cc b/cpp/core/internal/wifi_lan_bwu_handler.cc index 9b8eeedb..5b952417 100644 --- a/cpp/core/internal/wifi_lan_bwu_handler.cc +++ b/cpp/core/internal/wifi_lan_bwu_handler.cc @@ -46,18 +46,6 @@ ByteArray WifiLanBwuHandler::InitializeUpgradedMediumForEndpoint( // stop the advertising yet. std::string upgrade_service_id = Utils::WrapUpgradeServiceId(service_id); - auto credential = wifi_lan_medium_.GetCredentials(upgrade_service_id); - auto ip_address = credential.first; - auto port = credential.second; - if (ip_address.empty()) { - NEARBY_LOGS(INFO) - << "WifiLanBwuHandler couldn't initiate the wifi_lan upgrade for " - "endpoint " - << endpoint_id - << " because the wifi_lan ip address were unable to be obtained."; - return {}; - } - if (!wifi_lan_medium_.IsAcceptingConnections(upgrade_service_id)) { if (!wifi_lan_medium_.StartAcceptingConnections( upgrade_service_id, @@ -83,6 +71,18 @@ ByteArray WifiLanBwuHandler::InitializeUpgradedMediumForEndpoint( // cache service ID to revert active_service_ids_.insert(upgrade_service_id); + auto credential = wifi_lan_medium_.GetCredentials(upgrade_service_id); + auto ip_address = credential.first; + auto port = credential.second; + if (ip_address.empty()) { + NEARBY_LOGS(INFO) + << "WifiLanBwuHandler couldn't initiate the wifi_lan upgrade for " + "endpoint " + << endpoint_id + << " because the wifi_lan ip address were unable to be obtained."; + return {}; + } + return parser::ForBwuWifiLanPathAvailable(ip_address, port); }