Fix: send per-pid session id in channel creation
[lttng-tools.git] / src / bin / lttng-sessiond / ust-app.c
index 1736a3e851b20b646aa0f0b95c8e65c3ddc67fd6..e457cae6803f2ef43491a580ab0f6501171c7494 100644 (file)
@@ -1440,6 +1440,7 @@ static void shadow_copy_session(struct ust_app_session *ua_sess,
        ua_sess->bits_per_long = app->bits_per_long;
        /* There is only one consumer object per session possible. */
        ua_sess->consumer = usess->consumer;
+       ua_sess->output_traces = usess->output_traces;
 
        switch (ua_sess->buffer_type) {
        case LTTNG_BUFFER_PER_PID:
@@ -1946,9 +1947,11 @@ static int do_consumer_create_channel(struct ltt_ust_session *usess,
         * Now get the channel from the consumer. This call wil populate the stream
         * list of that channel and set the ust objects.
         */
-       ret = ust_consumer_get_channel(socket, ua_chan);
-       if (ret < 0) {
-               goto error_destroy;
+       if (usess->consumer->enabled) {
+               ret = ust_consumer_get_channel(socket, ua_chan);
+               if (ret < 0) {
+                       goto error_destroy;
+               }
        }
 
        rcu_read_unlock();
@@ -4843,3 +4846,66 @@ void ust_app_destroy(struct ust_app *app)
 
        call_rcu(&app->pid_n.head, delete_ust_app_rcu);
 }
+
+/*
+ * Take a snapshot for a given UST session. The snapshot is sent to the given
+ * output.
+ *
+ * Return 0 on success or else a negative value.
+ */
+int ust_app_snapshot_record(struct ltt_ust_session *usess,
+               struct snapshot_output *output, int wait)
+{
+       int ret = 0;
+       struct lttng_ht_iter iter;
+       struct ust_app *app;
+
+       assert(usess);
+       assert(output);
+
+       rcu_read_lock();
+
+       cds_lfht_for_each_entry(ust_app_ht->ht, &iter.iter, app, pid_n.node) {
+               struct consumer_socket *socket;
+               struct lttng_ht_iter chan_iter;
+               struct ust_app_channel *ua_chan;
+               struct ust_app_session *ua_sess;
+               struct ust_registry_session *registry;
+
+               ua_sess = lookup_session_by_app(usess, app);
+               if (!ua_sess) {
+                       /* Session not associated with this app. */
+                       continue;
+               }
+
+               /* Get the right consumer socket for the application. */
+               socket = consumer_find_socket_by_bitness(app->bits_per_long,
+                               output->consumer);
+               if (!socket) {
+                       ret = -EINVAL;
+                       goto error;
+               }
+
+               cds_lfht_for_each_entry(ua_sess->channels->ht, &chan_iter.iter,
+                               ua_chan, node.node) {
+                       ret = consumer_snapshot_channel(socket, ua_chan->key, output, 0,
+                                       ua_sess->euid, ua_sess->egid, ua_sess->path, wait);
+                       if (ret < 0) {
+                               goto error;
+                       }
+               }
+
+               registry = get_session_registry(ua_sess);
+               assert(registry);
+               ret = consumer_snapshot_channel(socket, registry->metadata_key, output,
+                               1, ua_sess->euid, ua_sess->egid, ua_sess->path, wait);
+               if (ret < 0) {
+                       goto error;
+               }
+
+       }
+
+error:
+       rcu_read_unlock();
+       return ret;
+}
This page took 0.024252 seconds and 4 git commands to generate.