#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 *);
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
*/
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,
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,
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
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,
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,
}
}
-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,
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;
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;
}
#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
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;