X-Git-Url: http://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-consumer.c;h=ba74112fa72a35758cde4006320dbbfbfd15ce37;hb=7972aab22f74b18faa168c0482216a3dd711a075;hp=60ec5c0b2d623013d7bc2858c2927e207e1b9e4e;hpb=d0b96690836f4b876096f3dc14801f8e25281a77;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/ust-consumer.c b/src/bin/lttng-sessiond/ust-consumer.c index 60ec5c0b2..ba74112fa 100644 --- a/src/bin/lttng-sessiond/ust-consumer.c +++ b/src/bin/lttng-sessiond/ust-consumer.c @@ -21,12 +21,14 @@ #include #include #include +#include #include #include #include #include "consumer.h" +#include "health.h" #include "ust-consumer.h" /* @@ -65,8 +67,8 @@ static char *setup_trace_path(struct consumer_output *consumer, } /* Create directory. Ignore if exist. */ - ret = run_as_mkdir_recursive(pathname, S_IRWXU | S_IRWXG, ua_sess->uid, - ua_sess->gid); + ret = run_as_mkdir_recursive(pathname, S_IRWXU | S_IRWXG, + ua_sess->euid, ua_sess->egid); if (ret < 0) { if (ret != -EEXIST) { ERR("Trace directory creation error"); @@ -92,21 +94,24 @@ error: /* * Send a single channel to the consumer using command ADD_CHANNEL. * - * Consumer socket MUST be acquired before calling this. + * Consumer socket lock MUST be acquired before calling this. */ 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 consumer_socket *socket, struct ust_registry_session *registry) { int ret; - unsigned long key; + uint32_t chan_id; + uint64_t key, chan_reg_key; char *pathname = NULL; struct lttcomm_consumer_msg msg; + struct ust_registry_channel *chan_reg; assert(ua_sess); assert(ua_chan); assert(socket); assert(consumer); + assert(registry); DBG2("Asking UST consumer for channel"); @@ -117,6 +122,21 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, goto error; } + /* Depending on the buffer type, a different channel key is used. */ + if (ua_sess->buffer_type == LTTNG_BUFFER_PER_UID) { + chan_reg_key = ua_chan->tracing_channel_id; + } else { + chan_reg_key = ua_chan->key; + } + + if (ua_chan->attr.type == LTTNG_UST_CHAN_METADATA) { + chan_id = -1U; + } else { + chan_reg = ust_registry_channel_find(registry, chan_reg_key); + assert(chan_reg); + chan_id = chan_reg->chan_id; + } + consumer_init_ask_channel_comm_msg(&msg, ua_chan->attr.subbuf_size, ua_chan->attr.num_subbuf, @@ -125,14 +145,15 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, ua_chan->attr.read_timer_interval, (int) ua_chan->attr.output, (int) ua_chan->attr.type, - ua_sess->id, + ua_sess->tracing_id, pathname, ua_chan->name, - ua_sess->uid, - ua_sess->gid, + ua_sess->euid, + ua_sess->egid, consumer->net_seq_index, ua_chan->key, - ua_sess->registry.uuid); + registry->uuid, + chan_id); health_code_update(); @@ -151,7 +172,7 @@ static int ask_channel_creation(struct ust_app_session *ua_sess, /* We need at least one where 1 stream for 1 cpu. */ assert(ua_chan->expected_stream_count > 0); - DBG2("UST ask channel %lu successfully done with %u stream(s)", key, + DBG2("UST ask channel %" PRIu64 " successfully done with %u stream(s)", key, ua_chan->expected_stream_count); error: @@ -167,7 +188,7 @@ error: */ int ust_consumer_ask_channel(struct ust_app_session *ua_sess, struct ust_app_channel *ua_chan, struct consumer_output *consumer, - struct consumer_socket *socket) + struct consumer_socket *socket, struct ust_registry_session *registry) { int ret; @@ -176,10 +197,11 @@ int ust_consumer_ask_channel(struct ust_app_session *ua_sess, assert(consumer); assert(socket); assert(socket->fd >= 0); + assert(registry); pthread_mutex_lock(socket->lock); - ret = ask_channel_creation(ua_sess, ua_chan, consumer, socket); + ret = ask_channel_creation(ua_sess, ua_chan, consumer, socket, registry); if (ret < 0) { goto error; } @@ -365,8 +387,8 @@ int ust_consumer_send_channel_to_ust(struct ust_app *app, assert(channel); assert(channel->obj); - DBG2("UST app send channel to app sock %d pid %d (name: %s, key: %lu)", - app->sock, app->pid, channel->name, channel->key); + DBG2("UST app send channel to sock %d pid %d (name: %s, key: %" PRIu64 ")", + app->sock, app->pid, channel->name, channel->tracing_channel_id); /* Send stream to application. */ ret = ustctl_send_channel_to_ust(app->sock, ua_sess->handle, channel->obj);