+
+ /* Current chunk directory, ex: 20170922-111754-42 */
+ ret = snprintf(session->consumer->chunk_path,
+ sizeof(session->consumer->chunk_path),
+ "%s-%" PRIu64, datetime,
+ session->current_archive_id + 1);
+ if (ret < 0 || ret >= sizeof(session->consumer->chunk_path)) {
+ ERR("Failed to format the new chunk's directory in rotate session command");
+ cmd_ret = LTTNG_ERR_UNK;
+ goto error;
+ }
+
+ /*
+ * The active path for the next rotation/destroy.
+ * Ex: ~/lttng-traces/auto-20170922-111748/20170922-111754-42
+ */
+ ret = snprintf(session->rotation_chunk.active_tracing_path,
+ sizeof(session->rotation_chunk.active_tracing_path),
+ "%s/%s",
+ session_get_base_path(session),
+ session->consumer->chunk_path);
+ if (ret < 0 || ret >= sizeof(session->rotation_chunk.active_tracing_path)) {
+ ERR("Failed to format active tracing path in rotate session command");
+ cmd_ret = LTTNG_ERR_UNK;
+ goto error;
+ }
+
+ /*
+ * A rotation has a local step even if the destination is a relay
+ * daemon; the buffers must be consumed by the consumer daemon.
+ */
+ session->rotation_pending_local = true;
+ session->rotation_pending_relay =
+ session_get_consumer_destination_type(session) == CONSUMER_DST_NET;
+ session->rotation_state = LTTNG_ROTATION_STATE_ONGOING;
+