lttng-live: ensure that port connections go to the same component
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mon, 15 May 2017 21:33:38 +0000 (17:33 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Sun, 28 May 2017 16:57:43 +0000 (12:57 -0400)
Also has tiny cleanups.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
plugins/ctf/lttng-live/lttng-live-internal.h
plugins/ctf/lttng-live/lttng-live.c
plugins/ctf/plugin.c

index 3d8b5fa71c07f20b503b11bd5540f92c6dd868a3..6b2d71fb86a4554b5d8a3ba30e0cfe078f4504b3 100644 (file)
@@ -191,6 +191,8 @@ struct lttng_live_component {
 
        struct bt_private_port *no_stream_port;
        struct lttng_live_no_stream_iterator *no_stream_iter;
+
+       struct bt_component *downstream_component;
 };
 
 enum bt_ctf_lttng_live_iterator_status {
@@ -212,7 +214,6 @@ enum bt_ctf_lttng_live_iterator_status {
        BT_CTF_LTTNG_LIVE_ITERATOR_STATUS_UNSUPPORTED = -4,
 };
 
-BT_HIDDEN
 enum bt_component_status lttng_live_component_init(struct bt_private_component *source,
                struct bt_value *params, void *init_method_data);
 
@@ -221,10 +222,13 @@ struct bt_value *lttng_live_query(struct bt_component_class *comp_class,
 
 void lttng_live_component_finalize(struct bt_private_component *component);
 
-BT_HIDDEN
 struct bt_notification_iterator_next_return lttng_live_iterator_next(
         struct bt_private_notification_iterator *iterator);
 
+enum bt_component_status lttng_live_accept_port_connection(
+               struct bt_private_component *private_component,
+               struct bt_private_port *self_private_port,
+               struct bt_port *other_port);
 
 enum bt_notification_iterator_status lttng_live_iterator_init(
                struct bt_private_notification_iterator *it,
index 7c1d22a4385e284a64736c65b8d0cfdb280fb665..813674fae1512be27a12d98609f67b1892147391 100644 (file)
@@ -1063,6 +1063,43 @@ error:
        return ret;
 }
 
+BT_HIDDEN
+enum bt_component_status lttng_live_accept_port_connection(
+               struct bt_private_component *private_component,
+               struct bt_private_port *self_private_port,
+               struct bt_port *other_port)
+{
+       struct lttng_live_component *lttng_live =
+                       bt_private_component_get_user_data(private_component);
+       struct bt_component *other_component;
+       enum bt_component_status status = BT_COMPONENT_STATUS_OK;
+       struct bt_port *self_port = bt_port_from_private_port(self_private_port);
+
+       other_component = bt_port_get_component(other_port);
+       bt_put(other_component);        /* weak */
+
+       if (!lttng_live->downstream_component) {
+               lttng_live->downstream_component = other_component;
+               goto end;
+       }
+
+       /*
+        * Compare prior component to ensure we are connected to the
+        * same downstream component as prior ports.
+        */
+       if (lttng_live->downstream_component != other_component) {
+               BT_LOGW("Cannot connect ctf.lttng-live component port \"%s\" to component \"%s\": already connected to component \"%s\".",
+                       bt_port_get_name(self_port),
+                       bt_component_get_name(other_component),
+                       bt_component_get_name(lttng_live->downstream_component));
+               status = BT_COMPONENT_STATUS_REFUSE_PORT_CONNECTION;
+               goto end;
+       }
+end:
+       bt_put(self_port);
+       return status;
+}
+
 static
 void __attribute__((constructor)) bt_lttng_live_logging_ctor(void)
 {
@@ -1085,6 +1122,10 @@ void __attribute__((constructor)) bt_lttng_live_logging_ctor(void)
                log_level = BT_LOGGING_LEVEL_ERROR;
        } else if (strcmp(log_level_env, "FATAL") == 0) {
                log_level = BT_LOGGING_LEVEL_FATAL;
+       } else {
+               bt_lttng_live_log_level = BT_LOGGING_LEVEL_FATAL;
+               BT_LOGF("Incorrect log level specified in BABELTRACE_PLUGIN_LTTNG_LIVE_LOG_LEVEL");
+               abort();
        }
 
         bt_lttng_live_log_level = log_level;
index 63f7f8b326673efb8d05238cca2afb138678240b..789f3c7eecef87631881da86028304bc4ba0b592 100644 (file)
@@ -68,6 +68,8 @@ BT_PLUGIN_SOURCE_COMPONENT_CLASS_QUERY_METHOD_WITH_ID(auto, lttng_live,
        lttng_live_query);
 BT_PLUGIN_SOURCE_COMPONENT_CLASS_FINALIZE_METHOD_WITH_ID(auto, lttng_live,
        lttng_live_component_finalize);
+BT_PLUGIN_SOURCE_COMPONENT_CLASS_ACCEPT_PORT_CONNECTION_METHOD_WITH_ID(auto,
+       lttng_live, lttng_live_accept_port_connection);
 BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_INIT_METHOD_WITH_ID(
        auto, lttng_live, lttng_live_iterator_init);
 BT_PLUGIN_SOURCE_COMPONENT_CLASS_NOTIFICATION_ITERATOR_FINALIZE_METHOD_WITH_ID(
This page took 0.026427 seconds and 4 git commands to generate.