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.
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;
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
{ "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', },
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;
case 'd':
opt_daemon = 1;
break;
+ case 'g':
+ tracing_group_name = optarg;
+ break;
case 'h':
usage();
exit(EXIT_FAILURE);
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.
*/
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);
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);
}
exit_dispatcher:
+ ret = pthread_join(health_thread, &status);
+ if (ret != 0) {
+ PERROR("pthread_join health thread");
+ goto error; /* join error, exit without cleanup */
+ }
+
+health_error:
+ utils_close_pipe(health_quit_pipe);
+
+error_health_pipe:
health_app_destroy(health_relayd);
exit_health_app_create: