+int timer_session_rotation_pending_check_start(struct ltt_session *session,
+ unsigned int interval_us)
+{
+ int ret;
+
+ DBG("Enabling session rotation pending check timer on session %" PRIu64,
+ session->id);
+ /*
+ * We arm this timer in a one-shot mode so we don't have to disable it
+ * explicitly (which could deadlock if the timer thread is blocked
+ * writing in the rotation_timer_pipe).
+ *
+ * Instead, we re-arm it if needed after the rotation_pending check as
+ * returned. Also, this timer is usually only needed once, so there is
+ * no need to go through the whole signal teardown scheme everytime.
+ */
+ ret = timer_start(&session->rotation_pending_check_timer,
+ session->id, interval_us,
+ LTTNG_SESSIOND_SIG_PENDING_ROTATION_CHECK,
+ /* one-shot */ true);
+ if (ret == 0) {
+ session->rotation_pending_check_timer_enabled = true;
+ }
+
+ return ret;
+}
+
+/*
+ * Call with session and session_list locks held.
+ */
+int timer_session_rotation_pending_check_stop(struct ltt_session *session)
+{
+ int ret;
+
+ assert(session);
+
+ DBG("Disabling session rotation pending check timer on session %" PRIu64,
+ session->id);
+ ret = timer_stop(&session->rotation_pending_check_timer,
+ LTTNG_SESSIOND_SIG_PENDING_ROTATION_CHECK);
+ if (ret == -1) {
+ ERR("Failed to stop rotate_pending_check timer");
+ } else {
+ session->rotation_pending_check_timer_enabled = false;
+ }
+ return ret;
+}
+
+/*
+ * Call with session and session_list locks held.
+ */
+int timer_session_rotation_schedule_timer_start(struct ltt_session *session,
+ unsigned int interval_us)
+{
+ int ret;
+
+ DBG("Enabling scheduled rotation timer on session \"%s\" (%ui µs)", session->name,
+ interval_us);
+ ret = timer_start(&session->rotation_schedule_timer, session->id,
+ interval_us, LTTNG_SESSIOND_SIG_SCHEDULED_ROTATION,
+ /* one-shot */ false);
+ if (ret < 0) {
+ goto end;
+ }
+ session->rotation_schedule_timer_enabled = true;
+end:
+ return ret;
+}
+
+/*
+ * Call with session and session_list locks held.
+ */
+int timer_session_rotation_schedule_timer_stop(struct ltt_session *session)
+{
+ int ret = 0;
+
+ assert(session);
+
+ if (!session->rotation_schedule_timer_enabled) {
+ goto end;
+ }
+
+ DBG("Disabling scheduled rotation timer on session %s", session->name);
+ ret = timer_stop(&session->rotation_schedule_timer,
+ LTTNG_SESSIOND_SIG_SCHEDULED_ROTATION);
+ if (ret < 0) {
+ ERR("Failed to stop scheduled rotation timer of session \"%s\"",
+ session->name);
+ goto end;
+ }
+
+ session->rotation_schedule_timer_enabled = false;
+ ret = 0;
+end:
+ return ret;
+}
+