return ret;
}
-static
-int rename_active_chunk(struct ltt_session *session)
-{
- int ret;
-
- session->current_archive_id++;
-
- /*
- * The currently active tracing path is now the folder we
- * want to rename.
- */
- ret = lttng_strncpy(session->rotation_chunk.current_rotate_path,
- session->rotation_chunk.active_tracing_path,
- sizeof(session->rotation_chunk.current_rotate_path));
- if (ret) {
- ERR("Failed to copy active tracing path");
- goto end;
- }
-
- ret = rename_completed_chunk(session, time(NULL));
- if (ret < 0) {
- ERR("Failed to rename current rotation's path");
- goto end;
- }
-
- /*
- * We just renamed, the folder, we didn't do an actual rotation, so
- * the active tracing path is now the renamed folder and we have to
- * restore the rotate count.
- */
- ret = lttng_strncpy(session->rotation_chunk.active_tracing_path,
- session->rotation_chunk.current_rotate_path,
- sizeof(session->rotation_chunk.active_tracing_path));
- if (ret) {
- ERR("Failed to rename active session chunk tracing path");
- goto end;
- }
-end:
- session->current_archive_id--;
- return ret;
-}
-
/*
* Command LTTNG_STOP_TRACE processed by the client thread.
*/
goto error;
}
- if (session->rotation_pending_check_timer_enabled) {
- if (timer_session_rotation_pending_check_stop(session)) {
- ERR("Failed to stop the \"rotation pending check\" timer of session %s",
- session->name);
- }
- }
-
if (session->rotation_schedule_timer_enabled) {
if (timer_session_rotation_schedule_timer_stop(
session)) {
}
}
+ /*
+ * A rotation is still ongoing. The check timer will continue to wait
+ * for the rotation to complete. When the rotation finally completes,
+ * a check will be performed to rename the "active" chunk to the
+ * expected "timestamp_begin-timestamp_end" format.
+ */
if (session->current_archive_id > 0 &&
session->rotation_state != LTTNG_ROTATION_STATE_ONGOING) {
ret = rename_active_chunk(session);
return ret;
}
+int rename_active_chunk(struct ltt_session *session)
+{
+ int ret;
+
+ session->current_archive_id++;
+
+ /*
+ * The currently active tracing path is now the folder we
+ * want to rename.
+ */
+ ret = lttng_strncpy(session->rotation_chunk.current_rotate_path,
+ session->rotation_chunk.active_tracing_path,
+ sizeof(session->rotation_chunk.current_rotate_path));
+ if (ret) {
+ ERR("Failed to copy active tracing path");
+ goto end;
+ }
+
+ ret = rename_completed_chunk(session, time(NULL));
+ if (ret < 0) {
+ ERR("Failed to rename current rotation's path");
+ goto end;
+ }
+
+ /*
+ * We just renamed, the folder, we didn't do an actual rotation, so
+ * the active tracing path is now the renamed folder and we have to
+ * restore the rotate count.
+ */
+ ret = lttng_strncpy(session->rotation_chunk.active_tracing_path,
+ session->rotation_chunk.current_rotate_path,
+ sizeof(session->rotation_chunk.active_tracing_path));
+ if (ret) {
+ ERR("Failed to rename active session chunk tracing path");
+ goto end;
+ }
+end:
+ session->current_archive_id--;
+ return ret;
+}
+
int subscribe_session_consumed_size_rotation(struct ltt_session *session, uint64_t size,
struct notification_thread_handle *notification_thread_handle)
{
#include "rotation-thread.h"
#include <stdint.h>
+int rename_active_chunk(struct ltt_session *session);
int rename_completed_chunk(struct ltt_session *session, time_t ts);
/*
session->name);
}
+ if (!session->active) {
+ /*
+ * A stop command was issued during the rotation, it is
+ * up to the rotation completion check to perform the
+ * renaming of the last chunk that was produced.
+ */
+ ret = notification_thread_command_session_rotation_ongoing(
+ notification_thread_handle,
+ session->name,
+ session->uid,
+ session->gid,
+ session->current_archive_id);
+ if (ret != LTTNG_OK) {
+ ERR("[rotation-thread] Failed to notify notification thread of completed rotation for session %s",
+ session->name);
+ }
+
+ ret = rename_active_chunk(session);
+ if (ret < 0) {
+ ERR("[rotation-thread] Failed to rename active rotation chunk");
+ goto end;
+ }
+
+ /* Ownership of location is transferred. */
+ location = session_get_trace_archive_location(session);
+ ret = notification_thread_command_session_rotation_completed(
+ notification_thread_handle,
+ session->name,
+ session->uid,
+ session->gid,
+ session->current_archive_id,
+ location);
+ if (ret != LTTNG_OK) {
+ ERR("[rotation-thread] Failed to notify notification thread of completed rotation for session %s",
+ session->name);
+ }
+ }
+
ret = 0;
end:
if (session->rotation_state == LTTNG_ROTATION_STATE_ONGOING) {