hci: Cancel timer before running callbacks
Bug: 36507488
Test: Turn Bluetooth on/off, scan for devices
Change-Id: Ia9334d83b2191504acdab50f777b6d10073226e0
diff --git a/hci/src/hci_layer.cc b/hci/src/hci_layer.cc
index 9ac3b70..f898980 100644
--- a/hci/src/hci_layer.cc
+++ b/hci/src/hci_layer.cc
@@ -440,10 +440,13 @@
"0x%04x).",
__func__, opcode);
}
- } else 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);
+ } 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;
@@ -457,14 +460,17 @@
// 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)
- wait_entry->status_callback(status, wait_entry->command,
- wait_entry->context);
+ } 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 @@
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 ||