struct lttng_trace_chunk *chunk_being_archived = NULL;
struct lttng_trace_chunk *new_trace_chunk = NULL;
enum lttng_trace_chunk_status chunk_status;
+ bool failed_to_rotate = false;
+ enum lttng_error_code rotation_fail_code = LTTNG_OK;
assert(session);
}
}
- /* The current trace chunk becomes the chunk being archived. */
+ /*
+ * The current trace chunk becomes the chunk being archived.
+ *
+ * After this point, "chunk_being_archived" must absolutely
+ * be closed on the consumer(s), otherwise it will never be
+ * cleaned-up, which will result in a leak.
+ */
ret = session_set_trace_chunk(session, new_trace_chunk,
&chunk_being_archived);
if (ret) {
if (session->kernel_session) {
cmd_ret = kernel_rotate_session(session);
if (cmd_ret != LTTNG_OK) {
- goto error;
+ failed_to_rotate = true;
+ rotation_fail_code = cmd_ret;
}
}
if (session->ust_session) {
cmd_ret = ust_app_rotate_session(session);
if (cmd_ret != LTTNG_OK) {
- goto error;
+ failed_to_rotate = true;
+ rotation_fail_code = cmd_ret;
}
}
goto error;
}
+ if (failed_to_rotate) {
+ cmd_ret = rotation_fail_code;
+ goto error;
+ }
+
session->quiet_rotation = quiet_rotation;
ret = timer_session_rotation_pending_check_start(session,
DEFAULT_ROTATE_PENDING_TIMER);