X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fmain.c;h=bf7be3e25c77b299e139ce8c46d49e6b8b9bb667;hb=55706a7d35e938a784ca0ccbdb3bb902070d9394;hp=dc41caad031dade163e0353c008c5371edbec7b3;hpb=424150266e9afc978cca8d00f1d70c31f534e656;p=lttng-tools.git diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index dc41caad0..bf7be3e25 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -57,6 +57,7 @@ #include "utils.h" #include "lttng-relayd.h" #include "live.h" +#include "health-relayd.h" /* command line options */ char *opt_output_path; @@ -114,6 +115,9 @@ struct lttng_ht *viewer_streams_ht; /* Global hash table that stores relay index object. */ struct lttng_ht *indexes_ht; +/* Relayd health monitoring */ +static struct health_app *health_relayd; + /* * usage function on stderr */ @@ -513,6 +517,8 @@ void *relay_thread_listener(void *data) DBG("[thread] Relay listener started"); + health_register(health_relayd, HEALTH_RELAYD_TYPE_LISTENER); + control_sock = relay_init_sock(control_uri); if (!control_sock) { goto error_sock_control; @@ -658,6 +664,7 @@ error_sock_control: if (err) { DBG("Thread exited with error"); } + health_unregister(health_relayd); DBG("Relay listener thread cleanup complete"); stop_threads(); return NULL; @@ -675,6 +682,8 @@ void *relay_thread_dispatcher(void *data) DBG("[thread] Relay dispatcher started"); + health_register(health_relayd, HEALTH_RELAYD_TYPE_DISPATCHER); + while (!CMM_LOAD_SHARED(dispatch_thread_exit)) { /* Atomically prepare the queue futex */ futex_nto1_prepare(&relay_cmd_queue.futex); @@ -712,6 +721,7 @@ void *relay_thread_dispatcher(void *data) } error: + health_unregister(health_relayd); DBG("Dispatch thread dying"); stop_threads(); return NULL; @@ -2144,6 +2154,8 @@ void *relay_thread_worker(void *data) rcu_register_thread(); + health_register(health_relayd, HEALTH_RELAYD_TYPE_WORKER); + /* table of connections indexed on socket */ relay_connections_ht = lttng_ht_new(0, LTTNG_HT_TYPE_ULONG); if (!relay_connections_ht) { @@ -2385,6 +2397,7 @@ relay_connections_ht_error: if (err) { DBG("Thread exited with error"); } + health_unregister(health_relayd); DBG("Worker thread cleanup complete"); free(data_buffer); stop_threads(); @@ -2503,6 +2516,13 @@ int main(int argc, char **argv) goto exit_relay_ctx_viewer_streams; } + /* Initialize thread health monitoring */ + health_relayd = health_app_create(NR_HEALTH_RELAYD_TYPES); + if (!health_relayd) { + PERROR("health_app_create error"); + goto exit_health_app_create; + } + /* Setup the dispatcher thread */ ret = pthread_create(&dispatcher_thread, NULL, relay_thread_dispatcher, (void *) NULL); @@ -2530,30 +2550,36 @@ int main(int argc, char **argv) ret = live_start_threads(live_uri, relay_ctx, thread_quit_pipe); if (ret != 0) { ERR("Starting live viewer threads"); + goto exit_live; } -exit_listener: + live_stop_threads(); + +exit_live: ret = pthread_join(listener_thread, &status); if (ret != 0) { PERROR("pthread_join"); goto error; /* join error, exit without cleanup */ } -exit_worker: +exit_listener: ret = pthread_join(worker_thread, &status); if (ret != 0) { PERROR("pthread_join"); goto error; /* join error, exit without cleanup */ } -exit_dispatcher: +exit_worker: ret = pthread_join(dispatcher_thread, &status); if (ret != 0) { PERROR("pthread_join"); goto error; /* join error, exit without cleanup */ } - live_stop_threads(); +exit_dispatcher: + health_app_destroy(health_relayd); + +exit_health_app_create: lttng_ht_destroy(viewer_streams_ht); exit_relay_ctx_viewer_streams: