#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <inttypes.h>
#include <common/common.h>
#include <common/consumer.h>
#include <common/defaults.h>
#include "consumer.h"
+#include "health.h"
#include "ust-consumer.h"
/*
}
/* 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");
/*
* 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");
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,
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->uuid);
+ registry->uuid,
+ chan_id);
health_code_update();
/* 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:
*/
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;
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;
}
}
goto error;
}
- ua_chan->handle = ua_chan->obj->handle;
/* Next, get all streams. */
while (1) {
}
goto error;
}
+ channel->handle = channel->obj->handle;
error:
return ret;
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);