Cleanup: src.ctf.lttng-live: remove usage of `bt_object`
authorFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 31 Oct 2019 15:40:27 +0000 (11:40 -0400)
committerFrancis Deslauriers <francis.deslauriers@efficios.com>
Thu, 31 Oct 2019 20:49:05 +0000 (16:49 -0400)
The live_viewer_connection objects are never shared and we can know that
by seeing that there is no to _get_ref() in this entire component class.

This commit also removes the need for the BT_OBJECT_DONT_LOG macro added
by:
    commit 9358ceb38baa2d50a69d7ee580463a2ddba25465
    Author: Philippe Proulx <eeppeliteloop@gmail.com>
    lib/object.h: log conditionally to `BT_OBJECT_DONT_LOG` undefined

so remove that to.

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Change-Id: I2b4ba20613e77048044507a93241bf7db3f58fa2
Reviewed-on: https://review.lttng.org/c/babeltrace/+/2312
Tested-by: jenkins <jenkins@lttng.org>
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
src/lib/object.h
src/plugins/ctf/lttng-live/lttng-live.c
src/plugins/ctf/lttng-live/viewer-connection.c
src/plugins/ctf/lttng-live/viewer-connection.h

index 9d584c1bfd311bf2424fa5364fd1819a7ed1eea1..c7cbb123f82b673a17ee89c91bed7dbc7e1b65b9 100644 (file)
 #include "common/assert.h"
 #include <stdbool.h>
 
-/*
- * Some parts of the Babeltrace project use this internal library header
- * for internal reference counting. Until we make this header generic
- * for the whole project, make it possible to disable logging in this
- * file by defining `BT_OBJECT_DONT_LOG` because it's possible that the
- * BT_LOGT() statements here won't find the log level
- * (`BT_LOG_OUTPUT_LEVEL`).
- */
-#if defined(BT_LOGT) && !defined(BT_OBJECT_DONT_LOG)
-# define _BT_OBJECT_LOGGING_ENABLED
-#endif
-
 struct bt_object;
 
 typedef void (*bt_object_release_func)(struct bt_object *);
@@ -138,7 +126,7 @@ void bt_object_set_parent(struct bt_object *child, struct bt_object *parent)
        BT_ASSERT_DBG(child);
        BT_ASSERT_DBG(child->is_shared);
 
-#ifdef _BT_OBJECT_LOGGING_ENABLED
+#ifdef BT_LOGT
        BT_LOGT("Setting object's parent: addr=%p, parent-addr=%p",
                child, parent);
 #endif
@@ -185,7 +173,7 @@ void bt_object_with_parent_release_func(struct bt_object *obj)
                 */
                struct bt_object *parent = obj->parent;
 
