X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Frotation-thread.cpp;h=5efc24edda31b81af320718c4f05bcbd2f5774e2;hb=139a8d250fb18f8ffc95b0936f7285f7b484b72f;hp=a2b92a858ae612254cafa8d8a13d05558c503bab;hpb=739b8e1740ff0dc8a37aaea4b6e2bbf0cf9dcf70;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/rotation-thread.cpp b/src/bin/lttng-sessiond/rotation-thread.cpp index a2b92a858..5efc24edd 100644 --- a/src/bin/lttng-sessiond/rotation-thread.cpp +++ b/src/bin/lttng-sessiond/rotation-thread.cpp @@ -8,35 +8,36 @@ #define _LGPL_SOURCE #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include #include #include #include #include -#include -#include -#include -#include -#include - -#include "rotation-thread.h" -#include "lttng-sessiond.h" -#include "health-sessiond.h" -#include "rotate.h" -#include "cmd.h" -#include "session.h" -#include "timer.h" -#include "notification-thread-commands.h" -#include "utils.h" -#include "thread.h" +#include +#include +#include +#include +#include +#include + +#include "rotation-thread.hpp" +#include "lttng-sessiond.hpp" +#include "health-sessiond.hpp" +#include "rotate.hpp" +#include "cmd.hpp" +#include "session.hpp" +#include "timer.hpp" +#include "notification-thread-commands.hpp" +#include "utils.hpp" +#include "thread.hpp" #include #include @@ -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) { @@ -89,7 +92,7 @@ struct rotation_thread_timer_queue *rotation_thread_timer_queue_create(void) { struct rotation_thread_timer_queue *queue = NULL; - queue = (rotation_thread_timer_queue *) zmalloc(sizeof(*queue)); + queue = zmalloc(); if (!queue) { PERROR("Failed to allocate timer rotate queue"); goto end; @@ -134,7 +137,7 @@ struct rotation_thread_handle *rotation_thread_handle_create( { struct rotation_thread_handle *handle; - handle = (rotation_thread_handle *) zmalloc(sizeof(*handle)); + handle = zmalloc(); if (!handle) { goto end; } @@ -193,7 +196,7 @@ void rotation_thread_enqueue_job(struct rotation_thread_timer_queue *queue, goto end; } - job = (rotation_thread_job *) zmalloc(sizeof(struct rotation_thread_job)); + job = zmalloc(); if (!job) { PERROR("Failed to allocate rotation thread job of type \"%s\" for session \"%s\"", job_type_str, session->name); @@ -215,7 +218,10 @@ void rotation_thread_enqueue_job(struct rotation_thread_timer_queue *queue, * the job will be processed when the rotation_thread catches * up. */ + DIAGNOSTIC_PUSH + DIAGNOSTIC_IGNORE_LOGICAL_OP if (errno == EAGAIN || errno == EWOULDBLOCK) { + DIAGNOSTIC_POP /* * Not an error, but would be surprising and indicate * that the rotation thread can't keep up with the @@ -481,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); @@ -561,7 +565,7 @@ int run_job(struct rotation_thread_job *job, struct ltt_session *session, static int handle_job_queue(struct rotation_thread_handle *handle, - struct rotation_thread *state, + struct rotation_thread *state __attribute__((unused)), struct rotation_thread_timer_queue *queue) { int ret = 0; @@ -621,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; @@ -632,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); @@ -673,6 +680,13 @@ 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) { @@ -707,16 +721,14 @@ end: } static -int handle_notification_channel(int fd, +int handle_notification_channel(int fd __attribute__((unused)), struct rotation_thread_handle *handle, - struct rotation_thread *state) + struct rotation_thread *state __attribute__((unused))) { int ret; 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); @@ -754,10 +766,7 @@ int handle_notification_channel(int fd, 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: