aboutsummaryrefslogtreecommitdiffstats
path: root/src/direct_bt
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2020-09-29 18:27:00 +0200
committerSven Gothel <[email protected]>2020-09-29 18:27:00 +0200
commit6fde0cc2b07d4b6529e88002f7637d5206e714ed (patch)
treea3e2f4e6ab4c21f37f8496daf681bf7c5ffc87e6 /src/direct_bt
parentb002fcc169ee9751dd45daf939d6b9a69e44f01a (diff)
DBTAdapter dtor: clear lists explicitly around powerdOff, ensure no leaked resource
Diffstat (limited to 'src/direct_bt')
-rw-r--r--src/direct_bt/DBTAdapter.cpp15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/direct_bt/DBTAdapter.cpp b/src/direct_bt/DBTAdapter.cpp
index 5c802316..cb7f536d 100644
--- a/src/direct_bt/DBTAdapter.cpp
+++ b/src/direct_bt/DBTAdapter.cpp
@@ -239,12 +239,22 @@ DBTAdapter::~DBTAdapter() noexcept {
{
int count = mgmt.removeMgmtEventCallback(dev_id);
DBG_PRINT("DBTAdapter removeMgmtEventCallback(DISCOVERING): %d callbacks", count);
- (void)count;
}
- statusListenerList.clear();
+ {
+ const std::lock_guard<std::recursive_mutex> lock(mtx_statusListenerList); // RAII-style acquire and relinquish via destructor
+ statusListenerList.clear();
+ }
poweredOff();
{
+ const std::lock_guard<std::mutex> lock(mtx_discoveredDevices); // RAII-style acquire and relinquish via destructor
+ discoveredDevices.clear();
+ }
+ {
+ const std::lock_guard<std::mutex> lock(mtx_connectedDevices); // RAII-style acquire and relinquish via destructor
+ connectedDevices.clear();;
+ }
+ {
const std::lock_guard<std::recursive_mutex> lock(mtx_sharedDevices); // RAII-style acquire and relinquish via destructor
sharedDevices.clear();
}
@@ -822,6 +832,7 @@ void DBTAdapter::sendDeviceUpdated(std::string cause, std::shared_ptr<DBTDevice>
}
bool DBTAdapter::mgmtEvDeviceConnectedHCI(std::shared_ptr<MgmtEvent> e) noexcept {
+ COND_PRINT(debug_event, "DBTAdapter::EventCB:DeviceConnected(dev_id %d): %s", dev_id, e->toString().c_str());
const MgmtEvtDeviceConnected &event = *static_cast<const MgmtEvtDeviceConnected *>(e.get());
EInfoReport ad_report;
{