correct path sent to the consumer even with a relay
[deliverable/lttng-tools.git] / src / bin / lttng-sessiond / consumer.c
index 54f8804d667b7b0c935b171c23cce203c205bc89..085c8cbcf19e008aa8e974a652188070eb2177f2 100644 (file)
@@ -1591,9 +1591,13 @@ end:
        return ret;
 }
 
+/*
+ * Ask the consumer to rotate a channel.
+ * app_pathname only used for UST, it contains the path after /ust/.
+ */
 int consumer_rotate_channel(struct consumer_socket *socket, uint64_t key,
                uid_t uid, gid_t gid, struct consumer_output *output,
-               char *tmp, uint32_t metadata)
+               char *app_pathname, uint32_t metadata)
 {
        int ret;
        struct lttcomm_consumer_msg msg;
@@ -1609,38 +1613,20 @@ int consumer_rotate_channel(struct consumer_socket *socket, uint64_t key,
        msg.u.rotate_channel.metadata = metadata;
 
        if (output->type == CONSUMER_DST_NET) {
-               ERR("TODO");
-               ret = -1;
-               goto error;
-               /*
-               msg.u.rotate_channel.relayd_id = output->consumer->net_seq_index;
-               ret = snprintf(msg.u.rotate_channel.pathname,
-                               sizeof(msg.u.rotate_channel.pathname),
-                               "%s/%s-%s-%" PRIu64 "%s", output->consumer->subdir,
-                               output->name, output->datetime, output->nb_rotate,
-                               session_path);
-               if (ret < 0) {
-                       ret = -LTTNG_ERR_NOMEM;
-                       goto error;
-               }
-               */
+               fprintf(stderr, "BASE: %s\n", output->dst.net.base_dir);
+               fprintf(stderr, "CHUNK: %s\n", output->chunk_path);
+               msg.u.rotate_channel.relayd_id = output->net_seq_index;
+               snprintf(msg.u.rotate_channel.pathname, PATH_MAX, "%s%s%s",
+                               output->dst.net.base_dir,
+                               output->chunk_path, app_pathname);
+               fprintf(stderr, "SENDING: %s\n", msg.u.rotate_channel.pathname);
        } else {
                msg.u.rotate_channel.relayd_id = (uint64_t) -1ULL;
-               snprintf(msg.u.rotate_channel.pathname, PATH_MAX, "%s/%s/%s",
+               snprintf(msg.u.rotate_channel.pathname, PATH_MAX, "%s%s%s",
                                output->dst.session_root_path,
-                               output->chunk_path, tmp);
+                               output->chunk_path, app_pathname);
                fprintf(stderr, "rotate to %s\n",
                                msg.u.rotate_channel.pathname);
-
-               /* Create directory. Ignore if exist. */
-               ret = run_as_mkdir_recursive(msg.u.rotate_channel.pathname,
-                               S_IRWXU | S_IRWXG, uid, gid);
-               if (ret < 0) {
-                       if (errno != EEXIST) {
-                               ERR("Trace directory creation error");
-                               goto error;
-                       }
-               }
        }
 
        health_code_update();
@@ -1654,3 +1640,53 @@ error:
        health_code_update();
        return ret;
 }
+
+int consumer_rotate_rename(struct consumer_socket *socket, uint64_t session_id,
+               struct consumer_output *output, char *current_path, char *new_path,
+               uint32_t create, uid_t uid, gid_t gid)
+{
+       int ret;
+       struct lttcomm_consumer_msg msg;
+
+       assert(socket);
+
+       DBG("Consumer rotate rename session %" PRIu64, session_id);
+
+       memset(&msg, 0, sizeof(msg));
+       msg.cmd_type = LTTNG_CONSUMER_ROTATE_RENAME;
+       msg.u.rotate_rename.session_id = session_id;
+       msg.u.rotate_rename.create = create;
+       msg.u.rotate_rename.uid = uid;
+       msg.u.rotate_rename.gid = gid;
+
+       if (output->type == CONSUMER_DST_NET) {
+               fprintf(stderr, "SUBDIR: %s\n", output->subdir);
+               fprintf(stderr, "SUBDIR: %s\n", output->dst.net.control.subdir);
+               ERR("TODO");
+               ret = -1;
+               msg.u.rotate_rename.relayd_id = output->net_seq_index;
+               goto error;
+       } else {
+               msg.u.rotate_rename.relayd_id = (uint64_t) -1ULL;
+               snprintf(msg.u.rotate_rename.current_path, PATH_MAX, "%s",
+                               current_path);
+               snprintf(msg.u.rotate_rename.new_path, PATH_MAX, "%s",
+                               new_path);
+               fprintf(stderr, "rotate rename from %s to %s\n", current_path,
+                               new_path);
+       }
+
+       health_code_update();
+       fprintf(stderr, "send %d to the consumer\n",
+                       LTTNG_CONSUMER_ROTATE_RENAME);
+
+       ret = 0;
+       ret = consumer_send_msg(socket, &msg);
+       if (ret < 0) {
+               goto error;
+       }
+
+error:
+       health_code_update();
+       return ret;
+}
This page took 0.026074 seconds and 5 git commands to generate.