X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=lib%2Fgraph%2Fport.c;h=a04049a1cf4616f831764511f90ba190d4ae582b;hb=4725a2013cb518374822ccb490610b45f74dbdbf;hp=01ee3944fc62bc83d101545da44266055e966399;hpb=e2f7325d1e58710ee928373592adcee466f93d06;p=babeltrace.git diff --git a/lib/graph/port.c b/lib/graph/port.c index 01ee3944..a04049a1 100644 --- a/lib/graph/port.c +++ b/lib/graph/port.c @@ -24,6 +24,8 @@ #define BT_LOG_TAG "PORT" #include +#include +#include #include #include #include @@ -34,10 +36,7 @@ #include #include #include -#include #include -#include -#include static void destroy_port(struct bt_object *obj) @@ -138,26 +137,34 @@ void bt_port_set_connection(struct bt_port *port, connection); } -enum bt_self_component_port_status bt_self_component_port_remove_from_component( - struct bt_self_component_port *self_port) +static inline +bool port_connection_iterators_are_finalized(struct bt_port *port) { - struct bt_port *port = (void *) self_port; - struct bt_component *comp = NULL; + bool ret = true; + struct bt_connection *conn = port->connection; + uint64_t i; - BT_ASSERT_PRE_NON_NULL(port, "Port"); - - comp = (void *) bt_object_borrow_parent(&port->base); - if (!comp) { - BT_LIB_LOGV("Port already removed from its component: %!+p", - port); + if (!conn) { goto end; } - /* bt_component_remove_port() logs details */ - bt_component_remove_port(comp, port); + for (i = 0; i < conn->iterators->len; i++) { + struct bt_self_component_port_input_message_iterator *iterator = + conn->iterators->pdata[i]; + + BT_ASSERT(iterator); + + if (iterator->state != BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZING && + iterator->state != BT_SELF_COMPONENT_PORT_INPUT_MESSAGE_ITERATOR_STATE_FINALIZED) { + BT_ASSERT_PRE_MSG("Message iterator is not being finalized or finalized: " + "%!+i", iterator); + ret = false; + goto end; + } + } end: - return BT_SELF_PORT_STATUS_OK; + return ret; } bt_bool bt_port_is_connected(const struct bt_port *port) @@ -171,3 +178,33 @@ void *bt_self_component_port_get_data(const struct bt_self_component_port *port) BT_ASSERT_PRE_NON_NULL(port, "Port"); return ((struct bt_port *) port)->user_data; } + +void bt_port_get_ref(const struct bt_port *port) +{ + bt_object_get_ref(port); +} + +void bt_port_put_ref(const struct bt_port *port) +{ + bt_object_put_ref(port); +} + +void bt_port_input_get_ref(const struct bt_port_input *port_input) +{ + bt_object_get_ref(port_input); +} + +void bt_port_input_put_ref(const struct bt_port_input *port_input) +{ + bt_object_put_ref(port_input); +} + +void bt_port_output_get_ref(const struct bt_port_output *port_output) +{ + bt_object_get_ref(port_output); +} + +void bt_port_output_put_ref(const struct bt_port_output *port_output) +{ + bt_object_put_ref(port_output); +}