* Command LTTNG_ROTATE_SESSION from the lttng-ctl library.
*
* Ask the consumer to rotate the session output directory.
+ * The session lock must be held.
*
* Return 0 on success or else a LTTNG_ERR code.
*/
/*
* If the session is stopped, we need to cancel this timer.
*/
- pthread_mutex_lock(&session->lock);
+ session_lock(session);
if (!session->active && session->rotate_timer_enabled) {
sessiond_rotate_timer_stop(session);
}
- pthread_mutex_unlock(&session->lock);
ret = cmd_rotate_session(session, NULL);
+ session_unlock(session);
fprintf(stderr, "RET ROTATE TIMER: %d\n", ret);
if (ret == -LTTNG_ERR_ROTATE_PENDING) {
ret = 0;
goto end;
}
+ rcu_read_lock();
+ session_lock_list();
session = session_find_by_id(timer_data.session_id);
if (!session) {
ERR("[rotation-thread] Session %" PRIu64 " not found",
timer_data.session_id);
ret = -1;
- goto end;
+ goto end_unlock;
}
if (timer_data.signal == LTTNG_SESSIOND_SIG_ROTATE_PENDING) {
ret = -1;
}
+end_unlock:
+ session_unlock_list();
+ rcu_read_unlock();
end:
return ret;
}
/*
* No rate limiting here, so if the timer fires too quickly, there will
- * be a backlog of timers queued up and we will try to catch up.
+ * be a backlog of timers queued up and the sessiond will try to catch
+ * up.
*/
memset(&timer_data, 0, sizeof(struct sessiond_rotation_timer));
timer_data.session_id = session->id;