relayd protocol: reply path for close chunk and create session 2.11
[lttng-tools.git] / src / bin / lttng-sessiond / cmd.c
index 0596033b1441fda9aaa3ca20e613be5923d4b714..48aa79298c3d9bae6775c5db8767651d6f9ba75d 100644 (file)
@@ -1040,7 +1040,8 @@ static enum lttng_error_code send_consumer_relayd_socket(
                const char *session_name, const char *hostname,
                const char *base_path, int session_live_timer,
                const uint64_t *current_chunk_id,
-               time_t session_creation_time)
+               time_t session_creation_time,
+               bool session_name_contains_creation_time)
 {
        int ret;
        struct lttcomm_relayd_sock *rsock = NULL;
@@ -1070,7 +1071,7 @@ static enum lttng_error_code send_consumer_relayd_socket(
                        relayd_uri->stype, session_id,
                        session_name, hostname, base_path,
                        session_live_timer, current_chunk_id,
-                       session_creation_time);
+                       session_creation_time, session_name_contains_creation_time);
        if (ret < 0) {
                status = LTTNG_ERR_ENABLE_CONSUMER_FAIL;
                goto close_sock;
@@ -1118,7 +1119,8 @@ static enum lttng_error_code send_consumer_relayd_sockets(
                unsigned int session_id, struct consumer_output *consumer,
                struct consumer_socket *sock, const char *session_name,
                const char *hostname, const char *base_path, int session_live_timer,
-               const uint64_t *current_chunk_id, time_t session_creation_time)
+               const uint64_t *current_chunk_id, time_t session_creation_time,
+               bool session_name_contains_creation_time)
 {
        enum lttng_error_code status = LTTNG_OK;
 
@@ -1130,7 +1132,8 @@ static enum lttng_error_code send_consumer_relayd_sockets(
                status = send_consumer_relayd_socket(session_id,
                                &consumer->dst.net.control, consumer, sock,
                                session_name, hostname, base_path, session_live_timer,
-                               current_chunk_id, session_creation_time);
+                               current_chunk_id, session_creation_time,
+                               session_name_contains_creation_time);
                if (status != LTTNG_OK) {
                        goto error;
                }
@@ -1141,7 +1144,8 @@ static enum lttng_error_code send_consumer_relayd_sockets(
                status = send_consumer_relayd_socket(session_id,
                                &consumer->dst.net.data, consumer, sock,
                                session_name, hostname, base_path, session_live_timer,
-                               current_chunk_id, session_creation_time);
+                               current_chunk_id, session_creation_time,
+                               session_name_contains_creation_time);
                if (status != LTTNG_OK) {
                        goto error;
                }
@@ -1199,7 +1203,8 @@ int cmd_setup_relayd(struct ltt_session *session)
                                        session->base_path,
                                        session->live_timer,
                                        current_chunk_id.is_set ? &current_chunk_id.value : NULL,
-                                       session->creation_time);
+                                       session->creation_time,
+                                       session->name_contains_creation_time);
                        pthread_mutex_unlock(socket->lock);
                        if (ret != LTTNG_OK) {
                                goto error;
@@ -1224,7 +1229,8 @@ int cmd_setup_relayd(struct ltt_session *session)
                                        session->base_path,
                                        session->live_timer,
                                        current_chunk_id.is_set ? &current_chunk_id.value : NULL,
-                                       session->creation_time);
+                                       session->creation_time,
+                                       session->name_contains_creation_time);
                        pthread_mutex_unlock(socket->lock);
                        if (ret != LTTNG_OK) {
                                goto error;
@@ -2582,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(
@@ -3193,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
@@ -4289,7 +4293,8 @@ static enum lttng_error_code set_relayd_for_snapshot(
                                base_path,
                                session->live_timer,
                                current_chunk_id.is_set ? &current_chunk_id.value : NULL,
-                               session->creation_time);
+                               session->creation_time,
+                               session->name_contains_creation_time);
                pthread_mutex_unlock(socket->lock);
                if (status != LTTNG_OK) {
                        rcu_read_unlock();
@@ -4557,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.
@@ -4780,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;
@@ -4846,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;
@@ -4967,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 =
@@ -4992,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.027383 seconds and 4 git commands to generate.