src.ctf.lttng-live: add lttng_live_session destructor
authorSimon Marchi <simon.marchi@efficios.com>
Thu, 7 Dec 2023 05:24:55 +0000 (05:24 +0000)
committerSimon Marchi <simon.marchi@efficios.com>
Wed, 17 Apr 2024 17:57:53 +0000 (13:57 -0400)
Convert lttng_live_destroy_session to a destructor.  Add a new
lttng_live_destroy_session function that calls delete, it's still needed
for the GPtrArray (which will be removed in a subsequent patch).

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Change-Id: Icb2d9c33fb3591e206698b37c9d658ff731184ad
Reviewed-on: https://review.lttng.org/c/babeltrace/+/8466
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12381
Tested-by: jenkins <jenkins@lttng.org>
src/plugins/ctf/lttng-live/lttng-live.cpp
src/plugins/ctf/lttng-live/lttng-live.hpp

index 41aea66a670ec53d460f96e4ba7c7ef7f290b91b..a8390a3457cc74becda7562f8ba06dece6973d25 100644 (file)
@@ -138,29 +138,26 @@ int lttng_live_add_session(struct lttng_live_msg_iter *lttng_live_msg_iter, uint
     return 0;
 }
 
-static void lttng_live_destroy_session(struct lttng_live_session *session)
+lttng_live_session::~lttng_live_session()
 {
-    if (!session) {
-        goto end;
-    }
+    BT_CPPLOGD_SPEC(this->logger, "Destroying live session: session-id={}, session-name=\"{}\"",
+                    this->id, this->session_name);
 
-    BT_CPPLOGD_SPEC(session->logger, "Destroying live session: session-id={}, session-name=\"{}\"",
-                    session->id, session->session_name);
-    if (session->id != -1ULL) {
-        if (lttng_live_session_detach(session)) {
-            if (!lttng_live_graph_is_canceled(session->lttng_live_msg_iter)) {
+    if (this->id != -1ULL) {
+        if (lttng_live_session_detach(this)) {
+            if (!lttng_live_graph_is_canceled(this->lttng_live_msg_iter)) {
                 /* Old relayd cannot detach sessions. */
-                BT_CPPLOGD_SPEC(session->logger, "Unable to detach lttng live session {}",
-                                session->id);
+                BT_CPPLOGD_SPEC(this->logger, "Unable to detach lttng live session {}", this->id);
             }
         }
-        session->id = -1ULL;
+
+        this->id = -1ULL;
     }
+}
 
+static void lttng_live_destroy_session(struct lttng_live_session *session)
+{
     delete session;
-
-end:
-    return;
 }
 
 static void lttng_live_msg_iter_destroy(struct lttng_live_msg_iter *lttng_live_msg_iter)
index 8e1312b5fed4dc937872e5b60c62251d7436bc21..3bbcd0ef4ff11748d0e791856c79f1676bb8c2c0 100644 (file)
@@ -213,6 +213,8 @@ struct lttng_live_session
     {
     }
 
+    ~lttng_live_session();
+
     bt2c::Logger logger;
 
     bt_self_component *self_comp = nullptr;
This page took 0.025529 seconds and 4 git commands to generate.