Skip to content

Commit

Permalink
Revert "Fix detached thread resource leak if Matter stack is stopped …
Browse files Browse the repository at this point in the history
…and then… (#15167)" (#15399)

This reverts commit 6107c13.

PR #15167 was merged with a permanent CI failure (Tsan failures on
Linux), so now nothing can pass CI.
  • Loading branch information
bzbarsky-apple authored Feb 22, 2022
1 parent f8f54e9 commit 3666c5b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 28 deletions.
23 changes: 3 additions & 20 deletions src/platform/Linux/PlatformManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
#include <platform/PlatformManager.h>
#include <platform/internal/GenericPlatformManagerImpl_POSIX.cpp>

#include <thread>

#include <arpa/inet.h>
#include <dirent.h>
#include <errno.h>
Expand Down Expand Up @@ -188,13 +190,11 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()
this->mpGDBusConnection = UniqueGDBusConnection(g_bus_get_sync(G_BUS_TYPE_SYSTEM, nullptr, &error));

std::thread gdbusThread(GDBus_Thread);
mGdbusThreadHandle = gdbusThread.native_handle();
gdbusThread.detach();
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
std::thread wifiIPThread(WiFIIPChangeListener);
mWifiIPThreadHandle = wifiIPThread.native_handle();
wifiIPThread.detach();
#endif

Expand All @@ -217,7 +217,6 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack()

CHIP_ERROR PlatformManagerImpl::_Shutdown()
{
CHIP_ERROR err;
uint64_t upTime = 0;

if (GetDiagnosticDataProvider().GetUpTime(upTime) == CHIP_NO_ERROR)
Expand All @@ -238,23 +237,7 @@ CHIP_ERROR PlatformManagerImpl::_Shutdown()
ChipLogError(DeviceLayer, "Failed to get current uptime since the Node’s last reboot");
}

err = Internal::GenericPlatformManagerImpl_POSIX<PlatformManagerImpl>::_Shutdown();

#if CHIP_WITH_GIO
if (pthread_cancel(mGdbusThreadHandle) != 0)
{
ChipLogError(DeviceLayer, "Failed to cancel gDBus thread");
}
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
if (pthread_cancel(mWifiIPThreadHandle) != 0)
{
ChipLogError(DeviceLayer, "Failed to cancel WiFI IP Change Listener thread");
}
#endif

return err;
return Internal::GenericPlatformManagerImpl_POSIX<PlatformManagerImpl>::_Shutdown();
}

CHIP_ERROR PlatformManagerImpl::_GetFixedLabelList(
Expand Down
8 changes: 0 additions & 8 deletions src/platform/Linux/PlatformManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
#include <gio/gio.h>
#endif

#include <thread>

namespace chip {
namespace DeviceLayer {

Expand Down Expand Up @@ -99,12 +97,6 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener
};
using UniqueGDBusConnection = std::unique_ptr<GDBusConnection, GDBusConnectionDeleter>;
UniqueGDBusConnection mpGDBusConnection;

std::thread::native_handle_type mGdbusThreadHandle;
#endif

#if CHIP_DEVICE_CONFIG_ENABLE_WIFI
std::thread::native_handle_type mWifiIPThreadHandle;
#endif
};

Expand Down

0 comments on commit 3666c5b

Please sign in to comment.