X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fsession.c;h=e0ab7f4a5eaf70933f25fa082fcead54787d5d17;hb=7d268848fe44e591c53c8dfce796c6503c4539e8;hp=514b11e9919da0c2814aa99096c4bcd99862d892;hpb=d070c424703336e9cca9d1603e1a81bee5b59560;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/session.c b/src/bin/lttng-sessiond/session.c index 514b11e99..e0ab7f4a5 100644 --- a/src/bin/lttng-sessiond/session.c +++ b/src/bin/lttng-sessiond/session.c @@ -262,15 +262,15 @@ struct lttng_trace_archive_location *session_get_trace_archive_location( goto end; } - ret = asprintf(&chunk_path, "%s/" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY "/%s", - session_get_base_path(session), - session->last_archived_chunk_name); - if (ret == -1) { - goto end; - } - switch (session_get_consumer_destination_type(session)) { case CONSUMER_DST_LOCAL: + ret = asprintf(&chunk_path, + "%s/" DEFAULT_ARCHIVED_TRACE_CHUNKS_DIRECTORY "/%s", + session_get_base_path(session), + session->last_archived_chunk_name); + if (ret == -1) { + goto end; + } location = lttng_trace_archive_location_local_create( chunk_path); break; @@ -286,7 +286,7 @@ struct lttng_trace_archive_location *session_get_trace_archive_location( location = lttng_trace_archive_location_relay_create( hostname, LTTNG_TRACE_ARCHIVE_LOCATION_RELAY_PROTOCOL_TYPE_TCP, - control_port, data_port, chunk_path); + control_port, data_port, session->last_chunk_path); break; } default: @@ -565,25 +565,6 @@ error: goto end_no_move; } -bool session_output_supports_trace_chunks(const struct ltt_session *session) -{ - const struct consumer_output *output = session->kernel_session ? - session->kernel_session->consumer : - session->ust_session->consumer; - - if (output->type == CONSUMER_DST_LOCAL) { - return true; - } else { - if (output->relay_major_version > 2) { - return true; - } else if (output->relay_major_version == 2 && - output->relay_minor_version >= 11) { - return true; - } - } - return false; -} - struct lttng_trace_chunk *session_create_new_trace_chunk( const struct ltt_session *session, const struct consumer_output *consumer_output_override, @@ -682,7 +663,8 @@ error: int session_close_trace_chunk(const struct ltt_session *session, struct lttng_trace_chunk *trace_chunk, - const enum lttng_trace_chunk_command_type *close_command) + const enum lttng_trace_chunk_command_type *close_command, + char *closed_trace_chunk_path) { int ret = 0; bool error_occurred = false; @@ -726,7 +708,7 @@ int session_close_trace_chunk(const struct ltt_session *session, ret = consumer_close_trace_chunk(socket, relayd_id, session->id, - trace_chunk); + trace_chunk, closed_trace_chunk_path); pthread_mutex_unlock(socket->lock); if (ret) { ERR("Failed to close trace chunk on user space consumer"); @@ -745,7 +727,7 @@ int session_close_trace_chunk(const struct ltt_session *session, ret = consumer_close_trace_chunk(socket, relayd_id, session->id, - trace_chunk); + trace_chunk, closed_trace_chunk_path); pthread_mutex_unlock(socket->lock); if (ret) { ERR("Failed to close trace chunk on kernel consumer"); @@ -851,6 +833,7 @@ void session_release(struct urcu_ref *ref) } lttng_dynamic_array_reset(&session->destroy_notifiers); free(session->last_archived_chunk_name); + free(session->base_path); free(session); if (session_published) { /* @@ -981,7 +964,7 @@ end: * Session list lock must be held by the caller. */ enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid, - struct ltt_session **out_session) + const char *base_path, struct ltt_session **out_session) { int ret; enum lttng_error_code ret_code; @@ -1064,6 +1047,7 @@ enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid, DEFAULT_SESSION_NAME, i, datetime); } + new_session->name_contains_creation_time = true; if (ret == -1 || ret >= sizeof(new_session->name)) { /* * Null-terminate in case the name is used @@ -1104,6 +1088,16 @@ enum lttng_error_code session_create(const char *name, uid_t uid, gid_t gid, } } + if (base_path) { + new_session->base_path = strdup(base_path); + if (!new_session->base_path) { + ERR("Failed to allocate base path of session \"%s\"", + name); + ret_code = LTTNG_ERR_SESSION_FAIL; + goto error; + } + } + new_session->uid = uid; new_session->gid = gid;