X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Frotation-thread.c;h=ecccc7bb01ab00bbbba7dd71675b88a7f4b08e3d;hb=fc58be13f62e691645dd75d56ce26d2e121b13e0;hp=21f20b40341023d78aa6533971bd77aa97e6c375;hpb=d88744a44aa5f2ca90ab87946692b9eed3120641;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/rotation-thread.c b/src/bin/lttng-sessiond/rotation-thread.c index 21f20b403..ecccc7bb0 100644 --- a/src/bin/lttng-sessiond/rotation-thread.c +++ b/src/bin/lttng-sessiond/rotation-thread.c @@ -356,7 +356,7 @@ int handle_channel_rotation_pipe(int fd, uint32_t revents, time_t now = time(NULL); if (now == (time_t) -1) { - session->rotation_status = LTTNG_ROTATION_STATUS_ERROR; + session->rotation_state = LTTNG_ROTATION_STATE_ERROR; ret = LTTNG_ERR_UNK; goto end_unlock_session; } @@ -367,7 +367,7 @@ int handle_channel_rotation_pipe(int fd, uint32_t revents, goto end_unlock_session; } session->rotate_pending = false; - session->rotation_status = LTTNG_ROTATION_STATUS_COMPLETED; + session->rotation_state = LTTNG_ROTATION_STATE_COMPLETED; session->last_chunk_start_ts = session->current_chunk_start_ts; if (session->rotate_pending_relay) { ret = sessiond_timer_rotate_pending_start( @@ -435,6 +435,48 @@ end: return ret; } +/* + * Process the rotate_timer, called with session lock held. + */ +static +int rotate_timer(struct ltt_session *session) +{ + int ret; + + /* + * Complete _at most_ one scheduled rotation on a stopped session. + */ + if (!session->active && session->rotate_timer_enabled && + session->rotated_after_last_stop) { + ret = 0; + goto end; + } + + /* Ignore this timer if a rotation is already in progress. */ + if (session->rotate_pending || session->rotate_pending_relay) { + ret = 0; + goto end; + } + + DBG("[rotation-thread] Rotate timer on session %s", session->name); + + ret = cmd_rotate_session(session, NULL); + if (ret == -LTTNG_ERR_ROTATION_PENDING) { + DBG("Scheduled rotation aborted since a rotation is already in progress"); + ret = 0; + goto end; + } else if (ret != LTTNG_OK) { + ERR("[rotation-thread] Automatic time-triggered rotation failed with error code %i", ret); + ret = -1; + goto end; + } + + ret = 0; + +end: + return ret; +} + static int handle_rotate_timer_pipe(uint32_t revents, struct rotation_thread_handle *handle, @@ -504,6 +546,8 @@ int handle_rotate_timer_pipe(uint32_t revents, if (timer_data->signal == LTTNG_SESSIOND_SIG_ROTATE_PENDING) { ret = rotate_pending_relay_timer(session); + } else if (timer_data->signal == LTTNG_SESSIOND_SIG_ROTATE_TIMER) { + ret = rotate_timer(session); } else { ERR("Unknown signal in rotate timer %d", timer_data->signal); ret = -1;