tmp
authorJulien Desfossez <jdesfossez@efficios.com>
Fri, 25 Aug 2017 20:04:22 +0000 (16:04 -0400)
committerJulien Desfossez <jdesfossez@efficios.com>
Wed, 6 Sep 2017 17:59:58 +0000 (13:59 -0400)
Signed-off-by: Julien Desfossez <jdesfossez@efficios.com>
src/bin/lttng-sessiond/consumer.c
src/common/consumer/consumer.c
src/common/consumer/consumer.h
src/common/kernel-consumer/kernel-consumer.c
src/common/ust-consumer/ust-consumer.c

index ff5a2944e0305ab1dffeaa4078788b07d3005852..fc5d0fc95c841463c5bd1f03c2fbdafa3d906ac9 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;
@@ -1608,18 +1612,19 @@ int consumer_rotate_channel(struct consumer_socket *socket, uint64_t key,
        msg.u.rotate_channel.key = key;
        msg.u.rotate_channel.metadata = metadata;
 
-
        if (output->type == CONSUMER_DST_NET) {
                fprintf(stderr, "SUBDIR: %s\n", output->subdir);
+               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->subdir,
-                               output->chunk_path, tmp);
+                               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",
                                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);
 
index fa93ab81358c08bd1ce0c833e268ba81558933d5..b99068925946e6e692148043eccbd4baa70a40fc 100644 (file)
@@ -4046,43 +4046,54 @@ int lttng_consumer_stream_is_rotate_ready(struct lttng_consumer_stream *stream,
                goto end;
        }
 
+       if (stream->rotate_ready) {
+               fprintf(stderr, "Rotate position reached for stream %lu\n",
+                               stream->key);
+               ret = 1;
+               goto end;
+       }
+
        /*
         * If we don't have the rotate_ready flag, check the consumed position
         * to determine if we need to rotate.
         */
-       if (!stream->rotate_ready) {
-               ret = lttng_consumer_sample_snapshot_positions(stream);
-               if (ret < 0) {
-                       ERR("Taking kernel snapshot positions");
-                       goto end;
-               }
+       ret = lttng_consumer_sample_snapshot_positions(stream);
+       if (ret < 0) {
+               ERR("Taking kernel snapshot positions");
+               goto end;
+       }
 
-               ret = lttng_consumer_get_consumed_snapshot(stream, &consumed_pos);
-               if (ret < 0) {
-                       ERR("Produced kernel snapshot position");
-                       goto end;
-               }
+       ret = lttng_consumer_get_consumed_snapshot(stream, &consumed_pos);
+       if (ret < 0) {
+               ERR("Produced kernel snapshot position");
+               goto end;
+       }
 
-               fprintf(stderr, "packet %lu, pos %lu\n", stream->key, consumed_pos);
-               /* Rotate position not reached yet. */
-               if ((consumed_pos + len) < stream->rotate_position) {
-                       ret = 0;
-                       goto end;
-               }
-               fprintf(stderr, "Rotate position %lu (expected %lu) reached for stream %lu\n",
-                               consumed_pos + len, stream->rotate_position,
-                               stream->key);
-               ret = 1;
-       } else {
-               fprintf(stderr, "Rotate position reached for stream %lu\n",
-                               stream->key);
-               ret = 1;
+       fprintf(stderr, "packet %lu, pos %lu\n", stream->key, consumed_pos);
+       /* Rotate position not reached yet. */
+       if ((consumed_pos + len) < stream->rotate_position) {
+               ret = 0;
+               goto end;
        }
+       fprintf(stderr, "Rotate position %lu (expected %lu) reached for stream %lu\n",
+                       consumed_pos + len, stream->rotate_position,
+                       stream->key);
+       ret = 1;
 
 end:
        return ret;
 }
 
+/*
+ * Reset the state for a stream after a rotation occurred.
+ */
+void lttng_consumer_reset_stream_rotate_state(struct lttng_consumer_stream *stream)
+{
+       stream->rotate_position = 0;
+       stream->rotate_ready = 0;
+       stream->rotated = 1;
+}
+
 /*
  * Performs the stream rotation for the rotate session feature if needed.
  * It must be called with the stream and channel locks held.
@@ -4153,9 +4164,7 @@ int lttng_consumer_rotate_stream(struct lttng_consumer_local_data *ctx,
                }
        }
 
-       stream->rotate_position = 0;
-       stream->rotate_ready = 0;
-       stream->rotated = 1;
+       lttng_consumer_reset_stream_rotate_state(stream);
 
        ret = 0;
        goto end;
index 7f09bf870effd1a2e80013912d4701692d7e12ea..ee846c870cab7209d63fc37828777af04f76396a 100644 (file)
@@ -826,5 +826,6 @@ int lttng_consumer_rotate_ready_streams(uint64_t key,
                struct lttng_consumer_local_data *ctx);
 int lttng_consumer_rotate_rename(char *current_path, char *new_path,
                uint32_t create, uid_t uid, gid_t gid);
+void lttng_consumer_reset_stream_rotate_state(struct lttng_consumer_stream *stream);
 
 #endif /* LIB_CONSUMER_H */
index 2f15f6a25067493be6b0e9ec22ef73d33debcf61..55b29530661714931ef0486b9d97bf7d82deeffa 100644 (file)
@@ -1490,6 +1490,7 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
                ret = -1;
                goto error;
        }
+       stream->rotate_ready = rotate_ready;
 
        if (!stream->metadata_flag) {
                ret = get_index_values(&index, infd);
@@ -1667,7 +1668,7 @@ ssize_t lttng_kconsumer_read_subbuffer(struct lttng_consumer_stream *stream,
        }
 
 rotate:
-       if (rotate_ready) {
+       if (stream->rotate_ready) {
                rotation_ret = lttng_consumer_rotate_stream(ctx, stream);
                if (rotation_ret < 0) {
                        ERR("Stream rotation error");
index fab493d1fe159d4902c6434b37828ef3f2e69cae..98c5426212b7162a8f4d3c3be9f9d7a5904e30cd 100644 (file)
@@ -2688,6 +2688,7 @@ retry:
                assert(err == 0);
                goto error;
        }
+       stream->rotate_ready = rotate_ready;
 
        /* write the subbuffer to the tracefile */
        ret = lttng_consumer_on_read_subbuffer_mmap(ctx, stream, subbuf_size, padding, &index);
@@ -2762,7 +2763,7 @@ retry:
        }
 
 rotate:
-       if (rotate_ready) {
+       if (stream->rotate_ready) {
                rotation_ret = lttng_consumer_rotate_stream(ctx, stream);
                if (rotation_ret < 0) {
                        ret = -1;
This page took 0.032803 seconds and 5 git commands to generate.