Skip to content

Commit

Permalink
Reinit gdbus wrapper class in non-static class method (#26455)
Browse files Browse the repository at this point in the history
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...
  • Loading branch information
arkq authored May 9, 2023
1 parent 51092c9 commit d154372
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions src/platform/Linux/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -745,6 +745,11 @@ void ConnectivityManagerImpl::_OnWpaProxyReady(GObject * source_object, GAsyncRe

void ConnectivityManagerImpl::StartWiFiManagement()
{
std::lock_guard<std::mutex> 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"));
}
Expand Down Expand Up @@ -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<std::mutex> 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);

Expand Down

0 comments on commit d154372

Please sign in to comment.