summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAjay Kumar <ajayku@codeaurora.org>2015-11-25 12:22:46 +0530
committerGerrit - the friendly Code Review server <code-review@localhost>2015-12-27 23:10:24 -0800
commite65809c52d08ac0b109efc734940501867e4f3a9 (patch)
treef6f125429a2db26c79372ba7121810684bd9aa36
parent203f378ab1aca3b17ebb5415361ead0a5ae2af86 (diff)
downloadandroid_system_bt-e65809c52d08ac0b109efc734940501867e4f3a9.tar.gz
android_system_bt-e65809c52d08ac0b109efc734940501867e4f3a9.tar.bz2
android_system_bt-e65809c52d08ac0b109efc734940501867e4f3a9.zip
Bluetooth: Fix module cleanup
if module does not start fully its state will either NONE OR INITIALIZED. While module_shut_down if module state is not STARTED, it will exit without shutting underlying layers which will give issues or ASSERT in next cleanup. In this specific issue hci module stucks in USERIAL_OPEN and startup timer expires and module exits with the error. Since there is no error check on hci module fail it goes ahead and enables BT(that might give issues later) but fails to cleanup and does not call USERIAL_CLOSE while hci module_shut_down as part of disable.Now this will ASSERT in next enable as USERIAL lib handle is not NULL. even if we call module_shut_down that is not going to help as it will exit without calling lifecycle function :shutdown. Adding module error state will solve the issue CRs-Fixed: 939575 Change-Id: I0f448eb438881a9df46d07eab44d809bae740ab5
-rw-r--r--btcore/src/module.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/btcore/src/module.c b/btcore/src/module.c
index 745a36893..700301d77 100644
--- a/btcore/src/module.c
+++ b/btcore/src/module.c
@@ -33,7 +33,8 @@
typedef enum {
MODULE_STATE_NONE = 0,
MODULE_STATE_INITIALIZED = 1,
- MODULE_STATE_STARTED = 2
+ MODULE_STATE_STARTED = 2,
+ MODULE_STATE_STARTUP_ERROR = 3
} module_state_t;
static const size_t number_of_metadata_buckets = 42;
@@ -97,6 +98,7 @@ bool module_start_up(const module_t *module) {
if (!call_lifecycle_function(module->start_up)) {
LOG_ERROR("%s failed to start up \"%s\"", __func__, module->name);
+ set_module_state(module, MODULE_STATE_STARTUP_ERROR);
return false;
}
@@ -108,7 +110,6 @@ void module_shut_down(const module_t *module) {
assert(metadata != NULL);
assert(module != NULL);
module_state_t state = get_module_state(module);
- assert(state <= MODULE_STATE_STARTED);
// Only something to do if the module was actually started
if (state < MODULE_STATE_STARTED)