fm: Initialize variables after fm_hal service connection
Initialize variables after fm_hal_service connection. In subsequent FM on,
if hal init happens before threads exits in previous FM off, there might be
race condition , because of which lib_running variable sets to 0 even if
init happens. This will lead to FM failure as all threads exits as
soon as created.
Change-Id: I2e61cc7ebb935c0b31c575aed60ead1424d23eb7
diff --git a/fm_hci/fm_hci.c b/fm_hci/fm_hci.c
index d509395..e0d437a 100644
--- a/fm_hci/fm_hci.c
+++ b/fm_hci/fm_hci.c
@@ -704,11 +704,6 @@
}
memset(hci, 0, sizeof(struct fm_hci_t));
- lib_running = 1;
- ready_events = 0;
- hci->command_credits = 1;
- hci->fd = -1;
-
pthread_mutex_init(&hci->tx_q_lock, NULL);
pthread_mutex_init(&hci->credit_lock, NULL);
pthread_mutex_init(&hci->event_lock, NULL);
@@ -724,6 +719,11 @@
}
ALOGI("fm_hal_fd = %d", fm_hal_fd);
+ lib_running = 1;
+ ready_events = 0;
+ hci->command_credits = 1;
+ hci->fd = -1;
+
ret = vendor_init(hci);
if (ret)
goto err_vendor;