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

Commit 39da2fb8 authored by Palash Ahuja's avatar Palash Ahuja
Browse files

BluetoothMetrics: LE Connection Metrics: Moving the mutex

up due to race condition

Bug: 278421198
Change-Id: I81a8d0d66c13014924163df98dae76c917da15e9
Test: atest LeImplTest
parent f3122155
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -169,6 +169,8 @@ void LEConnectionMetricsRemoteDevice::AddStateChangedEvent(
        common::ToHexString(transaction_state).c_str(),
        common::ToHexString(connection_type).c_str(),
        common::ToHexString(origin_type).c_str());

  std::unique_lock<std::mutex> lock(le_connection_metrics_remote_device_guard);
  if (address.IsEmpty()) {
    LOG_INFO(
        "LEConnectionMetricsRemoteDevice: Empty Address Cancellation %s, %s, %s\n",
@@ -197,7 +199,6 @@ 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));