relayd protocol: reply path for close chunk and create session 2.11
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 577647a1c074597ecd7935e5e3d1e3a37e2d9b32..48aa79298c3d9bae6775c5db8767651d6f9ba75d 100644 (file)
@@ -2588,8 +2588,7 @@ int cmd_start_trace(struct ltt_session *session)
                goto error;
        }
 
-       if (session->output_traces && !session->current_trace_chunk &&
-                       session_output_supports_trace_chunks(session)) {
+       if (session->output_traces && !session->current_trace_chunk) {
                struct lttng_trace_chunk *trace_chunk;
 
                trace_chunk = session_create_new_trace_chunk(
@@ -3199,8 +3198,7 @@ int cmd_destroy_session(struct ltt_session *session,
                 if (reply_context) {
                        reply_context->implicit_rotation_on_destroy = true;
                 }
-        } else if (session->has_been_started && session->current_trace_chunk &&
-                               session_output_supports_trace_chunks(session)) {
+        } else if (session->has_been_started && session->current_trace_chunk) {
                /*
                 * The user has not triggered a session rotation. However, to
                 * ensure all data has been consumed, the session is rotated
@@ -4564,7 +4562,7 @@ enum lttng_error_code snapshot_record(struct ltt_session *session,
        }
 
        if (session_close_trace_chunk(
-                           session, session->current_trace_chunk, NULL)) {
+                           session, session->current_trace_chunk, NULL, NULL)) {
                /*
                 * Don't goto end; make sure the chunk is closed for the session
                 * to allow future snapshots.
@@ -4787,7 +4785,7 @@ int cmd_rotate_session(struct ltt_session *session,
        }
 
        /* Unsupported feature in lttng-relayd before 2.11. */
-       if (session->consumer->type == CONSUMER_DST_NET &&
+       if (!quiet_rotation && session->consumer->type == CONSUMER_DST_NET &&
                        (session->consumer->relay_major_version == 2 &&
                        session->consumer->relay_minor_version < 11)) {
                cmd_ret = LTTNG_ERR_ROTATION_NOT_AVAILABLE_RELAY;
@@ -4853,7 +4851,8 @@ int cmd_rotate_session(struct ltt_session *session,
                        quiet_rotation ?
                                        NULL :
                                        &((enum lttng_trace_chunk_command_type){
-                                                       LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED}));
+                                                       LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED}),
+                       session->last_chunk_path);
        if (ret) {
                cmd_ret = LTTNG_ERR_CLOSE_TRACE_CHUNK_FAIL_CONSUMER;
                goto error;
@@ -4974,6 +4973,16 @@ int cmd_rotate_get_info(struct ltt_session *session,
                                        sizeof(info_return->location.local.absolute_path);
                        info_return->location_type =
                                        (int8_t) LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_LOCAL;
+                       fmt_ret = asprintf(&chunk_path,
+                                       "%s/" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY "/%s",
+                                       session_get_base_path(session),
+                                       session->last_archived_chunk_name);
+                       if (fmt_ret == -1) {
+                               PERROR("Failed to format the path of the last archived trace chunk");
+                               info_return->status = LTTNG_ROTATION_STATUS_ERROR;
+                               cmd_ret = LTTNG_ERR_UNK;
+                               goto end;
+                       }
                        break;
                case CONSUMER_DST_NET:
                        current_tracing_path_reply =
@@ -4999,20 +5008,17 @@ int cmd_rotate_get_info(struct ltt_session *session,
                                        &info_return->location.relay.ports.data);
                        info_return->location_type =
                                        (int8_t) LTTNG_TRACE_ARCHIVE_LOCATION_TYPE_RELAY;
+                       chunk_path = strdup(session->last_chunk_path);
+                       if (!chunk_path) {
+                               ERR("Failed to allocate the path of the last archived trace chunk");
+                               info_return->status = LTTNG_ROTATION_STATUS_ERROR;
+                               cmd_ret = LTTNG_ERR_UNK;
+                               goto end;
+                       }
                        break;
                default:
                        abort();
                }
-               fmt_ret = asprintf(&chunk_path,
-                               "%s/" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY "/%s",
-                               session_get_base_path(session),
-                               session->last_archived_chunk_name);
-               if (fmt_ret == -1) {
-                       PERROR("Failed to format the path of the last archived trace chunk");
-                       info_return->status = LTTNG_ROTATION_STATUS_ERROR;
-                       cmd_ret = LTTNG_ERR_UNK;
-                       goto end;
-               }
 
                fmt_ret = lttng_strncpy(current_tracing_path_reply,
                                chunk_path, current_tracing_path_reply_len);
This page took 0.024755 seconds and 4 git commands to generate.