From: Jérémie Galarneau Date: Wed, 22 Jun 2022 20:00:28 +0000 (-0400) Subject: Revert "Fix: sessiond: rotation trigger leak" X-Git-Tag: v2.12.12~7 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b7238f7cfdcc67f4c254c03004989156c13c4c15;p=lttng-tools.git Revert "Fix: sessiond: rotation trigger leak" This reverts commit 69d5d2ae78d1835f4547a2946d226c2a7a2e513c. The original leak does not exist in this version. Signed-off-by: Jérémie Galarneau Change-Id: I73f4dff67e9d98f898c2143a4562d8e38cc1e042 --- diff --git a/include/lttng/notification/notification-internal.h b/include/lttng/notification/notification-internal.h index d7289fd7b..c50536dc6 100644 --- a/include/lttng/notification/notification-internal.h +++ b/include/lttng/notification/notification-internal.h @@ -42,12 +42,4 @@ ssize_t lttng_notification_create_from_buffer( const struct lttng_buffer_view *view, struct lttng_notification **notification); -const struct lttng_condition *lttng_notification_get_const_condition( - const struct lttng_notification *notification); -const struct lttng_evaluation *lttng_notification_get_const_evaluation( - const struct lttng_notification *notification); - -const struct lttng_trigger *lttng_notification_get_const_trigger( - const struct lttng_notification *notification); - #endif /* LTTNG_NOTIFICATION_INTERNAL_H */ diff --git a/src/bin/lttng-sessiond/rotate.c b/src/bin/lttng-sessiond/rotate.c index 5e2eb5932..e2a3ef9ea 100644 --- a/src/bin/lttng-sessiond/rotate.c +++ b/src/bin/lttng-sessiond/rotate.c @@ -25,8 +25,6 @@ #include #include -#include -#include #include "session.h" #include "rotate.h" @@ -47,22 +45,17 @@ int subscribe_session_consumed_size_rotation(struct ltt_session *session, uint64 int ret; enum lttng_condition_status condition_status; enum lttng_notification_channel_status nc_status; - struct lttng_condition *rotate_condition = NULL; - struct lttng_action *notify_action = NULL; - const struct lttng_credentials session_creds = { - .uid = LTTNG_OPTIONAL_INIT_VALUE(session->uid), - .gid = LTTNG_OPTIONAL_INIT_VALUE(session->gid), - }; - - rotate_condition = lttng_condition_session_consumed_size_create(); - if (!rotate_condition) { + struct lttng_action *action; + + session->rotate_condition = lttng_condition_session_consumed_size_create(); + if (!session->rotate_condition) { ERR("Failed to create session consumed size condition object"); ret = -1; goto end; } condition_status = lttng_condition_session_consumed_size_set_threshold( - rotate_condition, size); + session->rotate_condition, size); if (condition_status != LTTNG_CONDITION_STATUS_OK) { ERR("Could not set session consumed size condition threshold (size = %" PRIu64 ")", size); @@ -72,7 +65,7 @@ int subscribe_session_consumed_size_rotation(struct ltt_session *session, uint64 condition_status = lttng_condition_session_consumed_size_set_session_name( - rotate_condition, session->name); + session->rotate_condition, session->name); if (condition_status != LTTNG_CONDITION_STATUS_OK) { ERR("Could not set session consumed size condition session name (name = %s)", session->name); @@ -80,16 +73,15 @@ int subscribe_session_consumed_size_rotation(struct ltt_session *session, uint64 goto end; } - notify_action = lttng_action_notify_create(); - if (!notify_action) { + action = lttng_action_notify_create(); + if (!action) { ERR("Could not create notify action"); ret = -1; goto end; } - assert(!session->rotate_trigger); - session->rotate_trigger = lttng_trigger_create(rotate_condition, - notify_action); + session->rotate_trigger = lttng_trigger_create(session->rotate_condition, + action); if (!session->rotate_trigger) { ERR("Could not create size-based rotation trigger"); ret = -1; @@ -97,7 +89,7 @@ int subscribe_session_consumed_size_rotation(struct ltt_session *session, uint64 } nc_status = lttng_notification_channel_subscribe( - rotate_notification_channel, rotate_condition); + rotate_notification_channel, session->rotate_condition); if (nc_status != LTTNG_NOTIFICATION_CHANNEL_STATUS_OK) { ERR("Could not subscribe to session consumed size notification"); ret = -1; @@ -115,11 +107,6 @@ int subscribe_session_consumed_size_rotation(struct ltt_session *session, uint64 ret = 0; end: - lttng_condition_put(rotate_condition); - lttng_action_put(notify_action); - if (ret) { - lttng_trigger_put(session->rotate_trigger); - } return ret; } @@ -129,10 +116,9 @@ int unsubscribe_session_consumed_size_rotation(struct ltt_session *session, int ret = 0; enum lttng_notification_channel_status status; - assert(session->rotate_trigger); status = lttng_notification_channel_unsubscribe( rotate_notification_channel, - lttng_trigger_get_const_condition(session->rotate_trigger)); + session->rotate_condition); if (status != LTTNG_NOTIFICATION_CHANNEL_STATUS_OK) { ERR("Session unsubscribe error: %d", (int) status); ret = -1; @@ -146,9 +132,6 @@ int unsubscribe_session_consumed_size_rotation(struct ltt_session *session, goto end; } - lttng_trigger_put(session->rotate_trigger); - session->rotate_trigger = NULL; - ret = 0; end: return ret; diff --git a/src/bin/lttng-sessiond/rotation-thread.c b/src/bin/lttng-sessiond/rotation-thread.c index b6bf2def3..5e6042e85 100644 --- a/src/bin/lttng-sessiond/rotation-thread.c +++ b/src/bin/lttng-sessiond/rotation-thread.c @@ -27,7 +27,6 @@ #include #include #include -#include #include "rotation-thread.h" #include "lttng-sessiond.h" @@ -623,7 +622,8 @@ end: } static -int handle_condition(const struct lttng_notification *notification, +int handle_condition(const struct lttng_condition *condition, + const struct lttng_evaluation *evaluation, struct notification_thread_handle *notification_thread_handle) { int ret = 0; @@ -633,10 +633,6 @@ int handle_condition(const struct lttng_notification *notification, 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); @@ -677,13 +673,6 @@ int handle_condition(const struct lttng_notification *notification, } 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) { @@ -726,6 +715,8 @@ int handle_notification_channel(int fd, 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); @@ -763,7 +754,10 @@ int handle_notification_channel(int fd, goto end; } - ret = handle_condition(notification, + notification_condition = lttng_notification_get_condition(notification); + notification_evaluation = lttng_notification_get_evaluation(notification); + + ret = handle_condition(notification_condition, notification_evaluation, handle->notification_thread_handle); end: diff --git a/src/bin/lttng-sessiond/session.c b/src/bin/lttng-sessiond/session.c index e87f4c18a..174301b2b 100644 --- a/src/bin/lttng-sessiond/session.c +++ b/src/bin/lttng-sessiond/session.c @@ -983,7 +983,6 @@ void session_release(struct urcu_ref *ref) lttng_dynamic_array_reset(&session->clear_notifiers); free(session->last_archived_chunk_name); free(session->base_path); - lttng_trigger_put(session->rotate_trigger); free(session); if (session_published) { /* diff --git a/src/bin/lttng-sessiond/session.h b/src/bin/lttng-sessiond/session.h index de4d8229e..aed5e1a1c 100644 --- a/src/bin/lttng-sessiond/session.h +++ b/src/bin/lttng-sessiond/session.h @@ -177,8 +177,9 @@ struct ltt_session { */ bool rotated; /* - * Trigger for size-based rotations. + * Condition and trigger for size-based rotations. */ + struct lttng_condition *rotate_condition; struct lttng_trigger *rotate_trigger; LTTNG_OPTIONAL(uint64_t) most_recent_chunk_id; struct lttng_trace_chunk *current_trace_chunk;