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

Commit fc61190e authored by Wang Fei's avatar Wang Fei
Browse files

Use ACL handle to find element to deal with packet

We encountered that when executing the buffer_packet,
but the ACL connection had been removed. So It will
lead to a crash.

Then we can use ACL handle to find the detail ACL handler
to deal with the ACL packet. Even if the ACL connection
vanished, then just ignore the detail packet handling because
the connection vanished.

Bug: 251764426
Test: Restart bluetooth, connect to other remote device,
      then watch if it running OK

Change-Id: Ic578d41ae80ec6a254a42759081dcd115cf1990b
parent af09ff0d
Loading
Loading
Loading
Loading
+9 −2
Original line number Diff line number Diff line
@@ -117,8 +117,9 @@ void RoundRobinScheduler::start_round_robin() {
        le_acl_packet_credits_ == 0 && acl_queue_handler->second.connection_type_ == ConnectionType::LE;
    if (!acl_queue_handler->second.dequeue_is_registered_ && !classic_buffer_full && !le_buffer_full) {
      acl_queue_handler->second.dequeue_is_registered_ = true;
      uint16_t acl_handle = acl_queue_handler->first;
      acl_queue_handler->second.queue_->GetDownEnd()->RegisterDequeue(
          handler_, common::Bind(&RoundRobinScheduler::buffer_packet, common::Unretained(this), acl_queue_handler));
          handler_, common::Bind(&RoundRobinScheduler::buffer_packet, common::Unretained(this), acl_handle));
    }
    acl_queue_handler = std::next(acl_queue_handler);
    if (acl_queue_handler == acl_queue_handlers_.end()) {
@@ -129,8 +130,14 @@ void RoundRobinScheduler::start_round_robin() {
  starting_point_ = std::next(starting_point_);
}

void RoundRobinScheduler::buffer_packet(std::map<uint16_t, acl_queue_handler>::iterator acl_queue_handler) {
void RoundRobinScheduler::buffer_packet(uint16_t acl_handle) {
  BroadcastFlag broadcast_flag = BroadcastFlag::POINT_TO_POINT;
  auto acl_queue_handler = acl_queue_handlers_.find(acl_handle);
  if( acl_queue_handler == acl_queue_handlers_.end()) {
    LOG_ERROR("Ignore since ACL connection vanished with handle: 0x%X", acl_handle);
    return;
  }

  // Wrap packet and enqueue it
  uint16_t handle = acl_queue_handler->first;
  auto packet = acl_queue_handler->second.queue_->GetDownEnd()->TryDequeue();
+1 −1
Original line number Diff line number Diff line
@@ -54,7 +54,7 @@ class RoundRobinScheduler {

 private:
  void start_round_robin();
  void buffer_packet(std::map<uint16_t, acl_queue_handler>::iterator acl_queue_handler);
  void buffer_packet(uint16_t acl_handle);
  void unregister_all_connections();
  void send_next_fragment();
  std::unique_ptr<AclBuilder> handle_enqueue_next_fragment();