OSDN Git Service

a race condition which can cause potential BT preload timeout.
authorZhihai Xu <zhihaixu@google.com>
Wed, 15 Jan 2014 18:28:55 +0000 (10:28 -0800)
committerZhihai Xu <zhihaixu@google.com>
Wed, 15 Jan 2014 18:28:55 +0000 (10:28 -0800)
a race condition which can cause potential BT preload timeout,
When BT startup, bt_hc_worker thread will send BT_EVT_PRELOAD_CMPL
to btu_task. However in bte_main_enable, it first calls
bte_hci_enable(), then creates btu_task. So it may send BT_EVT_PRELOAD_CMPL
before btu_task created. Change creating btu_task before call bte_hci_enable
to make sure btu_task already created successfully before send
BT_EVT_PRELOAD_CMPL.
If this race condition happen, the bluetooth will not be turned on.

bug:12566357
Change-Id: I245d2df90da0f9da324fc31e371dde8539c0926c

main/bte_main.c

index 62c6b6b..2ce4451 100644 (file)
@@ -197,12 +197,12 @@ void bte_main_enable()
 
     lpm_enabled = FALSE;
 
-    bte_hci_enable();
-
     GKI_create_task((TASKPTR)btu_task, BTU_TASK, BTE_BTU_TASK_STR,
                     (UINT16 *) ((UINT8 *)bte_btu_stack + BTE_BTU_STACK_SIZE),
                     sizeof(bte_btu_stack));
 
+    bte_hci_enable();
+
     GKI_run(0);
 }