+ DBG("[rotation-thread] Checking for pending rotation on session \"%s\", trace archive %" PRIu64,
+ session->name, session->current_archive_id - 1);
+
+ if (session->rotation_pending_local) {
+ /* Updates session->rotation_pending_local as needed. */
+ ret = check_session_rotation_pending_local(session);
+ if (ret) {
+ goto end;
+ }
+
+ /*
+ * No need to check for a pending rotation on the relay
+ * since the rotation is not even completed locally yet.
+ */
+ if (session->rotation_pending_local) {
+ goto end;
+ }
+ }
+
+ if (session->rotation_pending_relay) {
+ /* Updates session->rotation_pending_relay as needed. */
+ ret = check_session_rotation_pending_relay(session);
+ if (ret) {
+ goto end;
+ }
+
+ if (session->rotation_pending_relay) {
+ goto end;
+ }
+ }
+
+ DBG("[rotation-thread] Rotation of trace archive %" PRIu64 " completed for "
+ "session %s", session->current_archive_id - 1,
+ session->name);
+
+ /* Rename the completed trace archive's location. */
+ now = time(NULL);
+ if (now == (time_t) -1) {
+ ret = session_reset_rotation_state(session,
+ LTTNG_ROTATION_STATE_ERROR);
+ if (ret) {
+ ERR("Failed to reset rotation state of session \"%s\"",
+ session->name);
+ }
+ ret = LTTNG_ERR_UNK;
+ goto end;
+ }
+
+ ret = rename_completed_chunk(session, now);