diff --git a/internal/platform/implementation/windows/wifi_lan_mdns.cc b/internal/platform/implementation/windows/wifi_lan_mdns.cc index b86c2057..f0af2c28 100644 --- a/internal/platform/implementation/windows/wifi_lan_mdns.cc +++ b/internal/platform/implementation/windows/wifi_lan_mdns.cc @@ -148,7 +148,7 @@ bool WifiLanMdns::StopMdnsService() { LOG(INFO) << "StopMdnsService is called"; if (!is_service_started_) { LOG(WARNING) << "The mDNS service is not started."; - return false; + return true; } dns_service_notification_ = std::make_unique(); diff --git a/internal/platform/implementation/windows/wifi_lan_medium.cc b/internal/platform/implementation/windows/wifi_lan_medium.cc index 6872e682..0a5270c0 100644 --- a/internal/platform/implementation/windows/wifi_lan_medium.cc +++ b/internal/platform/implementation/windows/wifi_lan_medium.cc @@ -211,6 +211,9 @@ bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) { if (NearbyFlags::GetInstance().GetBoolFlag( nearby::platform::config_package_nearby::nearby_platform_feature:: kEnableBlockingSocket)) { + // The service may be running under WinRT when the flag is enabled. + dnssd_service_instance_ = nullptr; + bool result = wifi_lan_mdns_.StopMdnsService(); if (result) { @@ -223,6 +226,9 @@ bool WifiLanMedium::StopAdvertising(const NsdServiceInfo& nsd_service_info) { medium_status_ &= (~kMediumStatusAdvertising); return false; } else { + // The service may be running under Win32 when the flag is disabled. + wifi_lan_mdns_.StopMdnsService(); + dnssd_service_instance_ = nullptr; LOG(INFO) << "succeeded to stop mDNS advertising for service type ="