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;
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);
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.
}
}
- stream->rotate_position = 0;
- stream->rotate_ready = 0;
- stream->rotated = 1;
+ lttng_consumer_reset_stream_rotate_state(stream);
ret = 0;
goto end;
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 */
ret = -1;
goto error;
}
+ stream->rotate_ready = rotate_ready;
if (!stream->metadata_flag) {
ret = get_index_values(&index, infd);
}
rotate:
- if (rotate_ready) {
+ if (stream->rotate_ready) {
rotation_ret = lttng_consumer_rotate_stream(ctx, stream);
if (rotation_ret < 0) {
ERR("Stream rotation error");
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);
}
rotate:
- if (rotate_ready) {
+ if (stream->rotate_ready) {
rotation_ret = lttng_consumer_rotate_stream(ctx, stream);
if (rotation_ret < 0) {
ret = -1;