diff --git a/src/xrt/ipc/server/ipc_server_process.c b/src/xrt/ipc/server/ipc_server_process.c index 1ffcdc2d3..b69b67ea2 100644 --- a/src/xrt/ipc/server/ipc_server_process.c +++ b/src/xrt/ipc/server/ipc_server_process.c @@ -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");