Fix: send per-pid session id in channel creation
authorJulien Desfossez <jdesfossez@efficios.com>
Thu, 27 Jun 2013 21:57:06 +0000 (17:57 -0400)
committerDavid Goulet <dgoulet@efficios.com>
Fri, 28 Jun 2013 15:16:56 +0000 (11:16 -0400)
The registry indexing for per-pid sessions is done with a per-pid
session id. So for per-pid buffers, we need to send the per-pid session
id as well as the global session id to the consumer in order to give it
enough information if it needs to request metadata later.

This patch adds the session_id_per_pid to the channel creation message
and to the consumer. When the sessiond receives a metadata_request,
depending on the buffer type (per-pid or per-uid), it selects the right
id to do the registry lookup.

Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
Signed-off-by: David Goulet <dgoulet@efficios.com>
Conflicts:
src/bin/lttng-sessiond/consumer.c
src/bin/lttng-sessiond/consumer.h
src/bin/lttng-sessiond/ust-consumer.c
src/common/consumer.c
src/common/consumer.h
src/common/kernel-consumer/kernel-consumer.c
src/common/sessiond-comm/sessiond-comm.h
src/common/ust-consumer/ust-consumer.c

src/bin/lttng-sessiond/consumer.c
src/bin/lttng-sessiond/consumer.h
src/bin/lttng-sessiond/ust-consumer.c
src/common/consumer.c
src/common/consumer.h
src/common/kernel-consumer/kernel-consumer.c
src/common/sessiond-comm/sessiond-comm.h
src/common/ust-consumer/ust-consumer.c

index 8198629f32638fc181a07cc2c5d28ac6703c062f..36883766955e07847503236d7f62334364033c33 100644 (file)
@@ -723,6 +723,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,
                uint32_t chan_id,
                uint64_t tracefile_size,
                uint64_t tracefile_count,
