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

Commit d565a80d authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "floss: Properly clean up ACL on disconnect"

parents b0f0bfc2 e00ac7fc
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -297,6 +297,14 @@ void AclManager::SetSecurityModule(security::SecurityModule* security_module) {
  CallOn(pimpl_->classic_impl_, &classic_impl::set_security_module, security_module);
}

void AclManager::OnClassicSuspendInitiatedDisconnect(uint16_t handle, ErrorCode reason) {
  CallOn(pimpl_->classic_impl_, &classic_impl::on_classic_disconnect, handle, reason);
}

void AclManager::OnLeSuspendInitiatedDisconnect(uint16_t handle, ErrorCode reason) {
  CallOn(pimpl_->le_impl_, &le_impl::on_le_disconnect, handle, reason);
}

LeAddressManager* AclManager::GetLeAddressManager() {
  return pimpl_->le_impl_->le_address_manager_;
}
+4 −0
Original line number Diff line number Diff line
@@ -133,6 +133,10 @@ public:

 virtual LeAddressManager* GetLeAddressManager();

 // Virtual ACL disconnect emitted during suspend.
 virtual void OnClassicSuspendInitiatedDisconnect(uint16_t handle, ErrorCode reason);
 virtual void OnLeSuspendInitiatedDisconnect(uint16_t handle, ErrorCode reason);

 static const ModuleFactory Factory;

protected:
+12 −12
Original line number Diff line number Diff line
@@ -862,15 +862,15 @@ struct shim::legacy::Acl::impl {
    }

    // Since this is a suspend disconnect, we immediately also call
    // |OnDisconnection| without waiting for it to happen. We want the stack
    // to clean up ahead of the link layer (since we will mask away that
    // event). The reason we do this in a separate loop is that this will also
    // remove the handle from the connection map.
    // |OnClassicSuspendInitiatedDisconnect| without waiting for it to happen.
    // We want the stack to clean up ahead of the link layer (since we will mask
    // away that event). The reason we do this in a separate loop is that this
    // will also remove the handle from the connection map.
    for (auto& handle : disconnect_handles) {
      auto found = handle_to_classic_connection_map_.find(handle);
      if (found != handle_to_classic_connection_map_.end()) {
        found->second->OnDisconnection(
            hci::ErrorCode::CONNECTION_TERMINATED_BY_LOCAL_HOST);
        GetAclManager()->OnClassicSuspendInitiatedDisconnect(
            found->first, hci::ErrorCode::CONNECTION_TERMINATED_BY_LOCAL_HOST);
      }
    }

@@ -896,15 +896,15 @@ struct shim::legacy::Acl::impl {
    }

    // Since this is a suspend disconnect, we immediately also call
    // |OnDisconnection| without waiting for it to happen. We want the stack
    // to clean up ahead of the link layer (since we will mask away that
    // event). The reason we do this in a separate loop is that this will also
    // remove the handle from the connection map.
    // |OnLeSuspendInitiatedDisconnect| without waiting for it to happen. We
    // want the stack to clean up ahead of the link layer (since we will mask
    // away that event). The reason we do this in a separate loop is that this
    // will also remove the handle from the connection map.
    for (auto& handle : disconnect_handles) {
      auto found = handle_to_le_connection_map_.find(handle);
      if (found != handle_to_le_connection_map_.end()) {
        found->second->OnDisconnection(
            hci::ErrorCode::CONNECTION_TERMINATED_BY_LOCAL_HOST);
        GetAclManager()->OnLeSuspendInitiatedDisconnect(
            found->first, hci::ErrorCode::CONNECTION_TERMINATED_BY_LOCAL_HOST);
      }
    }
    promise.set_value();