diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2012-12-12 17:18:15 -0800 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2012-12-12 17:18:15 -0800 |
commit | 689d66b6559dcb3a0ad7f6cc33b6129e50910253 (patch) | |
tree | 0da4b1946b25b966e04569afd01aa992e19fb7bc /stack/btu | |
parent | 3ad3c81926cce0ae789752fbef6aa79ba595ae83 (diff) | |
download | external_bluetooth_bluedroid-689d66b6559dcb3a0ad7f6cc33b6129e50910253.zip external_bluetooth_bluedroid-689d66b6559dcb3a0ad7f6cc33b6129e50910253.tar.gz external_bluetooth_bluedroid-689d66b6559dcb3a0ad7f6cc33b6129e50910253.tar.bz2 |
Snapshot 9fd57cbacd95e89602f430244c35bbc67f08b6d2
Change-Id: Ibc3a4bf4161d286c7cfab89a19c676eb5cc9224f
Diffstat (limited to 'stack/btu')
-rw-r--r-- | stack/btu/btu_hcif.c | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/stack/btu/btu_hcif.c b/stack/btu/btu_hcif.c index 8ca9d35..63803bd 100644 --- a/stack/btu/btu_hcif.c +++ b/stack/btu/btu_hcif.c @@ -54,6 +54,9 @@ #endif // btla-specific -- +//Counter to track number of HCI command timeout +static int num_hci_cmds_timed_out; + /********************************************************************************/ /* L O C A L F U N C T I O N P R O T O T Y P E S */ /********************************************************************************/ @@ -418,6 +421,8 @@ void btu_hcif_process_event (UINT8 controller_id, BT_HDR *p_msg) btm_vendor_specific_evt (p, hci_evt_len); break; } + // reset the num_hci_cmds_timed_out upon receving any event from controller. + num_hci_cmds_timed_out = 0; } @@ -1591,9 +1596,26 @@ void btu_hcif_cmd_timeout (UINT8 controller_id) /* free stored command */ GKI_freebuf(p_cmd); - /* If anyone wants device status notifications, give him one */ - btm_report_device_status (BTM_DEV_STATUS_CMD_TOUT); + num_hci_cmds_timed_out++; + /* When we receive consecutive HCI cmd timeouts for >=BTM_MAX_HCI_CMD_TOUT_BEFORE_RESTART + times, Bluetooth process will be killed and restarted */ + if (num_hci_cmds_timed_out >= BTM_MAX_HCI_CMD_TOUT_BEFORE_RESTART) + { + BT_TRACE_1(TRACE_LAYER_HCI, TRACE_TYPE_ERROR, + "Num consecutive HCI Cmd tout =%d Restarting BT process",num_hci_cmds_timed_out); + usleep(10000); /* 10 milliseconds */ + /* Killing the process to force a restart as part of fault tolerance */ + kill(getpid(), SIGKILL); + } + else + { + BT_TRACE_1 (TRACE_LAYER_HCI, TRACE_TYPE_WARNING, "HCI Cmd timeout counter %d", + num_hci_cmds_timed_out); + + /* If anyone wants device status notifications, give him one */ + btm_report_device_status (BTM_DEV_STATUS_CMD_TOUT); + } /* See if we can forward any more commands */ btu_hcif_send_cmd (controller_id, NULL); } |