From 2b1fbbaa4d7843e8c6179f6feddb193e070aca42 Mon Sep 17 00:00:00 2001 From: Arkadiusz Bokowy Date: Tue, 9 May 2023 20:48:05 +0200 Subject: [PATCH] Reinit gdbus wrapper class in non-static class method (#26455) It seems that Clang Thread Safety Analysis is confused if the lock takes place not on the class instance itself but in the static method... --- src/platform/Linux/ConnectivityManagerImpl.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/platform/Linux/ConnectivityManagerImpl.cpp b/src/platform/Linux/ConnectivityManagerImpl.cpp index 53a1aa27ee91e6..aba40e3b116528 100644 --- a/src/platform/Linux/ConnectivityManagerImpl.cpp +++ b/src/platform/Linux/ConnectivityManagerImpl.cpp @@ -745,6 +745,11 @@ void ConnectivityManagerImpl::_OnWpaProxyReady(GObject * source_object, GAsyncRe void ConnectivityManagerImpl::StartWiFiManagement() { + std::lock_guard lock(mWpaSupplicantMutex); + + mConnectivityFlag.ClearAll(); + mWpaSupplicant = GDBusWpaSupplicant{}; + CHIP_ERROR err = PlatformMgrImpl().GLibMatterContextInvokeSync(_StartWiFiManagement, this); VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(DeviceLayer, "Failed to start WiFi management")); } @@ -1705,13 +1710,7 @@ CHIP_ERROR ConnectivityManagerImpl::_StartWiFiManagement(ConnectivityManagerImpl // all D-Bus signals will be delivered to the GLib global default main context. VerifyOrDie(g_main_context_get_thread_default() != nullptr); - std::lock_guard lock(self->mWpaSupplicantMutex); - - self->mConnectivityFlag.ClearAll(); - self->mWpaSupplicant = GDBusWpaSupplicant{}; - ChipLogProgress(DeviceLayer, "wpa_supplicant: Start WiFi management"); - wpa_fi_w1_wpa_supplicant1_proxy_new_for_bus(G_BUS_TYPE_SYSTEM, G_DBUS_PROXY_FLAGS_NONE, kWpaSupplicantServiceName, kWpaSupplicantObjectPath, nullptr, self->_OnWpaProxyReady, nullptr);