-#ifdef _BT_OBJECT_LOGGING_ENABLED
+#ifdef BT_LOGT
                BT_LOGT("Releasing parented object: addr=%p, ref-count=%llu, "
                        "parent-addr=%p, parent-ref-count=%llu",
                        obj, obj->ref_count,
@@ -275,7 +263,7 @@ void bt_object_get_ref_no_null_check_no_parent_check(const struct bt_object *c_o
        BT_ASSERT_DBG(obj);
        BT_ASSERT_DBG(obj->is_shared);
 
-#ifdef _BT_OBJECT_LOGGING_ENABLED
+#ifdef BT_LOGT
        BT_LOGT("Incrementing object's reference count: %llu -> %llu: "
                "addr=%p, cur-count=%llu, new-count=%llu",
                obj->ref_count, obj->ref_count + 1,
@@ -294,7 +282,7 @@ void bt_object_get_ref_no_null_check(const void *c_obj)
        BT_ASSERT_DBG(obj->is_shared);
 
        if (G_UNLIKELY(obj->parent && bt_object_get_ref_count(obj) == 0)) {
-#ifdef _BT_OBJECT_LOGGING_ENABLED
+#ifdef BT_LOGT
                BT_LOGT("Incrementing object's parent's reference count: "
                        "addr=%p, parent-addr=%p", obj, obj->parent);
 #endif
@@ -302,7 +290,7 @@ void bt_object_get_ref_no_null_check(const void *c_obj)
                bt_object_get_ref_no_null_check(obj->parent);
        }
 
-#ifdef _BT_OBJECT_LOGGING_ENABLED
+#ifdef BT_LOGT
        BT_LOGT("Incrementing object's reference count: %llu -> %llu: "
                "addr=%p, cur-count=%llu, new-count=%llu",
                obj->ref_count, obj->ref_count + 1,
@@ -321,7 +309,7 @@ void bt_object_put_ref_no_null_check(const void *c_obj)
        BT_ASSERT_DBG(obj->is_shared);
        BT_ASSERT_DBG(obj->ref_count > 0);
 
-#ifdef _BT_OBJECT_LOGGING_ENABLED
+#ifdef BT_LOGT
        BT_LOGT("Decrementing object's reference count: %llu -> %llu: "
                "addr=%p, cur-count=%llu, new-count=%llu",
                obj->ref_count, obj->ref_count - 1,
index d12b674d3f3c7c754531f4eef2ad54b4e3b7233a..87efe7a681784a463df969d2ceae039c794daca1 100644 (file)
@@ -316,7 +316,9 @@ void lttng_live_msg_iter_destroy(struct lttng_live_msg_iter *lttng_live_msg_iter
                g_ptr_array_free(lttng_live_msg_iter->sessions, TRUE);
        }
 
-       BT_OBJECT_PUT_REF_AND_RESET(lttng_live_msg_iter->viewer_connection);
+       if (lttng_live_msg_iter->viewer_connection) {
+               live_viewer_connection_destroy(lttng_live_msg_iter->viewer_connection);
+       }
        BT_ASSERT(lttng_live_msg_iter->lttng_live_comp);
        BT_ASSERT(lttng_live_msg_iter->lttng_live_comp->has_msg_iter);
 
index 6fa1456f593fb1fc28f18e75555fb21c65362421..befffb30a8c6117c096f9df086c7ff12823781ad 100644 (file)
@@ -316,15 +316,6 @@ void lttng_live_disconnect_viewer(
        }
 }
 
-static
-void connection_release(bt_object *obj)
-{
-       struct live_viewer_connection *conn =
-               container_of(obj, struct live_viewer_connection, obj);
-
-       live_viewer_connection_destroy(conn);
-}
-
 static
 int list_update_session(bt_value *results,
                const struct lttng_viewer_session *session,
@@ -1611,7 +1602,6 @@ struct live_viewer_connection *live_viewer_connection_create(
        viewer_connection->self_comp = self_comp;
        viewer_connection->self_comp_class = self_comp_class;
 
-       bt_object_init_shared(&viewer_connection->obj, connection_release);
        viewer_connection->control_sock = BT_INVALID_SOCKET;
        viewer_connection->port = -1;
        viewer_connection->in_query = in_query;
@@ -1646,20 +1636,33 @@ void live_viewer_connection_destroy(
                struct live_viewer_connection *viewer_connection)
 {
        BT_COMP_LOGI("Closing connection to url \"%s\"", viewer_connection->url->str);
+
+       if (!viewer_connection) {
+               goto end;
+       }
+
        lttng_live_disconnect_viewer(viewer_connection);
+
        if (viewer_connection->url) {
                g_string_free(viewer_connection->url, true);
        }
+
        if (viewer_connection->relay_hostname) {
                g_string_free(viewer_connection->relay_hostname, true);
        }
+
        if (viewer_connection->target_hostname) {
                g_string_free(viewer_connection->target_hostname, true);
        }
+
        if (viewer_connection->session_name) {
                g_string_free(viewer_connection->session_name, true);
        }
+
        g_free(viewer_connection);
 
        bt_socket_fini();
+
+end:
+       return;
 }
index fcdd4c4dbddc96cb7b22191a3b672844f4c13c87..c42c16b05cfd8187e92147f1920a8d263c813d2f 100644 (file)
 #include "common/macros.h"
 #include "compat/socket.h"
 
-/*
- * FIXME: This is an internal Babeltrace library header; it is not meant
- * to be generic as it is now. Make sure this included code does not
- * log because it won't find our local log level.
- */
-#define BT_OBJECT_DONT_LOG
-#include "lib/object.h"
-
 #define LTTNG_DEFAULT_NETWORK_VIEWER_PORT      5344
 
 #define LTTNG_LIVE_MAJOR                       2
@@ -46,7 +38,6 @@
 struct lttng_live_component;
 
 struct live_viewer_connection {
-       bt_object obj;
        bt_logging_level log_level;
        bt_self_component *self_comp;
        bt_self_component_class *self_comp_class;
This page took 0.030237 seconds and 4 git commands to generate.