Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d835d553 authored by Palash Ahuja's avatar Palash Ahuja
Browse files

[BluetoothMetrics] Adding a mutex for LE Connection Metrics Remote

Device.

There is a possible race condition when a new entry
is added for the same address meanwhile there is a removal of the
same entry when removed from opened_devices.

Bug: b/278421198
Change-Id: I93c059cdca4b3af0811c88390c4832780320d258
parent e2c2f377
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -204,6 +204,7 @@ void LEConnectionMetricsRemoteDevice::AddStateChangedEvent(
    return;
  }

  std::unique_lock<std::mutex> lock(le_connection_metrics_remote_device_guard);
  auto it = opened_devices.find(address);
  if (it == opened_devices.end()) {
    device_metrics.push_back(std::make_unique<LEConnectionMetricState>(address));
+1 −0
Original line number Diff line number Diff line
@@ -104,6 +104,7 @@ class LEConnectionMetricsRemoteDevice {
  void UploadLEConnectionSession(const hci::Address& address);

 private:
  mutable std::mutex le_connection_metrics_remote_device_guard;
  std::vector<std::unique_ptr<LEConnectionMetricState>> device_metrics;
  std::unordered_map<hci::Address, LEConnectionMetricState*> opened_devices;
  BaseMetricsLoggerModule* metrics_logger_module;