X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fcmd.c;h=1b73978f27f0e81d671987f05ae851e70e5acf47;hb=1f4fc77013a97e2a0df92d86d0ea9f2a639ed65f;hp=0596033b1441fda9aaa3ca20e613be5923d4b714;hpb=6fa5fe7cc78bea0b0bba154a0f911d3df530e18f;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/cmd.c b/src/bin/lttng-sessiond/cmd.c index 0596033b1..1b73978f2 100644 --- a/src/bin/lttng-sessiond/cmd.c +++ b/src/bin/lttng-sessiond/cmd.c @@ -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 ? ¤t_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 ? ¤t_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 ? ¤t_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(); @@ -4471,6 +4476,8 @@ enum lttng_error_code snapshot_record(struct ltt_session *session, session->kernel_session->consumer; snapshot_kernel_consumer_output = consumer_copy_output(snapshot_output->consumer); + strcpy(snapshot_kernel_consumer_output->chunk_path, + snapshot_chunk_name); ret = consumer_copy_sockets(snapshot_kernel_consumer_output, original_kernel_consumer_output); if (ret < 0) { @@ -4491,6 +4498,8 @@ enum lttng_error_code snapshot_record(struct ltt_session *session, original_ust_consumer_output = session->ust_session->consumer; snapshot_ust_consumer_output = consumer_copy_output(snapshot_output->consumer); + strcpy(snapshot_ust_consumer_output->chunk_path, + snapshot_chunk_name); ret = consumer_copy_sockets(snapshot_ust_consumer_output, original_ust_consumer_output); if (ret < 0) { @@ -4557,7 +4566,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 +4789,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 +4855,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 +4977,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 +5012,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);