Fix: live_viewer_connection_create(): `lttng_live_msg_iter` can be `NULL`
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Mon, 29 Jul 2019 14:06:58 +0000 (10:06 -0400)
committerPhilippe Proulx <eeppeliteloop@gmail.com>
Wed, 31 Jul 2019 21:18:07 +0000 (17:18 -0400)
Because `lttng_live_msg_iter` can be `NULL` in
live_viewer_connection_create() when it's used from a query operation,
pass the log level to use directly and only read `self_comp` if
`lttng_live_msg_iter` exists.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Change-Id: Ied5ec621bcd066df0bb312a6f81899616f9d1a9f
Reviewed-on: https://review.lttng.org/c/babeltrace/+/1797

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 5946f064bd8b0b04a5ec8d542de625a3f64fea59..f13a5eabc301f9ac60a0f331c11b6e32af0ee269 100644 (file)
@@ -1337,7 +1337,7 @@ bt_component_class_message_iterator_init_method_status lttng_live_msg_iter_init(
 
        lttng_live_msg_iter->viewer_connection =
                live_viewer_connection_create(lttng_live->params.url->str, false,
-                       lttng_live_msg_iter);
+                       lttng_live_msg_iter, log_level);
        if (!lttng_live_msg_iter->viewer_connection) {
                goto error;
        }
@@ -1424,7 +1424,8 @@ bt_component_class_query_method_status lttng_live_query_list_sessions(
 
        url = bt_value_string_get(url_value);
 
-       viewer_connection = live_viewer_connection_create(url, true, NULL);
+       viewer_connection = live_viewer_connection_create(url, true, NULL,
+               log_level);
        if (!viewer_connection) {
                goto error;
        }
index 8c02be02faf4091cd35e8df27e015589334ea324..c7347020f30baf869583f36c7005c4e5e8504df3 100644 (file)
@@ -1466,18 +1466,23 @@ error:
 BT_HIDDEN
 struct live_viewer_connection *live_viewer_connection_create(
                const char *url, bool in_query,
-               struct lttng_live_msg_iter *lttng_live_msg_iter)
+               struct lttng_live_msg_iter *lttng_live_msg_iter,
+               bt_logging_level log_level)
 {
        struct live_viewer_connection *viewer_connection;
 
        viewer_connection = g_new0(struct live_viewer_connection, 1);
 
-       if (bt_socket_init(lttng_live_msg_iter->log_level) != 0) {
+       if (bt_socket_init(log_level) != 0) {
                goto error;
        }
 
-       viewer_connection->log_level = lttng_live_msg_iter->log_level;
-       viewer_connection->self_comp = lttng_live_msg_iter->self_comp;
+       viewer_connection->log_level = log_level;
+
+       if (lttng_live_msg_iter) {
+               viewer_connection->self_comp = lttng_live_msg_iter->self_comp;
+       }
+
        bt_object_init_shared(&viewer_connection->obj, connection_release);
        viewer_connection->control_sock = BT_INVALID_SOCKET;
        viewer_connection->port = -1;
index 549a900387d5eb611eb686ac367b997c62f8ef11..94073426fa91feaed946145389f279a2a4cb132f 100644 (file)
@@ -86,7 +86,8 @@ struct packet_index {
 
 struct live_viewer_connection * live_viewer_connection_create(
                const char *url, bool in_query,
-               struct lttng_live_msg_iter *lttng_live_msg_iter);
+               struct lttng_live_msg_iter *lttng_live_msg_iter,
+               bt_logging_level log_level);
 
 void live_viewer_connection_destroy(
                struct live_viewer_connection *conn);
This page took 0.027544 seconds and 4 git commands to generate.