X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-consumer.c;h=611b54dcdb17d392f14bd42dc98320a0cb098b61;hp=2eb8cda253a096c89f03d0e7cfd6bd869ed675f2;hb=90e7d72ff2b93752b8c81c49e9251a83b01703c6;hpb=4ce514c43483ba24fd935024da5b7aca681a7e52 diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index 2eb8cda25..611b54dcd 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -16,6 +16,7 @@ */ #define _GNU_SOURCE +#define _LGPL_SOURCE #include #include #include @@ -28,7 +29,7 @@ #include #include "consumer.h" -#include "health.h" +#include "health-sessiond.h" #include "ust-consumer.h" #include "buffer-registry.h" #include "session.h" @@ -102,7 +103,7 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, struct ust_app_channel *ua_chan, struct consumer_output *consumer, struct consumer_socket *socket, struct ust_registry_session *registry) { - int ret; + int ret, output; uint32_t chan_id; uint64_t key, chan_reg_key; char *pathname = NULL; @@ -141,13 +142,21 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, chan_id = chan_reg->chan_id; } + switch (ua_chan->attr.output) { + case LTTNG_UST_MMAP: + default: + output = LTTNG_EVENT_MMAP; + break; + } + consumer_init_ask_channel_comm_msg(&msg, ua_chan->attr.subbuf_size, ua_chan->attr.num_subbuf, ua_chan->attr.overwrite, ua_chan->attr.switch_timer_interval, ua_chan->attr.read_timer_interval, - (int) ua_chan->attr.output, + ua_sess->live_timer_interval, + output, (int) ua_chan->attr.type, ua_sess->tracing_id, pathname, @@ -166,7 +175,7 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, health_code_update(); - ret = lttcomm_send_unix_sock(*socket->fd, &msg, sizeof(msg)); + ret = consumer_socket_send(socket, &msg, sizeof(msg)); if (ret < 0) { goto error; } @@ -207,7 +216,6 @@ int ust_consumer_ask_channel(struct ust_app_session *ua_sess, assert(ua_chan); assert(consumer); assert(socket); - assert(socket->fd); assert(registry); if (!consumer->enabled) { @@ -242,8 +250,8 @@ int ust_consumer_get_channel(struct consumer_socket *socket, assert(ua_chan); assert(socket); - assert(socket->fd); + memset(&msg, 0, sizeof(msg)); msg.cmd_type = LTTNG_CONSUMER_GET_CHANNEL; msg.u.get_channel.key = ua_chan->key; @@ -257,11 +265,11 @@ int ust_consumer_get_channel(struct consumer_socket *socket, } /* First, get the channel from consumer. */ - ret = ustctl_recv_channel_from_consumer(*socket->fd, &ua_chan->obj); + ret = ustctl_recv_channel_from_consumer(*socket->fd_ptr, &ua_chan->obj); if (ret < 0) { if (ret != -EPIPE) { ERR("Error recv channel from consumer %d with ret %d", - *socket->fd, ret); + *socket->fd_ptr, ret); } else { DBG3("UST app recv channel from consumer. Consumer is dead."); } @@ -280,7 +288,7 @@ int ust_consumer_get_channel(struct consumer_socket *socket, } /* Stream object is populated by this call if successful. */ - ret = ustctl_recv_stream_from_consumer(*socket->fd, &stream->obj); + ret = ustctl_recv_stream_from_consumer(*socket->fd_ptr, &stream->obj); if (ret < 0) { free(stream); if (ret == -LTTNG_UST_ERR_NOENT) { @@ -290,7 +298,7 @@ int ust_consumer_get_channel(struct consumer_socket *socket, } if (ret != -EPIPE) { ERR("Recv stream from consumer %d with ret %d", - *socket->fd, ret); + *socket->fd_ptr, ret); } else { DBG3("UST app recv stream from consumer. Consumer is dead."); } @@ -301,7 +309,7 @@ int ust_consumer_get_channel(struct consumer_socket *socket, cds_list_add_tail(&stream->list, &ua_chan->streams.head); ua_chan->streams.count++; - DBG2("UST app stream %d received succesfully", ua_chan->streams.count); + DBG2("UST app stream %d received successfully", ua_chan->streams.count); } /* This MUST match or else we have a synchronization problem. */ @@ -337,8 +345,8 @@ int ust_consumer_destroy_channel(struct consumer_socket *socket, assert(ua_chan); assert(socket); - assert(socket->fd); + memset(&msg, 0, sizeof(msg)); msg.cmd_type = LTTNG_CONSUMER_DESTROY_CHANNEL; msg.u.destroy_channel.key = ua_chan->key; @@ -376,8 +384,8 @@ int ust_consumer_send_stream_to_ust(struct ust_app *app, ret = ustctl_send_stream_to_ust(app->sock, channel->obj, stream->obj); if (ret < 0) { if (ret != -EPIPE && ret != -LTTNG_UST_ERR_EXITING) { - ERR("Error ustctl send stream %s to app pid: %d with ret %d", - stream->name, app->pid, ret); + ERR("ustctl send stream handle %d to app pid: %d with ret %d", + stream->obj->handle, app->pid, ret); } else { DBG3("UST app send stream to ust failed. Application is dead."); } @@ -440,15 +448,13 @@ int ust_consumer_metadata_request(struct consumer_socket *socket) assert(socket); rcu_read_lock(); - pthread_mutex_lock(socket->lock); - health_code_update(); /* Wait for a metadata request */ - ret = lttcomm_recv_unix_sock(*socket->fd, &request, sizeof(request)); - if (ret <= 0) { - ERR("Consumer closed the metadata socket"); - ret = -1; + pthread_mutex_lock(socket->lock); + ret = consumer_socket_recv(socket, &request, sizeof(request)); + pthread_mutex_unlock(socket->lock); + if (ret < 0) { goto end; } @@ -466,6 +472,7 @@ int ust_consumer_metadata_request(struct consumer_socket *socket) DBG("PID registry not found for session id %" PRIu64, request.session_id_per_pid); + memset(&msg, 0, sizeof(msg)); msg.cmd_type = LTTNG_ERR_UND; (void) consumer_send_msg(socket, &msg); /* @@ -481,7 +488,9 @@ int ust_consumer_metadata_request(struct consumer_socket *socket) } assert(ust_reg); + pthread_mutex_lock(&ust_reg->lock); ret_push = ust_app_push_metadata(ust_reg, socket, 1); + pthread_mutex_unlock(&ust_reg->lock); if (ret_push < 0) { ERR("Pushing metadata"); ret = -1; @@ -491,7 +500,6 @@ int ust_consumer_metadata_request(struct consumer_socket *socket) ret = 0; end: - pthread_mutex_unlock(socket->lock); rcu_read_unlock(); return ret; }