Fix race conditions with bluetooth devices being erased while being used.

This commit is contained in:
Vibhav Pant
2023-09-26 18:34:56 +05:30
parent b4bd7ddbb8
commit 97af86a414
10 changed files with 135 additions and 157 deletions
@@ -90,7 +90,9 @@ std::shared_ptr<MonitoredBluetoothDevice> BluetoothDevices::add_new_device(
auto [device_it, inserted] = devices_by_path_.emplace(
std::string(device_object_path),
std::make_shared<MonitoredBluetoothDevice>(
system_bus_, std::move(device_object_path), observers_));
system_bus_,
std::make_shared<bluez::Device>(system_bus_, device_object_path),
observers_));
if (!inserted) device_it->second->UnmarkLost();
return device_it->second;
}