X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fmain.c;h=6bc8b00e914b1d1d6a15c6e82d2e0f520609afcc;hp=41cdf112687c86fc60af8d832b07684dfc4c49bd;hb=622c9ecfa3a7665e2981aaa4881f58afe07106ce;hpb=b1d41407438e92d79fa17cde7f6da0cc559386f9 diff --git a/src/bin/lttng-sessiond/main.c b/src/bin/lttng-sessiond/main.c index 41cdf1126..6bc8b00e9 100644 --- a/src/bin/lttng-sessiond/main.c +++ b/src/bin/lttng-sessiond/main.c @@ -412,6 +412,7 @@ static void cleanup(void) ERR("Unable to clean %s", rundir); } free(cmd); + free(rundir); DBG("Cleaning up all sessions"); @@ -837,6 +838,25 @@ static void *thread_manage_consumer(void *data) DBG("[thread] Manage consumer started"); + /* + * Since the consumer thread can be spawned at any moment in time, we init + * the health to a poll status (1, which is a valid health over time). + * When the thread starts, we update here the health to a "code" path being + * an even value so this thread, when reaching a poll wait, does not + * trigger an error with an even value. + * + * Here is the use case we avoid. + * + * +1: the first poll update during initialization (main()) + * +2 * x: multiple code update once in this thread. + * +1: poll wait in this thread (being a good health state). + * == even number which after the wait period shows as a bad health. + * + * In a nutshell, the following poll update to the health state brings back + * the state to an even value meaning a code path. + */ + health_poll_update(&consumer_data->health); + health_code_update(&consumer_data->health); ret = lttcomm_listen_unix_sock(consumer_data->err_sock); @@ -1172,12 +1192,12 @@ static void *thread_manage_apps(void *data) ust_app_unregister(ust_cmd.sock); } else { /* - * We just need here to monitor the close of the UST - * socket and poll set monitor those by default. - * Listen on POLLIN (even if we never expect any - * data) to ensure that hangup wakes us. + * We only monitor the error events of the socket. This + * thread does not handle any incoming data from UST + * (POLLIN). */ - ret = lttng_poll_add(&events, ust_cmd.sock, LPOLLIN); + ret = lttng_poll_add(&events, ust_cmd.sock, + LPOLLERR & LPOLLHUP & LPOLLRDHUP); if (ret < 0) { goto error; } @@ -2114,7 +2134,7 @@ static int process_client_msg(struct command_ctx *cmd_ctx, int sock, case LTTNG_LIST_DOMAINS: case LTTNG_START_TRACE: case LTTNG_STOP_TRACE: - case LTTNG_DATA_AVAILABLE: + case LTTNG_DATA_PENDING: need_domain = 0; break; default: @@ -2809,9 +2829,9 @@ skip_domain: bytecode); break; } - case LTTNG_DATA_AVAILABLE: + case LTTNG_DATA_PENDING: { - ret = cmd_data_available(cmd_ctx->session); + ret = cmd_data_pending(cmd_ctx->session); break; } default: @@ -3976,7 +3996,9 @@ int main(int argc, char **argv) /* * Init health counters of the consumer thread. We do a quick hack here to * the state of the consumer health is fine even if the thread is not - * started. This is simply to ease our life and has no cost what so ever. + * started. Once the thread starts, the health state is updated with a poll + * value to set a health code path. This is simply to ease our life and has + * no cost what so ever. */ health_init(&kconsumer_data.health); health_poll_update(&kconsumer_data.health); @@ -4073,7 +4095,25 @@ exit_dispatch: goto error; /* join error, exit without cleanup */ } + ret = join_consumer_thread(&ustconsumer32_data); + if (ret != 0) { + PERROR("join_consumer ust32"); + goto error; /* join error, exit without cleanup */ + } + + ret = join_consumer_thread(&ustconsumer64_data); + if (ret != 0) { + PERROR("join_consumer ust64"); + goto error; /* join error, exit without cleanup */ + } + exit_client: + ret = pthread_join(health_thread, &status); + if (ret != 0) { + PERROR("pthread_join health thread"); + goto error; /* join error, exit without cleanup */ + } + exit_health: exit: /*