X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-relayd%2Fmain.c;h=33aad88ee3e5d0d274790dd4edef675ffeeb06db;hb=bd11e201a9d7e2f2f71a841a6617aa53074b030a;hp=6727a547de65b2a94706a76b5f2089b5b33956a5;hpb=eea7556c652e22165c760a37e1db48595216ee7c;p=lttng-tools.git diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 6727a547d..33aad88ee 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -68,6 +68,8 @@ static struct lttng_uri *live_uri; const char *progname; +const char *tracing_group_name = DEFAULT_TRACING_GROUP; + /* * Quit pipe for all threads. This permits a single cancellation point * for all threads when receiving an event on the pipe. @@ -86,6 +88,7 @@ static int dispatch_thread_exit; static pthread_t listener_thread; static pthread_t dispatcher_thread; static pthread_t worker_thread; +static pthread_t health_thread; static uint64_t last_relay_stream_id; static uint64_t last_relay_session_id; @@ -131,6 +134,7 @@ void usage(void) fprintf(stderr, " -D, --data-port URL Data port listening.\n"); fprintf(stderr, " -o, --output PATH Output path for traces. Must use an absolute path.\n"); fprintf(stderr, " -v, --verbose Verbose mode. Activate DBG() macro.\n"); + fprintf(stderr, " -g, --group NAME Specify the tracing group name. (default: tracing)\n"); } static @@ -144,6 +148,7 @@ int parse_args(int argc, char **argv) { "control-port", 1, 0, 'C', }, { "data-port", 1, 0, 'D', }, { "daemonize", 0, 0, 'd', }, + { "group", 1, 0, 'g', }, { "help", 0, 0, 'h', }, { "output", 1, 0, 'o', }, { "verbose", 0, 0, 'v', }, @@ -152,7 +157,7 @@ int parse_args(int argc, char **argv) while (1) { int option_index = 0; - c = getopt_long(argc, argv, "dhv" "C:D:o:", + c = getopt_long(argc, argv, "dhv" "C:D:o:g:", long_options, &option_index); if (c == -1) { break; @@ -188,6 +193,9 @@ int parse_args(int argc, char **argv) case 'd': opt_daemon = 1; break; + case 'g': + tracing_group_name = optarg; + break; case 'h': usage(); exit(EXIT_FAILURE); @@ -297,6 +305,18 @@ int notify_thread_pipe(int wpipe) return ret; } +static void notify_health_quit_pipe(int *pipe) +{ + int ret; + + do { + ret = write(pipe[1], "4", 1); + } while (ret < 0 && errno == EINTR); + if (ret < 0 || ret != 1) { + PERROR("write relay health quit"); + } +} + /* * Stop all threads by closing the thread quit pipe. */ @@ -312,6 +332,8 @@ void stop_threads(void) ERR("write error on thread quit pipe"); } + notify_health_quit_pipe(health_quit_pipe); + /* Dispatch thread */ CMM_STORE_SHARED(dispatch_thread_exit, 1); futex_nto1_wake(&relay_cmd_queue.futex); @@ -2569,6 +2591,19 @@ int main(int argc, char **argv) goto exit_health_app_create; } + ret = utils_create_pipe(health_quit_pipe); + if (ret < 0) { + goto error_health_pipe; + } + + /* Create thread to manage the client socket */ + ret = pthread_create(&health_thread, NULL, + thread_manage_health, (void *) NULL); + if (ret != 0) { + PERROR("pthread_create health"); + goto health_error; + } + /* Setup the dispatcher thread */ ret = pthread_create(&dispatcher_thread, NULL, relay_thread_dispatcher, (void *) NULL); @@ -2599,8 +2634,6 @@ int main(int argc, char **argv) goto exit_live; } - live_stop_threads(); - exit_live: ret = pthread_join(listener_thread, &status); if (ret != 0) { @@ -2623,6 +2656,21 @@ exit_worker: } exit_dispatcher: + ret = pthread_join(health_thread, &status); + if (ret != 0) { + PERROR("pthread_join health thread"); + goto error; /* join error, exit without cleanup */ + } + + /* + * Stop live threads only after joining other threads. + */ + live_stop_threads(); + +health_error: + utils_close_pipe(health_quit_pipe); + +error_health_pipe: health_app_destroy(health_relayd); exit_health_app_create: