Move to kernel style SPDX license identifiers
[babeltrace.git] / src / lib / graph / connection.c
index d290e60450dd436c09a81681fe3d887cadd4850f..af480f255400bd855659b839f7a4fd0d1a35a9d4 100644 (file)
@@ -1,34 +1,20 @@
 /*
+ * SPDX-License-Identifier: MIT
+ *
  * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
  * Copyright 2017 Jérémie Galarneau <jeremie.galarneau@efficios.com>
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
  */
 
-#define BT_LOG_TAG "CONNECTION"
-#include "lib/lib-logging.h"
+#define BT_LOG_TAG "LIB/CONNECTION"
+#include "lib/logging.h"
 
 #include "common/assert.h"
 #include "lib/assert-pre.h"
-#include <babeltrace2/graph/connection-const.h>
+#include "lib/assert-post.h"
+#include <babeltrace2/graph/connection.h>
 #include "lib/object.h"
 #include "compat/compiler.h"
+#include <stdbool.h>
 #include <stdlib.h>
 #include <glib.h>
 
@@ -49,8 +35,7 @@ void destroy_connection(struct bt_object *obj)
        /*
         * Make sure that each message iterator which was created for
         * this connection is finalized before we destroy it. Once a
-        * message iterator is finalized, all its method return NULL or
-        * the BT_MESSAGE_ITERATOR_STATUS_CANCELED status.
+        * message iterator is finalized, you cannot use it.
         *
         * Because connections are destroyed before components within a
         * graph, this ensures that message iterators are always
@@ -125,7 +110,7 @@ struct bt_connection *bt_connection_create(struct bt_graph *graph,
                graph, upstream_port, downstream_port);
        connection = g_new0(struct bt_connection, 1);
        if (!connection) {
-               BT_LOGE_STR("Failed to allocate one connection.");
+               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one connection.");
                goto end;
        }
 
@@ -135,7 +120,7 @@ struct bt_connection *bt_connection_create(struct bt_graph *graph,
                parent_is_owner);
        connection->iterators = g_ptr_array_new();
        if (!connection->iterators) {
-               BT_LOGE_STR("Failed to allocate a GPtrArray.");
+               BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate a GPtrArray.");
                BT_OBJECT_PUT_REF_AND_RESET(connection);
                goto end;
        }
@@ -204,12 +189,12 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph)
         * which is on graph destruction.
         */
        for (i = 0; i < conn->iterators->len; i++) {
-               struct bt_self_component_port_input_message_iterator *iterator =
+               struct bt_message_iterator *iterator =
                        g_ptr_array_index(conn->iterators, i);
 
                BT_LIB_LOGD("Finalizing message iterator created by "
                        "this ended connection: %![iter-]+i", iterator);
-               bt_self_component_port_input_message_iterator_try_finalize(
+               bt_message_iterator_try_finalize(
                        iterator);
 
                /*
@@ -217,7 +202,7 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph)
                 * from this connection's iterators on destruction
                 * because this connection won't exist anymore.
                 */
-               bt_self_component_port_input_message_iterator_set_connection(
+               bt_message_iterator_set_connection(
                        iterator, NULL);
        }
 
@@ -231,20 +216,20 @@ void bt_connection_end(struct bt_connection *conn, bool try_remove_from_graph)
 const struct bt_port_output *bt_connection_borrow_upstream_port_const(
                const struct bt_connection *connection)
 {
-       BT_ASSERT_PRE_NON_NULL(connection, "Connection");
+       BT_ASSERT_PRE_DEV_NON_NULL(connection, "Connection");
        return (void *) connection->upstream_port;
 }
 
 const struct bt_port_input *bt_connection_borrow_downstream_port_const(
                const struct bt_connection *connection)
 {
-       BT_ASSERT_PRE_NON_NULL(connection, "Connection");
+       BT_ASSERT_PRE_DEV_NON_NULL(connection, "Connection");
        return (void *) connection->downstream_port;
 }
 
 BT_HIDDEN
 void bt_connection_remove_iterator(struct bt_connection *conn,
-               struct bt_self_component_port_input_message_iterator *iterator)
+               struct bt_message_iterator *iterator)
 {
        g_ptr_array_remove(conn->iterators, iterator);
        BT_LIB_LOGD("Removed message iterator from connection: "
This page took 0.024478 seconds and 4 git commands to generate.