Revert "Fix: sessiond: rotation trigger leak"
authorJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 22 Jun 2022 20:00:28 +0000 (16:00 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Wed, 22 Jun 2022 20:57:52 +0000 (16:57 -0400)
This reverts commit 69d5d2ae78d1835f4547a2946d226c2a7a2e513c.

The original leak does not exist in this version.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Change-Id: I73f4dff67e9d98f898c2143a4562d8e38cc1e042

include/lttng/notification/notification-internal.h
src/bin/lttng-sessiond/rotate.c
src/bin/lttng-sessiond/rotation-thread.c
src/bin/lttng-sessiond/session.c
src/bin/lttng-sessiond/session.h

index d7289fd7bbf460dc1b1023641deba92ee3669699..c50536dc6eafa399bb3350a75add68b3257007dc 100644 (file)
@@ -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 */
index 5e2eb5932a6a36e9f6781f0930d39cf88d91fb76..e2a3ef9eaac221ef97cc611004db602d7af347f0 100644 (file)
@@ -25,8 +25,6 @@
 
 #include <lttng/notification/channel-internal.h>
 #include <lttng/rotate-internal.h>
-#include <lttng/condition/condition-internal.h>
-#include <lttng/action/action-internal.h>
 
 #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;
index b6bf2def32d2314829356feed287f99b8ed98068..5e6042e85671b88ad0b12dd5ea848b51b84529c2 100644 (file)
@@ -27,7 +27,6 @@
 #include <lttng/rotate-internal.h>
 #include <lttng/location-internal.h>
 #include <lttng/condition/condition-internal.h>
-#include <lttng/notification/notification-internal.h>
 
 #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, &notification_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:
index e87f4c18a2ac9cc6d88f2180e5f86e55c692bfeb..174301b2bb39b7a592c7ad47504cda5c88c116b9 100644 (file)
@@ -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) {
                /*
index de4d8229ed1a37219d6d5042b1c16a56d02501f3..aed5e1a1c8bfaf4a34fba8cdc21922ca30640123 100644 (file)
@@ -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;
This page took 0.03112 seconds and 4 git commands to generate.