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

Commit f5e5963b authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi
Browse files

floss: Re-order AclManager Start/Stop

We need to initialize classic_impl and le_impl before we register for
Dequeue. Otherwise, we may attempt to access those impls before they are
ready. Similarly, unregister before cleaning up the impls for the same
reason.

Bug: 259585527
Tag: #floss
Test: ChromeOS basic autotest
Change-Id: I6f23ac785949dc332ec72a6bfa49b91ae833e41a
parent 88585ad5
Loading
Loading
Loading
Loading
+9 −7
Original line number Original line Diff line number Diff line
@@ -65,9 +65,6 @@ struct AclManager::impl {
    round_robin_scheduler_ = new RoundRobinScheduler(handler_, controller_, hci_layer_->GetAclQueueEnd());
    round_robin_scheduler_ = new RoundRobinScheduler(handler_, controller_, hci_layer_->GetAclQueueEnd());
    acl_scheduler_ = acl_manager_.GetDependency<AclScheduler>();
    acl_scheduler_ = acl_manager_.GetDependency<AclScheduler>();


    hci_queue_end_ = hci_layer_->GetAclQueueEnd();
    hci_queue_end_->RegisterDequeue(
        handler_, common::Bind(&impl::dequeue_and_route_acl_packet_to_connection, common::Unretained(this)));
    bool crash_on_unknown_handle = false;
    bool crash_on_unknown_handle = false;
    {
    {
      const std::lock_guard<std::mutex> lock(dumpsys_mutex_);
      const std::lock_guard<std::mutex> lock(dumpsys_mutex_);
@@ -75,9 +72,18 @@ struct AclManager::impl {
          hci_layer_, controller_, handler_, round_robin_scheduler_, crash_on_unknown_handle, acl_scheduler_);
          hci_layer_, controller_, handler_, round_robin_scheduler_, crash_on_unknown_handle, acl_scheduler_);
      le_impl_ = new le_impl(hci_layer_, controller_, handler_, round_robin_scheduler_, crash_on_unknown_handle);
      le_impl_ = new le_impl(hci_layer_, controller_, handler_, round_robin_scheduler_, crash_on_unknown_handle);
    }
    }

    hci_queue_end_ = hci_layer_->GetAclQueueEnd();
    hci_queue_end_->RegisterDequeue(
        handler_, common::Bind(&impl::dequeue_and_route_acl_packet_to_connection, common::Unretained(this)));
  }
  }


  void Stop() {
  void Stop() {
    hci_queue_end_->UnregisterDequeue();
    if (enqueue_registered_.exchange(false)) {
      hci_queue_end_->UnregisterEnqueue();
    }

    {
    {
      const std::lock_guard<std::mutex> lock(dumpsys_mutex_);
      const std::lock_guard<std::mutex> lock(dumpsys_mutex_);
      delete le_impl_;
      delete le_impl_;
@@ -86,11 +92,7 @@ struct AclManager::impl {
      classic_impl_ = nullptr;
      classic_impl_ = nullptr;
    }
    }


    hci_queue_end_->UnregisterDequeue();
    delete round_robin_scheduler_;
    delete round_robin_scheduler_;
    if (enqueue_registered_.exchange(false)) {
      hci_queue_end_->UnregisterEnqueue();
    }
    hci_queue_end_ = nullptr;
    hci_queue_end_ = nullptr;
    handler_ = nullptr;
    handler_ = nullptr;
    hci_layer_ = nullptr;
    hci_layer_ = nullptr;