X-Git-Url: https://git.liburcu.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Frotation-thread.cpp;h=22891dd13ec4d5f20c99d10aa650c0fe0af65e7c;hb=2545db87957d24f43e2e2d5c49bb56b31bb9180a;hp=ee924ba98f042ee83a7f80f5d0737c95630d867a;hpb=64803277bbdbe0a943360d918298a48157d9da55;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/rotation-thread.cpp b/src/bin/lttng-sessiond/rotation-thread.cpp index ee924ba98..22891dd13 100644 --- a/src/bin/lttng-sessiond/rotation-thread.cpp +++ b/src/bin/lttng-sessiond/rotation-thread.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include "rotation-thread.hpp" #include "lttng-sessiond.hpp" @@ -47,13 +48,6 @@ struct rotation_thread { struct lttng_poll_event events; }; -struct rotation_thread_job { - enum rotation_thread_job_type type; - struct ltt_session *session; - /* List member in struct rotation_thread_timer_queue. */ - struct cds_list_head head; -}; - /* * The timer thread enqueues jobs and wakes up the rotation thread. * When the rotation thread wakes up, it empties the queue. @@ -72,6 +66,15 @@ struct rotation_thread_handle { struct lttng_pipe *quit_pipe; }; +namespace { +struct rotation_thread_job { + enum rotation_thread_job_type type; + struct ltt_session *session; + /* List member in struct rotation_thread_timer_queue. */ + struct cds_list_head head; +}; +} /* namespace */ + static const char *get_job_type_str(enum rotation_thread_job_type job_type) { @@ -484,9 +487,7 @@ int check_session_rotation_pending(struct ltt_session *session, location = session_get_trace_archive_location(session); ret = notification_thread_command_session_rotation_completed( notification_thread_handle, - session->name, - session->uid, - session->gid, + session->id, session->last_archived_chunk_id.value, location); lttng_trace_archive_location_put(location); @@ -624,8 +625,7 @@ end: } static -int handle_condition(const struct lttng_condition *condition, - const struct lttng_evaluation *evaluation, +int handle_condition(const struct lttng_notification *notification, struct notification_thread_handle *notification_thread_handle) { int ret = 0; @@ -635,6 +635,10 @@ int handle_condition(const struct lttng_condition *condition, enum lttng_evaluation_status evaluation_status; uint64_t consumed; struct ltt_session *session; + const struct lttng_condition *condition = + lttng_notification_get_const_condition(notification); + const struct lttng_evaluation *evaluation = + lttng_notification_get_const_evaluation(notification); condition_type = lttng_condition_get_type(condition); @@ -676,25 +680,41 @@ int handle_condition(const struct lttng_condition *condition, } session_lock(session); + if (!lttng_trigger_is_equal(session->rotate_trigger, + lttng_notification_get_const_trigger(notification))) { + /* Notification does not originate from our rotation trigger. */ + ret = 0; + goto end_unlock; + } + ret = unsubscribe_session_consumed_size_rotation(session, notification_thread_handle); if (ret) { goto end_unlock; } - ret = cmd_rotate_session(session, NULL, false, - LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED); - if (ret == -LTTNG_ERR_ROTATION_PENDING) { + ret = cmd_rotate_session( + session, NULL, false, LTTNG_TRACE_CHUNK_COMMAND_TYPE_MOVE_TO_COMPLETED); + switch (ret) { + case LTTNG_OK: + break; + case -LTTNG_ERR_ROTATION_PENDING: DBG("Rotate already pending, subscribe to the next threshold value"); - } else if (ret != LTTNG_OK) { - ERR("Failed to rotate on size notification with error: %s", - lttng_strerror(ret)); + break; + case -LTTNG_ERR_ROTATION_MULTIPLE_AFTER_STOP: + DBG("Rotation already happened since last stop, subscribe to the next threshold value"); + break; + case -LTTNG_ERR_ROTATION_AFTER_STOP_CLEAR: + DBG("Rotation already happened since last stop and clear, subscribe to the next threshold value"); + break; + default: + ERR("Failed to rotate on size notification with error: %s", lttng_strerror(ret)); ret = -1; goto end_unlock; } - ret = subscribe_session_consumed_size_rotation(session, - consumed + session->rotate_size, - notification_thread_handle); + + ret = subscribe_session_consumed_size_rotation( + session, consumed + session->rotate_size, notification_thread_handle); if (ret) { ERR("Failed to subscribe to session consumed size condition"); goto end_unlock; @@ -718,8 +738,6 @@ int handle_notification_channel(int fd __attribute__((unused)), bool notification_pending; struct lttng_notification *notification = NULL; enum lttng_notification_channel_status status; - const struct lttng_evaluation *notification_evaluation; - const struct lttng_condition *notification_condition; status = lttng_notification_channel_has_pending_notification( rotate_notification_channel, ¬ification_pending); @@ -757,10 +775,7 @@ int handle_notification_channel(int fd __attribute__((unused)), goto end; } - notification_condition = lttng_notification_get_condition(notification); - notification_evaluation = lttng_notification_get_evaluation(notification); - - ret = handle_condition(notification_condition, notification_evaluation, + ret = handle_condition(notification, handle->notification_thread_handle); end: