Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delay start of dockerd until SD card is available #258

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions app/dockerdwrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,12 @@ static gboolean get_and_verify_tls_selection(AXParameter* param_handle, bool* us
return true;
}

// Meant to be used as a one-shot call from g_timeout_add_seconds()
static gboolean quit_main_loop(void*) {
main_loop_quit();
return FALSE;
}

// Read and verify consistency of settings. Call set_status_parameter() or quit_program() and return
// false on error.
static bool read_settings(struct settings* settings, const struct app_state* app_state) {
Expand Down Expand Up @@ -430,6 +436,15 @@ static bool read_settings(struct settings* settings, const struct app_state* app
return false;
}

// It takes a few seconds from sd_disk_storage_init() until sd_card_callback(), which is when
// app_state->sd_card_area is set. Waiting here means we may avoid failure in the call to
// prepare_data_root() below.
if (is_parameter_yes(param_handle, PARAM_SD_CARD_SUPPORT) && !app_state->sd_card_area) {
int id = g_timeout_add_seconds(5, quit_main_loop, NULL);
g_main_loop_run(loop); // Wait until the timer or sd_card_callback() calls main_loop_quit()
g_source_remove(id); // If it was sd_card_callback(), the timer must not restart dockerd.
}

if (!(settings->data_root = prepare_data_root(param_handle, app_state->sd_card_area)))
return false;

Expand Down Expand Up @@ -679,12 +694,6 @@ static void stop_dockerd(void) {
log_info("Stopped dockerd.");
}

// Meant to be used as a one-shot call from g_timeout_add_seconds()
static gboolean quit_main_loop(void*) {
main_loop_quit();
return FALSE;
}

// Meant to be used as an AXParameter callback
static void restart_dockerd_when_parameter_changed(const gchar* name,
const gchar* value,
Expand Down