Skip to content

Commit be39db5

Browse files
Include settings struct in app_state
Allow settings to be taken into consideration when changing application state.
1 parent a3b2204 commit be39db5

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

app/dockerdwrapper.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ struct app_state {
7676
volatile int allow_dockerd_to_start_atomic;
7777
char* sd_card_area;
7878
AXParameter* param_handle;
79+
struct settings settings;
7980
};
8081

8182
static bool dockerd_allowed_to_start(const struct app_state* app_state) {
@@ -400,8 +401,10 @@ static gboolean get_and_verify_tls_selection(AXParameter* param_handle, bool* us
400401

401402
// Read and verify consistency of settings. Call set_status_parameter() or quit_program() and return
402403
// false on error.
403-
static bool read_settings(struct settings* settings, const struct app_state* app_state) {
404+
static bool read_settings(struct app_state* app_state) {
404405
AXParameter* param_handle = app_state->param_handle;
406+
struct settings* settings = &app_state->settings;
407+
405408
settings->use_tcp_socket = is_parameter_yes(param_handle, PARAM_TCP_SOCKET);
406409

407410
if (!settings->use_tcp_socket)
@@ -545,8 +548,9 @@ static const char* build_daemon_args(const struct settings* settings, AXParamete
545548

546549
// Start dockerd. On success, call set_status_parameter(STATUS_RUNNING) and on error,
547550
// call set_status_parameter(STATUS_NOT_STARTED).
548-
static bool start_dockerd(const struct settings* settings, struct app_state* app_state) {
551+
static bool start_dockerd(struct app_state* app_state) {
549552
AXParameter* param_handle = app_state->param_handle;
553+
const struct settings* settings = &app_state->settings;
550554
GError* error = NULL;
551555
bool result = false;
552556
bool return_value = false;
@@ -585,12 +589,8 @@ static bool start_dockerd(const struct settings* settings, struct app_state* app
585589
}
586590

587591
static void read_settings_and_start_dockerd(struct app_state* app_state) {
588-
struct settings settings = {0};
589-
590-
if (read_settings(&settings, app_state))
591-
start_dockerd(&settings, app_state);
592-
593-
free(settings.data_root);
592+
if (read_settings(app_state))
593+
start_dockerd(app_state);
594594
}
595595

596596
static bool send_signal(const char* name, GPid pid, int sig) {
@@ -880,6 +880,7 @@ int main(int argc, char** argv) {
880880
}
881881

882882
sd_disk_storage_free(sd_disk_storage);
883+
free(app_state.settings.data_root);
883884
free(app_state.sd_card_area);
884885

885886
return application_exit_code;

0 commit comments

Comments
 (0)