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

Commit 1e200765 authored by Myles Watson's avatar Myles Watson
Browse files

hci: Cancel timer before running callbacks

Bug: 36507488
Test: Turn Bluetooth on/off, scan for devices
Change-Id: Ia9334d83b2191504acdab50f777b6d10073226e0
parent 73333583
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -440,11 +440,14 @@ static bool filter_incoming_event(BT_HDR* packet) {
                 "0x%04x).",
                 __func__, opcode);
      }
    } else if (wait_entry->complete_callback) {
    } else {
      update_command_response_timer();
      if (wait_entry->complete_callback) {
        wait_entry->complete_callback(packet, wait_entry->context);
      } else if (wait_entry->complete_future) {
        future_ready(wait_entry->complete_future, packet);
      }
    }

    goto intercepted;
  } else if (event_code == HCI_COMMAND_STATUS_EVT) {
@@ -457,14 +460,17 @@ static bool filter_incoming_event(BT_HDR* packet) {
    // command complete event

    wait_entry = get_waiting_command(opcode);
    if (!wait_entry)
    if (!wait_entry) {
      LOG_WARN(
          LOG_TAG,
          "%s command status event with no matching command. opcode: 0x%04x",
          __func__, opcode);
    else if (wait_entry->status_callback)
    } else {
      update_command_response_timer();
      if (wait_entry->status_callback)
        wait_entry->status_callback(status, wait_entry->command,
                                    wait_entry->context);
    }

    goto intercepted;
  }
@@ -472,8 +478,6 @@ static bool filter_incoming_event(BT_HDR* packet) {
  return false;

intercepted:
  update_command_response_timer();

  if (wait_entry) {
    // If it has a callback, it's responsible for freeing the packet
    if (event_code == HCI_COMMAND_STATUS_EVT ||