The relay daemons's initialization and teardown relies on a large
number of goto/labels to clean-up on failure to launch.
All of the clean-up can be performed unconditionally by checking for
NULL or uninitialized file descriptors in relayd_cleanup(). This
reduces the number of possible tear-down paths and partly initialized
state to keep track of.
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I3195caf05b3dd04cc7e9c60dcb322261159fe0df
static
char health_unix_sock_path[PATH_MAX];
static
char health_unix_sock_path[PATH_MAX];
-int health_quit_pipe[2];
+int health_quit_pipe[2] = { -1, -1 };
/*
* Check if the thread quit pipe was triggered.
/*
* Check if the thread quit pipe was triggered.
free(opt_output_path);
free(opt_working_directory);
free(opt_output_path);
free(opt_working_directory);
+ if (health_relayd) {
+ health_app_destroy(health_relayd);
+ }
/* Close thread quit pipes */
/* Close thread quit pipes */
+ utils_close_pipe(health_quit_pipe);
utils_close_pipe(thread_quit_pipe);
utils_close_pipe(thread_quit_pipe);
+ if (sessiond_trace_chunk_registry) {
+ sessiond_trace_chunk_registry_destroy(
+ sessiond_trace_chunk_registry);
+ }
+
uri_free(control_uri);
uri_free(data_uri);
/* Live URI is freed in the live thread. */
uri_free(control_uri);
uri_free(data_uri);
/* Live URI is freed in the live thread. */
if (!sessiond_trace_chunk_registry) {
ERR("Failed to initialize session daemon trace chunk registry");
retval = -1;
if (!sessiond_trace_chunk_registry) {
ERR("Failed to initialize session daemon trace chunk registry");
retval = -1;
- goto exit_sessiond_trace_chunk_registry;
}
/* Initialize thread health monitoring */
}
/* Initialize thread health monitoring */
if (!health_relayd) {
PERROR("health_app_create error");
retval = -1;
if (!health_relayd) {
PERROR("health_app_create error");
retval = -1;
- goto exit_health_app_create;
}
/* Create thread quit pipe */
if (init_thread_quit_pipe()) {
retval = -1;
}
/* Create thread quit pipe */
if (init_thread_quit_pipe()) {
retval = -1;
}
/* Setup the thread apps communication pipe. */
if (create_relay_conn_pipe()) {
retval = -1;
}
/* Setup the thread apps communication pipe. */
if (create_relay_conn_pipe()) {
retval = -1;
}
/* Init relay command queue. */
}
/* Init relay command queue. */
sessions_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!sessions_ht) {
retval = -1;
sessions_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!sessions_ht) {
retval = -1;
}
/* tables of streams indexed by stream ID */
relay_streams_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!relay_streams_ht) {
retval = -1;
}
/* tables of streams indexed by stream ID */
relay_streams_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!relay_streams_ht) {
retval = -1;
}
/* tables of streams indexed by stream ID */
viewer_streams_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!viewer_streams_ht) {
retval = -1;
}
/* tables of streams indexed by stream ID */
viewer_streams_ht = lttng_ht_new(0, LTTNG_HT_TYPE_U64);
if (!viewer_streams_ht) {
retval = -1;
}
ret = utils_create_pipe(health_quit_pipe);
if (ret) {
retval = -1;
}
ret = utils_create_pipe(health_quit_pipe);
if (ret) {
retval = -1;
- goto exit_health_quit_pipe;
}
/* Create thread to manage the client socket */
}
/* Create thread to manage the client socket */
errno = ret;
PERROR("pthread_create health");
retval = -1;
errno = ret;
PERROR("pthread_create health");
retval = -1;
- goto exit_health_thread;
}
/* Setup the dispatcher thread */
}
/* Setup the dispatcher thread */
PERROR("pthread_join health_thread");
retval = -1;
}
PERROR("pthread_join health_thread");
retval = -1;
}
-exit_health_thread:
-
- utils_close_pipe(health_quit_pipe);
-exit_health_quit_pipe:
-
-exit_init_data:
- health_app_destroy(health_relayd);
- sessiond_trace_chunk_registry_destroy(sessiond_trace_chunk_registry);
-exit_health_app_create:
-exit_sessiond_trace_chunk_registry:
exit_options:
/*
* Wait for all pending call_rcu work to complete before tearing
exit_options:
/*
* Wait for all pending call_rcu work to complete before tearing