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

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

Merge "RoundRobin: Consolidate Unregister and Disconnect"

parents 58f7b1ed 9168bf70
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -112,7 +112,6 @@ struct classic_impl : public DisconnectorForLe, public security::ISecurityManage
  void on_classic_disconnect(uint16_t handle, ErrorCode reason) {
    if (acl_connections_.count(handle) == 1) {
      auto& connection = acl_connections_.find(handle)->second;
      round_robin_scheduler_->SetDisconnect(handle);
      round_robin_scheduler_->Unregister(handle);
      connection.connection_management_callbacks_->OnDisconnection(reason);
      acl_connections_.erase(handle);
+0 −1
Original line number Diff line number Diff line
@@ -92,7 +92,6 @@ struct le_impl {
  void on_le_disconnect(uint16_t handle, ErrorCode reason) {
    if (le_acl_connections_.count(handle) == 1) {
      auto& connection = le_acl_connections_.find(handle)->second;
      round_robin_scheduler_->SetDisconnect(handle);
      round_robin_scheduler_->Unregister(handle);
      connection.le_connection_management_callbacks_->OnDisconnection(reason);
      le_acl_connections_.erase(handle);
+8 −16
Original line number Diff line number Diff line
@@ -42,7 +42,7 @@ RoundRobinScheduler::~RoundRobinScheduler() {

void RoundRobinScheduler::Register(ConnectionType connection_type, uint16_t handle,
                                   std::shared_ptr<acl_manager::AclConnection::Queue> queue) {
  acl_queue_handler acl_queue_handler = {connection_type, std::move(queue), false, 0, false};
  acl_queue_handler acl_queue_handler = {connection_type, std::move(queue), false, 0};
  acl_queue_handlers_.insert(std::pair<uint16_t, RoundRobinScheduler::acl_queue_handler>(handle, acl_queue_handler));
  if (fragments_to_send_.size() == 0) {
    start_round_robin();
@@ -52,17 +52,6 @@ void RoundRobinScheduler::Register(ConnectionType connection_type, uint16_t hand
void RoundRobinScheduler::Unregister(uint16_t handle) {
  ASSERT(acl_queue_handlers_.count(handle) == 1);
  auto acl_queue_handler = acl_queue_handlers_.find(handle)->second;
  if (acl_queue_handler.dequeue_is_registered_) {
    acl_queue_handler.dequeue_is_registered_ = false;
    acl_queue_handler.queue_->GetDownEnd()->UnregisterDequeue();
  }
  acl_queue_handlers_.erase(handle);
  starting_point_ = acl_queue_handlers_.begin();
}

void RoundRobinScheduler::SetDisconnect(uint16_t handle) {
  auto acl_queue_handler = acl_queue_handlers_.find(handle)->second;
  acl_queue_handler.is_disconnected_ = true;
  // Reclaim outstanding packets
  if (acl_queue_handler.connection_type_ == ConnectionType::CLASSIC) {
    acl_packet_credits_ += acl_queue_handler.number_of_sent_packets_;
@@ -70,6 +59,13 @@ void RoundRobinScheduler::SetDisconnect(uint16_t handle) {
    le_acl_packet_credits_ += acl_queue_handler.number_of_sent_packets_;
  }
  acl_queue_handler.number_of_sent_packets_ = 0;

  if (acl_queue_handler.dequeue_is_registered_) {
    acl_queue_handler.dequeue_is_registered_ = false;
    acl_queue_handler.queue_->GetDownEnd()->UnregisterDequeue();
  }
  acl_queue_handlers_.erase(handle);
  starting_point_ = acl_queue_handlers_.begin();
}

uint16_t RoundRobinScheduler::GetCredits() {
@@ -196,10 +192,6 @@ void RoundRobinScheduler::incoming_acl_credits(uint16_t handle, uint16_t credits
    LOG_INFO("Dropping %hx received credits to unknown connection 0x%0hx", credits, handle);
    return;
  }
  if (acl_queue_handler->second.is_disconnected_) {
    LOG_INFO("Dropping %hx received credits to disconnected connection 0x%0hx", credits, handle);
    return;
  }
  acl_queue_handler->second.number_of_sent_packets_ -= credits;
  if (acl_queue_handler->second.connection_type_ == ConnectionType::CLASSIC) {
    acl_packet_credits_ += credits;
+0 −2
Original line number Diff line number Diff line
@@ -41,13 +41,11 @@ class RoundRobinScheduler {
    std::shared_ptr<acl_manager::AclConnection::Queue> queue_;
    bool dequeue_is_registered_ = false;
    uint16_t number_of_sent_packets_ = 0;  // Track credits
    bool is_disconnected_ = false;
  };

  void Register(ConnectionType connection_type, uint16_t handle,
                std::shared_ptr<acl_manager::AclConnection::Queue> queue);
  void Unregister(uint16_t handle);
  void SetDisconnect(uint16_t handle);
  uint16_t GetCredits();
  uint16_t GetLeCredits();