Now the OSI module's shut_down processing is split into "shut_down"
and "clean_up".
Previously, there was an ordering issue manipulating some of the
internal state during graceful shutdown/cleanup. Some of the modules
had two steps: shut_down, followed by clean_up, while other had only
shut_down step. This triggered the following assert in file alarm.c
alarm_cancel: assertion "alarms != NULL" failed
Bug:
21406940
Change-Id: Iab1f033a69cbff646a6b0f346760ae82f8b00b8f
return NULL;
}
+future_t *osi_clean_up(void) {
+ alarm_cleanup();
+ return NULL;
+}
+
const module_t osi_module = {
.name = OSI_MODULE,
.init = NULL,
.start_up = osi_start_up,
.shut_down = osi_shut_down,
- .clean_up = NULL,
+ .clean_up = osi_clean_up,
.dependencies = {NULL}
};
btif_shutdown_bluetooth();
module_clean_up(get_module(BTIF_CONFIG_MODULE));
+ module_clean_up(get_module(OSI_MODULE));
module_clean_up(get_module(BT_UTILS_MODULE));
future_await(hack_future);
// Shuts down the alarm dispatch callback. To be called during module/stack
// shutdown only.
void alarm_shutdown(void);
+
+// Alarm-related state cleanup
+void alarm_cleanup(void);
semaphore_free(alarm_expired);
alarm_expired = NULL;
timer_delete(&timer);
+}
+
+void alarm_cleanup(void) {
+ // If lazy_initialize never ran there is nothing to do
+ if (!alarms)
+ return;
list_free(alarms);
alarms = NULL;
void AlarmTestHarness::TearDown() {
alarm_shutdown();
+ alarm_cleanup();
timer_delete(timer);
AllocationTestHarness::TearDown();
}