summaryrefslogtreecommitdiffstats
path: root/hci
diff options
context:
space:
mode:
authorLuke Zhang <lukez@codeaurora.org>2015-10-20 13:33:49 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2015-10-20 13:37:09 -0700
commitaafbaf8e5fac2f1dad163049e14f91302b525a9f (patch)
tree9464026fa7f75fa00f67a56be4badefaa8d32c46 /hci
parent06a96fa5065087c20e937f382981d2dcc376fb7b (diff)
downloadandroid_system_bt-aafbaf8e5fac2f1dad163049e14f91302b525a9f.tar.gz
android_system_bt-aafbaf8e5fac2f1dad163049e14f91302b525a9f.tar.bz2
android_system_bt-aafbaf8e5fac2f1dad163049e14f91302b525a9f.zip
Fixed the problem that HCI command times out even without pending
command. Start the hci timer before sending out the HCI command, and protect the pending command queue with mutex. Also we set the length of the list as volatile. In this way, we can prevent the intervention between hci TX and RX threads. Change-Id: I8d2bcdb636b503344f173d3f8255f5a29b30aadb CRs-fixed: 926763
Diffstat (limited to 'hci')
-rw-r--r--hci/src/hci_layer.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/hci/src/hci_layer.c b/hci/src/hci_layer.c
index fb2bb972e..fa65e6e02 100644
--- a/hci/src/hci_layer.c
+++ b/hci/src/hci_layer.c
@@ -464,14 +464,14 @@ static void event_command_ready(fixed_queue_t *queue, UNUSED_ATTR void *context)
// Move it to the list of commands awaiting response
pthread_mutex_lock(&commands_pending_response_lock);
list_append(commands_pending_response, wait_entry);
+
+ non_repeating_timer_restart_if(command_response_timer, !list_is_empty(commands_pending_response));
pthread_mutex_unlock(&commands_pending_response_lock);
// Send it off
low_power_manager->wake_assert();
packet_fragmenter->fragment_and_dispatch(wait_entry->command);
low_power_manager->transmit_done();
-
- non_repeating_timer_restart_if(command_response_timer, !list_is_empty(commands_pending_response));
}
}
@@ -709,7 +709,9 @@ static bool filter_incoming_event(BT_HDR *packet) {
return false;
intercepted:;
+ pthread_mutex_lock(&commands_pending_response_lock);
non_repeating_timer_restart_if(command_response_timer, !list_is_empty(commands_pending_response));
+ pthread_mutex_unlock(&commands_pending_response_lock);
if (wait_entry) {
// If it has a callback, it's responsible for freeing the packet