+               uint64_t session_id_per_pid,
                unsigned int monitor)
 {
        assert(msg);
@@ -739,6 +740,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,
        msg->u.ask_channel.output = output;
        msg->u.ask_channel.type = type;
        msg->u.ask_channel.session_id = session_id;
+       msg->u.ask_channel.session_id_per_pid = session_id_per_pid;
        msg->u.ask_channel.uid = uid;
        msg->u.ask_channel.gid = gid;
        msg->u.ask_channel.relayd_id = relayd_id;
index 4d8f66a72957cc06f74ef54fde0c6fc45cdc4a16..c3c8dfb7f1a15386c45dbd236bd34e2811df87f1 100644 (file)
@@ -212,6 +212,7 @@ void consumer_init_ask_channel_comm_msg(struct lttcomm_consumer_msg *msg,
                uint32_t chan_id,
                uint64_t tracefile_size,
                uint64_t tracefile_count,
+               uint64_t session_id_per_pid,
                unsigned int monitor);
 void consumer_init_stream_comm_msg(struct lttcomm_consumer_msg *msg,
                enum lttng_consumer_command cmd,
index 72b68bb7f7bed39d03ed5860381ef70d94df5ad8..d85e32aa0ce9f2a011887fd4b9a1c70e541ccca0 100644 (file)
@@ -158,6 +158,7 @@ static int ask_channel_creation(struct ust_app_session *ua_sess,
                        chan_id,
                        ua_chan->tracefile_size,
                        ua_chan->tracefile_count,
+                       ua_sess->id,
                        ua_sess->output_traces);
 
        health_code_update();
@@ -446,7 +447,7 @@ int ust_consumer_metadata_request(struct consumer_socket *socket)
                goto end;
        }
 
-       DBG("Metadata request received for session %u, key %" PRIu64,
+       DBG("Metadata request received for session %" PRIu64 ", key %" PRIu64,
                        request.session_id, request.key);
 
        reg_uid = buffer_reg_uid_find(request.session_id,
@@ -455,10 +456,10 @@ int ust_consumer_metadata_request(struct consumer_socket *socket)
                ust_reg = reg_uid->registry->reg.ust;
        } else {
                struct buffer_reg_pid *reg_pid =
-                       buffer_reg_pid_find(request.session_id);
+                       buffer_reg_pid_find(request.session_id_per_pid);
                if (!reg_pid) {
-                       DBG("PID registry not found for session id %u",
-                                       request.session_id);
+                       DBG("PID registry not found for session id %" PRIu64,
+                                       request.session_id_per_pid);
 
                        msg.cmd_type = LTTNG_ERR_UND;
                        (void) consumer_send_msg(socket, &msg);
index 5574c5f0e1d545691f6837d2d4100a10c2a59e48..57322ae08dbb41685f17bcadb3b59ccc378c2431 100644 (file)
@@ -769,6 +769,7 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key,
                enum lttng_event_output output,
                uint64_t tracefile_size,
                uint64_t tracefile_count,
+               uint64_t session_id_per_pid,
                unsigned int monitor)
 {
        struct lttng_consumer_channel *channel;
@@ -782,6 +783,7 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key,
        channel->key = key;
        channel->refcount = 0;
        channel->session_id = session_id;
+       channel->session_id_per_pid = session_id_per_pid;
        channel->uid = uid;
        channel->gid = gid;
        channel->relayd_id = relayd_id;
index f804b7260ce7e6d013eb55ff36c90487930562e3..ca567d7ff8844dcdb99b5aab0bb20bf4897e4256 100644 (file)
@@ -106,6 +106,11 @@ struct lttng_consumer_channel {
        int refcount;
        /* Tracing session id on the session daemon side. */
        uint64_t session_id;
+       /*
+        * Session id when requesting metadata to the session daemon for
+        * a session with per-PID buffers.
+        */
+       uint64_t session_id_per_pid;
        /* Channel trace file path name. */
        char pathname[PATH_MAX];
        /* Channel name. */
@@ -493,6 +498,7 @@ struct lttng_consumer_channel *consumer_allocate_channel(uint64_t key,
                enum lttng_event_output output,
                uint64_t tracefile_size,
                uint64_t tracefile_count,
+               uint64_t session_id_per_pid,
                unsigned int monitor);
 void consumer_del_stream(struct lttng_consumer_stream *stream,
                struct lttng_ht *ht);
index 84be2db463fb0b8cd8a3a6107fd321531eef2aa9..354a0424e3d27993f87b90d24352c5cad21f19c2 100644 (file)
@@ -480,7 +480,7 @@ int lttng_kconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                                msg.u.channel.name, msg.u.channel.uid, msg.u.channel.gid,
                                msg.u.channel.relayd_id, msg.u.channel.output,
                                msg.u.channel.tracefile_size,
-                               msg.u.channel.tracefile_count,
+                               msg.u.channel.tracefile_count, 0,
                                msg.u.channel.monitor);
                if (new_channel == NULL) {
                        lttng_consumer_send_error(ctx, LTTCOMM_CONSUMERD_OUTFD_ERROR);
index 07c3ff1f5249146d311df90b44664a38b36d16c8..e984cb1a976e5cbed52561f115fb4bc0c7ff60bb 100644 (file)
@@ -155,7 +155,8 @@ enum lttcomm_metadata_command {
  * per PID registry indexed by session id ignoring the other values.
  */
 struct lttcomm_metadata_request_msg {
-       unsigned int session_id; /* Tracing session id */
+       uint64_t session_id; /* Tracing session id */
+       uint64_t session_id_per_pid; /* Tracing session id for per-pid */
        uint32_t bits_per_long; /* Consumer ABI */
        uint32_t uid;
        uint64_t key; /* Metadata channel key. */
@@ -362,6 +363,7 @@ struct lttcomm_consumer_msg {
                        uint32_t chan_id;                       /* Channel ID on the tracer side. */
                        uint64_t tracefile_size;        /* bytes */
                        uint32_t tracefile_count;       /* number of tracefiles */
+                       uint64_t session_id_per_pid;    /* Per-pid session ID. */
                        /* Tells the consumer if the stream should be or not monitored. */
                        uint32_t monitor;
                } LTTNG_PACKED ask_channel;
index f24b5fa3e2587039a57e4fca3eef192bc80ed6c3..46644a907a9b7bd5e659def07bcae21c2295ed7d 100644 (file)
@@ -115,13 +115,14 @@ static struct lttng_consumer_channel *allocate_channel(uint64_t session_id,
                const char *pathname, const char *name, uid_t uid, gid_t gid,
                int relayd_id, uint64_t key, enum lttng_event_output output,
                uint64_t tracefile_size, uint64_t tracefile_count,
-               unsigned int monitor)
+               uint64_t session_id_per_pid, unsigned int monitor)
 {
        assert(pathname);
        assert(name);
 
-       return consumer_allocate_channel(key, session_id, pathname, name, uid, gid,
-                       relayd_id, output, tracefile_size, tracefile_count, monitor);
+       return consumer_allocate_channel(key, session_id, pathname, name, uid,
+                       gid, relayd_id, output, tracefile_size,
+                       tracefile_count, session_id_per_pid, monitor);
 }
 
 /*
@@ -926,6 +927,7 @@ int lttng_ustconsumer_recv_cmd(struct lttng_consumer_local_data *ctx,
                                (enum lttng_event_output) msg.u.ask_channel.output,
                                msg.u.ask_channel.tracefile_size,
                                msg.u.ask_channel.tracefile_count,
+                               msg.u.ask_channel.session_id_per_pid,
                                msg.u.ask_channel.monitor);
                if (!channel) {
                        goto end_channel_error;
@@ -1511,10 +1513,13 @@ int lttng_ustconsumer_request_metadata(struct lttng_consumer_local_data *ctx,
        }
 
        request.session_id = channel->session_id;
+       request.session_id_per_pid = channel->session_id_per_pid;
        request.uid = channel->uid;
        request.key = channel->key;
-       DBG("Sending metadata request to sessiond, session %" PRIu64,
-                       channel->session_id);
+       DBG("Sending metadata request to sessiond, session id %" PRIu64
+                       ", per-pid %" PRIu64,
+                       channel->session_id,
+                       channel->session_id_per_pid);
 
        ret = lttcomm_send_unix_sock(ctx->consumer_metadata_socket, &request,
                        sizeof(request));
This page took 0.03204 seconds and 4 git commands to generate.