ipc: Change init order to avoid assertion

This commit is contained in:
Jarvis Huang 2022-12-27 18:24:44 +08:00 committed by Jakob Bornecrantz
parent cd163e366b
commit aa6b8cd88d

View file

@ -148,8 +148,9 @@ teardown_all(struct ipc_server *s)
ipc_server_mainloop_deinit(&s->ml);
os_mutex_destroy(&s->global_state.lock);
u_process_destroy(s->process);
os_mutex_destroy(&s->global_state.lock);
}
static int
@ -450,6 +451,13 @@ init_all(struct ipc_server *s)
xrt_result_t xret;
int ret;
ret = os_mutex_init(&s->global_state.lock);
if (ret < 0) {
IPC_ERROR(s, "Global state lock mutex failed to init!");
teardown_all(s);
return ret;
}
s->process = u_process_create_if_not_running();
if (!s->process) {
@ -505,13 +513,6 @@ init_all(struct ipc_server *s)
return ret;
}
ret = os_mutex_init(&s->global_state.lock);
if (ret < 0) {
IPC_ERROR(s, "Global state lock mutex failed to inti!");
teardown_all(s);
return ret;
}
u_var_add_root(s, "IPC Server", false);
u_var_add_log_level(s, &s->log_level, "Log level");
u_var_add_bool(s, &s->exit_on_disconnect, "exit_on_disconnect");