X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fconsumer.c;h=5f87f4b5018fbec1a2de542797f46b4f6d17475f;hp=29bd0c00c56d95c91a71f031697faa404a6ec7ad;hb=331744e34f56a5aec69b05d356d6901e67926acc;hpb=31fa4745f181bd1bdbceb89fbe27e130f5b4e2b9 diff --git a/src/common/consumer.c b/src/common/consumer.c index 29bd0c00c..5f87f4b50 100644 --- a/src/common/consumer.c +++ b/src/common/consumer.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -1141,6 +1142,7 @@ struct lttng_consumer_local_data *lttng_consumer_create( } ctx->consumer_error_socket = -1; + ctx->consumer_metadata_socket = -1; /* assign the callbacks */ ctx->on_buffer_ready = buffer_ready; ctx->on_recv_channel = recv_channel; @@ -1227,6 +1229,10 @@ void lttng_consumer_destroy(struct lttng_consumer_local_data *ctx) if (ret) { PERROR("close"); } + ret = close(ctx->consumer_metadata_socket); + if (ret) { + PERROR("close"); + } utils_close_pipe(ctx->consumer_thread_pipe); utils_close_pipe(ctx->consumer_channel_pipe); utils_close_pipe(ctx->consumer_data_pipe); @@ -1328,6 +1334,7 @@ ssize_t lttng_consumer_on_read_subbuffer_mmap( goto end; } ret = lttng_ustctl_get_mmap_read_offset(stream, &mmap_offset); + break; default: ERR("Unknown consumer_data type"); @@ -2707,6 +2714,33 @@ end_ht: return NULL; } +static int set_metadata_socket(struct lttng_consumer_local_data *ctx, + struct pollfd *sockpoll, int client_socket) +{ + int ret; + + assert(ctx); + assert(sockpoll); + + if (lttng_consumer_poll_socket(sockpoll) < 0) { + ret = -1; + goto error; + } + DBG("Metadata connection on client_socket"); + + /* Blocking call, waiting for transmission */ + ctx->consumer_metadata_socket = lttcomm_accept_unix_sock(client_socket); + if (ctx->consumer_metadata_socket < 0) { + WARN("On accept metadata"); + ret = -1; + goto error; + } + ret = 0; + +error: + return ret; +} + /* * This thread listens on the consumerd socket and receives the file * descriptors from the session daemon. @@ -2773,6 +2807,15 @@ void *consumer_thread_sessiond_poll(void *data) goto end; } + /* + * Setup metadata socket which is the second socket connection on the + * command unix socket. + */ + ret = set_metadata_socket(ctx, consumer_sockpoll, client_socket); + if (ret < 0) { + goto end; + } + /* This socket is not useful anymore. */ ret = close(client_socket); if (ret < 0) {