Cleanup subdir for CONSUMER_DST_NET
authorJulien Desfossez <jdesfossez@efficios.com>
Mon, 28 Aug 2017 19:36:49 +0000 (15:36 -0400)
committerJulien Desfossez <jdesfossez@efficios.com>
Wed, 30 Aug 2017 19:29:02 +0000 (15:29 -0400)
The subdir in the consumer_output structure is supposed to be the
domain-specific sub-directory (/kernel or /ust), but currently we
prepend <hostname>/<session-name> to this subdir for sessions that use a
relay.

Here, we introduce the dst.net.base_dir to store the
<hostname>/<session-name> in the consumer_output and keep subdir
only for the domain-specific data.

This is useful for session rotation where we need to insert the
chunk-name between the session-name and the domain-specific folder.

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

index c26b6b9d91d144051354c83ff92b05337e6dbc73..9cd22744393bae2996fd27b70456ac492f69ae2e 100644 (file)
@@ -715,11 +715,12 @@ int consumer_set_network_uri(struct consumer_output *obj,
                        goto error;
                }
 
-               if (lttng_strncpy(obj->subdir, tmp_path, sizeof(obj->subdir))) {
+               if (lttng_strncpy(obj->dst.net.base_dir, tmp_path,
+                                       sizeof(obj->dst.net.base_dir))) {
                        ret = -LTTNG_ERR_INVALID;
                        goto error;
                }
-               DBG3("Consumer set network uri subdir path %s", tmp_path);
+               DBG3("Consumer set network uri base_dir path %s", tmp_path);
        }
 
        return 0;
@@ -1405,7 +1406,8 @@ int consumer_snapshot_channel(struct consumer_socket *socket, uint64_t key,
                msg.u.snapshot_channel.use_relayd = 1;
                ret = snprintf(msg.u.snapshot_channel.pathname,
                                sizeof(msg.u.snapshot_channel.pathname),
-                               "%s/%s-%s-%" PRIu64 "%s", output->consumer->subdir,
+                               "%s/%s/%s-%s-%" PRIu64 "%s", output->consumer->dst.net.base_dir,
+                               output->consumer->subdir,
                                output->name, output->datetime, output->nb_snapshot,
                                session_path);
                if (ret < 0) {
index 8787122ae690f446866068725015036f4eae3499..d73a40bd485011242493b4b4210606a591bfe398 100644 (file)
@@ -140,6 +140,11 @@ struct consumer_net {
 
        /* Data path for network streaming. */
        struct lttng_uri data;
+
+       /*
+        * <hostname>/<session-name>
+        */
+       char base_dir[PATH_MAX];
 };
 
 /*
index afbef8e38a5ed54353fb1a826fdae069ed991ee2..7c73aee9681fcc412c89c613928573dddd1cadf5 100644 (file)
@@ -68,7 +68,9 @@ static char *create_channel_path(struct consumer_output *consumer,
                }
                DBG3("Kernel local consumer tracefile path: %s", pathname);
        } else {
-               ret = snprintf(tmp_path, sizeof(tmp_path), "%s", consumer->subdir);
+               ret = snprintf(tmp_path, sizeof(tmp_path), "%s%s",
+                               consumer->dst.net.base_dir,
+                               consumer->subdir);
                if (ret < 0) {
                        PERROR("snprintf kernel metadata path");
                        goto error;
index a431a19f01ac8e9706caf5201529f0559586f4d9..788821834aea3d8704027d77ea381d74d6d0cb7e 100644 (file)
@@ -81,7 +81,9 @@ static char *setup_trace_path(struct consumer_output *consumer,
                        }
                }
        } else {
-               ret = snprintf(pathname, PATH_MAX, "%s%s", consumer->subdir,
+               ret = snprintf(pathname, PATH_MAX, "%s%s%s",
+                               consumer->dst.net.base_dir,
+                               consumer->subdir,
                                ua_sess->path);
                if (ret < 0) {
                        PERROR("snprintf channel path");
This page took 0.029346 seconds and 5 git commands to generate.