Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6823da27 authored by Pavlin Radoslavov's avatar Pavlin Radoslavov
Browse files

Add missing clean_up step for the OSI module.

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
parent a56cc929
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -34,11 +34,16 @@ future_t *osi_shut_down(void) {
  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}
};
+1 −0
Original line number Diff line number Diff line
@@ -186,6 +186,7 @@ static void event_clean_up_stack(UNUSED_ATTR void *context) {

  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);
+3 −0
Original line number Diff line number Diff line
@@ -55,3 +55,6 @@ void alarm_cancel(alarm_t *alarm);
// 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);
+6 −0
Original line number Diff line number Diff line
@@ -190,6 +190,12 @@ void alarm_shutdown(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;
+1 −0
Original line number Diff line number Diff line
@@ -53,6 +53,7 @@ void AlarmTestHarness::SetUp() {

void AlarmTestHarness::TearDown() {
  alarm_shutdown();
  alarm_cleanup();
  timer_delete(timer);
  AllocationTestHarness::TearDown();
}