X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=blobdiff_plain;f=src%2Flib%2Fplugin%2Fplugin-so.c;h=6025bdec19ae829ab2922301467d4518fa1d35b9;hp=24590cf2041d985237292cfde7e4f23a534ecf25;hb=0235b0db7de5bcacdb3650c92461f2ce5eb2143d;hpb=829fbd63d69b11e1923a62dc52ad0f16945b1b55 diff --git a/src/lib/plugin/plugin-so.c b/src/lib/plugin/plugin-so.c index 24590cf2..6025bdec 100644 --- a/src/lib/plugin/plugin-so.c +++ b/src/lib/plugin/plugin-so.c @@ -1,26 +1,8 @@ /* + * SPDX-License-Identifier: MIT + * * Copyright 2017-2018 Philippe Proulx * Copyright 2016 Jérémie Galarneau - * - * Author: Jérémie Galarneau - * - * 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 "LIB/PLUGIN-SO" @@ -32,12 +14,10 @@ #include #include "lib/graph/component-class.h" #include -#include -#include -#include #include #include "common/list.h" #include +#include #include #include #include @@ -86,6 +66,11 @@ BT_PLUGIN_MODULE(); * component class is removed from this list, the shared library handle * object's reference count falls to zero and the shared library is * finally closed. + * + * We're not using a GLib linked list here because this destructor is + * called after GLib's thread-specific data is destroyed, which contains + * the allocated memory for GLib data structures (what's used by + * g_slice_alloc()). */ static @@ -173,7 +158,7 @@ int bt_plugin_so_shared_lib_handle_create( int status = BT_FUNC_STATUS_OK; BT_ASSERT(shared_lib_handle); - BT_LOGI("Creating shared library handle: path=\"%s\"", path); + BT_LOGI("Creating shared library handle: path=\"%s\"", path ? path : "(null)"); *shared_lib_handle = g_new0(struct bt_plugin_so_shared_lib_handle, 1); if (!*shared_lib_handle) { BT_LIB_LOGE_APPEND_CAUSE("Failed to allocate one shared library handle."); @@ -217,7 +202,7 @@ end: BT_ASSERT(*shared_lib_handle || status != BT_FUNC_STATUS_OK); if (*shared_lib_handle) { BT_LOGI("Created shared library handle: path=\"%s\", addr=%p", - path, *shared_lib_handle); + path ? path : "(null)", *shared_lib_handle); } return status; @@ -288,34 +273,37 @@ int bt_plugin_so_init(struct bt_plugin *plugin, union { struct { - bt_component_class_source_init_method init; + bt_component_class_source_get_supported_mip_versions_method get_supported_mip_versions; + bt_component_class_source_initialize_method init; bt_component_class_source_finalize_method finalize; bt_component_class_source_query_method query; bt_component_class_source_output_port_connected_method output_port_connected; - bt_component_class_source_message_iterator_init_method msg_iter_init; - bt_component_class_source_message_iterator_finalize_method msg_iter_finalize; - bt_component_class_source_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; - bt_component_class_source_message_iterator_seek_beginning_method msg_iter_seek_beginning; - bt_component_class_source_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; - bt_component_class_source_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning; + bt_message_iterator_class_initialize_method msg_iter_initialize; + bt_message_iterator_class_finalize_method msg_iter_finalize; + bt_message_iterator_class_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; + bt_message_iterator_class_seek_beginning_method msg_iter_seek_beginning; + bt_message_iterator_class_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; + bt_message_iterator_class_can_seek_beginning_method msg_iter_can_seek_beginning; } source; struct { - bt_component_class_filter_init_method init; + bt_component_class_filter_get_supported_mip_versions_method get_supported_mip_versions; + bt_component_class_filter_initialize_method init; bt_component_class_filter_finalize_method finalize; bt_component_class_filter_query_method query; bt_component_class_filter_input_port_connected_method input_port_connected; bt_component_class_filter_output_port_connected_method output_port_connected; - bt_component_class_filter_message_iterator_init_method msg_iter_init; - bt_component_class_filter_message_iterator_finalize_method msg_iter_finalize; - bt_component_class_filter_message_iterator_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; - bt_component_class_filter_message_iterator_seek_beginning_method msg_iter_seek_beginning; - bt_component_class_filter_message_iterator_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; - bt_component_class_filter_message_iterator_can_seek_beginning_method msg_iter_can_seek_beginning; + bt_message_iterator_class_initialize_method msg_iter_initialize; + bt_message_iterator_class_finalize_method msg_iter_finalize; + bt_message_iterator_class_seek_ns_from_origin_method msg_iter_seek_ns_from_origin; + bt_message_iterator_class_seek_beginning_method msg_iter_seek_beginning; + bt_message_iterator_class_can_seek_ns_from_origin_method msg_iter_can_seek_ns_from_origin; + bt_message_iterator_class_can_seek_beginning_method msg_iter_can_seek_beginning; } filter; struct { - bt_component_class_sink_init_method init; + bt_component_class_sink_get_supported_mip_versions_method get_supported_mip_versions; + bt_component_class_sink_initialize_method init; bt_component_class_sink_finalize_method finalize; bt_component_class_sink_query_method query; bt_component_class_sink_input_port_connected_method input_port_connected; @@ -332,6 +320,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, GArray *comp_class_full_descriptors; size_t i; int ret; + struct bt_message_iterator_class *msg_iter_class = NULL; BT_LOGI("Initializing plugin object from descriptors found in sections: " "plugin-addr=%p, plugin-path=\"%s\", " @@ -488,22 +477,40 @@ int bt_plugin_so_init(struct bt_plugin *plugin, cc_full_descr->help = cur_cc_descr_attr->value.help; break; - case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD: + case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GET_SUPPORTED_MIP_VERSIONS_METHOD: + switch (cc_type) { + case BT_COMPONENT_CLASS_TYPE_SOURCE: + cc_full_descr->methods.source.get_supported_mip_versions = + cur_cc_descr_attr->value.source_get_supported_mip_versions_method; + break; + case BT_COMPONENT_CLASS_TYPE_FILTER: + cc_full_descr->methods.filter.get_supported_mip_versions = + cur_cc_descr_attr->value.filter_get_supported_mip_versions_method; + break; + case BT_COMPONENT_CLASS_TYPE_SINK: + cc_full_descr->methods.sink.get_supported_mip_versions = + cur_cc_descr_attr->value.sink_get_supported_mip_versions_method; + break; + default: + bt_common_abort(); + } + break; + case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INITIALIZE_METHOD: switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: cc_full_descr->methods.source.init = - cur_cc_descr_attr->value.source_init_method; + cur_cc_descr_attr->value.source_initialize_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: cc_full_descr->methods.filter.init = - cur_cc_descr_attr->value.filter_init_method; + cur_cc_descr_attr->value.filter_initialize_method; break; case BT_COMPONENT_CLASS_TYPE_SINK: cc_full_descr->methods.sink.init = - cur_cc_descr_attr->value.sink_init_method; + cur_cc_descr_attr->value.sink_initialize_method; break; default: - abort(); + bt_common_abort(); } break; case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD: @@ -521,7 +528,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, cur_cc_descr_attr->value.sink_finalize_method; break; default: - abort(); + bt_common_abort(); } break; case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD: @@ -539,7 +546,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, cur_cc_descr_attr->value.sink_query_method; break; default: - abort(); + bt_common_abort(); } break; case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD: @@ -553,7 +560,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, cur_cc_descr_attr->value.sink_input_port_connected_method; break; default: - abort(); + bt_common_abort(); } break; case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD: @@ -567,7 +574,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, cur_cc_descr_attr->value.filter_output_port_connected_method; break; default: - abort(); + bt_common_abort(); } break; case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_GRAPH_IS_CONFIGURED_METHOD: @@ -577,91 +584,91 @@ int bt_plugin_so_init(struct bt_plugin *plugin, cur_cc_descr_attr->value.sink_graph_is_configured_method; break; default: - abort(); + bt_common_abort(); } break; - case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD: + case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INITIALIZE_METHOD: switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: - cc_full_descr->methods.source.msg_iter_init = - cur_cc_descr_attr->value.source_msg_iter_init_method; + cc_full_descr->methods.source.msg_iter_initialize = + cur_cc_descr_attr->value.msg_iter_initialize_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: - cc_full_descr->methods.filter.msg_iter_init = - cur_cc_descr_attr->value.filter_msg_iter_init_method; + cc_full_descr->methods.filter.msg_iter_initialize = + cur_cc_descr_attr->value.msg_iter_initialize_method; break; default: - abort(); + bt_common_abort(); } break; case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD: switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: cc_full_descr->methods.source.msg_iter_finalize = - cur_cc_descr_attr->value.source_msg_iter_finalize_method; + cur_cc_descr_attr->value.msg_iter_finalize_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: cc_full_descr->methods.filter.msg_iter_finalize = - cur_cc_descr_attr->value.filter_msg_iter_finalize_method; + cur_cc_descr_attr->value.msg_iter_finalize_method; break; default: - abort(); + bt_common_abort(); } break; case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_NS_FROM_ORIGIN_METHOD: switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: cc_full_descr->methods.source.msg_iter_seek_ns_from_origin = - cur_cc_descr_attr->value.source_msg_iter_seek_ns_from_origin_method; + cur_cc_descr_attr->value.msg_iter_seek_ns_from_origin_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin = - cur_cc_descr_attr->value.filter_msg_iter_seek_ns_from_origin_method; + cur_cc_descr_attr->value.msg_iter_seek_ns_from_origin_method; break; default: - abort(); + bt_common_abort(); } break; case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_SEEK_BEGINNING_METHOD: switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: cc_full_descr->methods.source.msg_iter_seek_beginning = - cur_cc_descr_attr->value.source_msg_iter_seek_beginning_method; + cur_cc_descr_attr->value.msg_iter_seek_beginning_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: cc_full_descr->methods.filter.msg_iter_seek_beginning = - cur_cc_descr_attr->value.filter_msg_iter_seek_beginning_method; + cur_cc_descr_attr->value.msg_iter_seek_beginning_method; break; default: - abort(); + bt_common_abort(); } break; case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_NS_FROM_ORIGIN_METHOD: switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin = - cur_cc_descr_attr->value.source_msg_iter_can_seek_ns_from_origin_method; + cur_cc_descr_attr->value.msg_iter_can_seek_ns_from_origin_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin = - cur_cc_descr_attr->value.filter_msg_iter_can_seek_ns_from_origin_method; + cur_cc_descr_attr->value.msg_iter_can_seek_ns_from_origin_method; break; default: - abort(); + bt_common_abort(); } break; case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_CAN_SEEK_BEGINNING_METHOD: switch (cc_type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: cc_full_descr->methods.source.msg_iter_can_seek_beginning = - cur_cc_descr_attr->value.source_msg_iter_can_seek_beginning_method; + cur_cc_descr_attr->value.msg_iter_can_seek_beginning_method; break; case BT_COMPONENT_CLASS_TYPE_FILTER: cc_full_descr->methods.filter.msg_iter_can_seek_beginning = - cur_cc_descr_attr->value.filter_msg_iter_can_seek_beginning_method; + cur_cc_descr_attr->value.msg_iter_can_seek_beginning_method; break; default: - abort(); + bt_common_abort(); } break; default: @@ -712,7 +719,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, /* Initialize plugin */ if (spec->init) { - enum bt_plugin_init_func_status init_status; + enum bt_plugin_initialize_func_status init_status; BT_LOGD_STR("Calling user's plugin initialization function."); init_status = spec->init((void *) plugin); @@ -762,22 +769,111 @@ int bt_plugin_so_init(struct bt_plugin *plugin, bt_component_class_type_string( cc_full_descr->descriptor->type)); + if (cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_SOURCE || + cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_FILTER) { + bt_message_iterator_class_next_method next_method; + bt_message_iterator_class_initialize_method init_method; + bt_message_iterator_class_finalize_method fini_method; + bt_message_iterator_class_seek_ns_from_origin_method seek_ns_from_origin_method; + bt_message_iterator_class_seek_beginning_method seek_beginning_method; + bt_message_iterator_class_can_seek_ns_from_origin_method can_seek_ns_from_origin_method; + bt_message_iterator_class_can_seek_beginning_method can_seek_beginning_method; + + if (cc_full_descr->descriptor->type == BT_COMPONENT_CLASS_TYPE_SOURCE) { + next_method = cc_full_descr->descriptor->methods.source.msg_iter_next; + init_method = cc_full_descr->methods.source.msg_iter_initialize; + fini_method = cc_full_descr->methods.source.msg_iter_finalize; + seek_ns_from_origin_method = cc_full_descr->methods.source.msg_iter_seek_ns_from_origin; + can_seek_ns_from_origin_method = cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin; + seek_beginning_method = cc_full_descr->methods.source.msg_iter_seek_beginning; + can_seek_beginning_method = cc_full_descr->methods.source.msg_iter_can_seek_beginning; + } else { + next_method = cc_full_descr->descriptor->methods.filter.msg_iter_next; + init_method = cc_full_descr->methods.filter.msg_iter_initialize; + fini_method = cc_full_descr->methods.filter.msg_iter_finalize; + seek_ns_from_origin_method = cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin; + can_seek_ns_from_origin_method = cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin; + seek_beginning_method = cc_full_descr->methods.filter.msg_iter_seek_beginning; + can_seek_beginning_method = cc_full_descr->methods.filter.msg_iter_can_seek_beginning; + } + + msg_iter_class = bt_message_iterator_class_create(next_method); + if (!msg_iter_class) { + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot create message iterator class."); + status = BT_FUNC_STATUS_MEMORY_ERROR; + goto end; + } + + if (init_method) { + ret = bt_message_iterator_class_set_initialize_method( + msg_iter_class, init_method); + if (ret) { + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot set message iterator initialization method."); + status = BT_FUNC_STATUS_MEMORY_ERROR; + goto end; + } + } + + if (fini_method) { + ret = bt_message_iterator_class_set_finalize_method( + msg_iter_class, fini_method); + if (ret) { + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot set message iterator finalization method."); + status = BT_FUNC_STATUS_MEMORY_ERROR; + goto end; + } + } + + if (seek_ns_from_origin_method) { + ret = bt_message_iterator_class_set_seek_ns_from_origin_methods( + msg_iter_class, + seek_ns_from_origin_method, + can_seek_ns_from_origin_method); + if (ret) { + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot set message iterator \"seek nanoseconds from origin\" methods."); + status = BT_FUNC_STATUS_MEMORY_ERROR; + goto end; + } + } + + if (seek_beginning_method) { + ret = bt_message_iterator_class_set_seek_beginning_methods( + msg_iter_class, + seek_beginning_method, + can_seek_beginning_method); + if (ret) { + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot set message iterator \"seek beginning\" methods."); + status = BT_FUNC_STATUS_MEMORY_ERROR; + goto end; + } + } + } + switch (cc_full_descr->descriptor->type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: + BT_ASSERT(msg_iter_class); + src_comp_class = bt_component_class_source_create( - cc_full_descr->descriptor->name, - cc_full_descr->descriptor->methods.source.msg_iter_next); + cc_full_descr->descriptor->name, msg_iter_class); comp_class = bt_component_class_source_as_component_class( src_comp_class); break; case BT_COMPONENT_CLASS_TYPE_FILTER: + BT_ASSERT(msg_iter_class); + flt_comp_class = bt_component_class_filter_create( - cc_full_descr->descriptor->name, - cc_full_descr->descriptor->methods.source.msg_iter_next); + cc_full_descr->descriptor->name, msg_iter_class); comp_class = bt_component_class_filter_as_component_class( flt_comp_class); break; case BT_COMPONENT_CLASS_TYPE_SINK: + BT_ASSERT(!msg_iter_class); + sink_comp_class = bt_component_class_sink_create( cc_full_descr->descriptor->name, cc_full_descr->descriptor->methods.sink.consume); @@ -820,6 +916,15 @@ int bt_plugin_so_init(struct bt_plugin *plugin, goto end; } + /* + * The component class has taken a reference on the message + * iterator class, so we can drop ours. The message iterator + * class will get destroyed at the same time as the component + * class. + */ + bt_message_iterator_class_put_ref(msg_iter_class); + msg_iter_class = NULL; + if (cc_full_descr->description) { ret = bt_component_class_set_description( comp_class, cc_full_descr->description); @@ -846,8 +951,21 @@ int bt_plugin_so_init(struct bt_plugin *plugin, switch (cc_full_descr->descriptor->type) { case BT_COMPONENT_CLASS_TYPE_SOURCE: + if (cc_full_descr->methods.source.get_supported_mip_versions) { + ret = bt_component_class_source_set_get_supported_mip_versions_method( + src_comp_class, + cc_full_descr->methods.source.get_supported_mip_versions); + if (ret) { + BT_LIB_LOGE_APPEND_CAUSE( + "Cannot set source component class's \"get supported MIP versions\" method."); + status = BT_FUNC_STATUS_MEMORY_ERROR; + BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); + goto end; + } + } + if (cc_full_descr->methods.source.init) { - ret = bt_component_class_source_set_init_method( + ret = bt_component_class_source_set_initialize_method( src_comp_class, cc_full_descr->methods.source.init); if (ret) { @@ -898,88 +1016,23 @@ int bt_plugin_so_init(struct bt_plugin *plugin, } } - if (cc_full_descr->methods.source.msg_iter_init) { - ret = bt_component_class_source_set_message_iterator_init_method( - src_comp_class, - cc_full_descr->methods.source.msg_iter_init); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set source component class's message iterator initialization method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.source.msg_iter_finalize) { - ret = bt_component_class_source_set_message_iterator_finalize_method( - src_comp_class, - cc_full_descr->methods.source.msg_iter_finalize); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set source component class's message iterator finalization method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.source.msg_iter_seek_ns_from_origin) { - ret = bt_component_class_source_set_message_iterator_seek_ns_from_origin_method( - src_comp_class, - cc_full_descr->methods.source.msg_iter_seek_ns_from_origin); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set source component class's message iterator \"seek nanoseconds from origin\" method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.source.msg_iter_seek_beginning) { - ret = bt_component_class_source_set_message_iterator_seek_beginning_method( - src_comp_class, - cc_full_descr->methods.source.msg_iter_seek_beginning); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set source component class's message iterator \"seek beginning\" method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin) { - ret = bt_component_class_source_set_message_iterator_can_seek_ns_from_origin_method( - src_comp_class, - cc_full_descr->methods.source.msg_iter_can_seek_ns_from_origin); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set source component class's message iterator \"can seek nanoseconds from origin\" method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.source.msg_iter_can_seek_beginning) { - ret = bt_component_class_source_set_message_iterator_can_seek_beginning_method( - src_comp_class, - cc_full_descr->methods.source.msg_iter_can_seek_beginning); + break; + case BT_COMPONENT_CLASS_TYPE_FILTER: + if (cc_full_descr->methods.filter.get_supported_mip_versions) { + ret = bt_component_class_filter_set_get_supported_mip_versions_method( + flt_comp_class, + cc_full_descr->methods.filter.get_supported_mip_versions); if (ret) { BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set source component class's message iterator \"can seek beginning\" method."); + "Cannot set filter component class's \"get supported MIP versions\" method."); status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(src_comp_class); + BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); goto end; } } - break; - case BT_COMPONENT_CLASS_TYPE_FILTER: if (cc_full_descr->methods.filter.init) { - ret = bt_component_class_filter_set_init_method( + ret = bt_component_class_filter_set_initialize_method( flt_comp_class, cc_full_descr->methods.filter.init); if (ret) { @@ -1043,88 +1096,23 @@ int bt_plugin_so_init(struct bt_plugin *plugin, } } - if (cc_full_descr->methods.filter.msg_iter_init) { - ret = bt_component_class_filter_set_message_iterator_init_method( - flt_comp_class, - cc_full_descr->methods.filter.msg_iter_init); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set filter component class's message iterator initialization method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.filter.msg_iter_finalize) { - ret = bt_component_class_filter_set_message_iterator_finalize_method( - flt_comp_class, - cc_full_descr->methods.filter.msg_iter_finalize); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set filter component class's message iterator finalization method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin) { - ret = bt_component_class_filter_set_message_iterator_seek_ns_from_origin_method( - flt_comp_class, - cc_full_descr->methods.filter.msg_iter_seek_ns_from_origin); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set filter component class's message iterator \"seek nanoseconds from origin\" method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.filter.msg_iter_seek_beginning) { - ret = bt_component_class_filter_set_message_iterator_seek_beginning_method( - flt_comp_class, - cc_full_descr->methods.filter.msg_iter_seek_beginning); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set filter component class's message iterator \"seek beginning\" method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin) { - ret = bt_component_class_filter_set_message_iterator_can_seek_ns_from_origin_method( - flt_comp_class, - cc_full_descr->methods.filter.msg_iter_can_seek_ns_from_origin); - if (ret) { - BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set filter component class's message iterator \"can seek nanoseconds from origin\" method."); - status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); - goto end; - } - } - - if (cc_full_descr->methods.filter.msg_iter_can_seek_beginning) { - ret = bt_component_class_filter_set_message_iterator_can_seek_beginning_method( - flt_comp_class, - cc_full_descr->methods.filter.msg_iter_can_seek_beginning); + break; + case BT_COMPONENT_CLASS_TYPE_SINK: + if (cc_full_descr->methods.sink.get_supported_mip_versions) { + ret = bt_component_class_sink_set_get_supported_mip_versions_method( + sink_comp_class, + cc_full_descr->methods.sink.get_supported_mip_versions); if (ret) { BT_LIB_LOGE_APPEND_CAUSE( - "Cannot set filter component class's message iterator \"can seek beginning\" method."); + "Cannot set sink component class's \"get supported MIP versions\" method."); status = BT_FUNC_STATUS_MEMORY_ERROR; - BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class); + BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class); goto end; } } - break; - case BT_COMPONENT_CLASS_TYPE_SINK: if (cc_full_descr->methods.sink.init) { - ret = bt_component_class_sink_set_init_method( + ret = bt_component_class_sink_set_initialize_method( sink_comp_class, cc_full_descr->methods.sink.init); if (ret) { @@ -1190,7 +1178,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, break; default: - abort(); + bt_common_abort(); } /* @@ -1212,6 +1200,7 @@ int bt_plugin_so_init(struct bt_plugin *plugin, } end: + bt_message_iterator_class_put_ref(msg_iter_class); g_array_free(comp_class_full_descriptors, TRUE); return status; } @@ -1238,7 +1227,7 @@ struct bt_plugin *bt_plugin_so_create_empty( spec = plugin->spec_data; spec->shared_lib_handle = shared_lib_handle; - bt_object_get_no_null_check(spec->shared_lib_handle); + bt_object_get_ref_no_null_check(spec->shared_lib_handle); goto end; error: @@ -1324,25 +1313,8 @@ int bt_plugin_so_create_all_from_sections( continue; } - BT_LOGI("Creating plugin object for plugin: " - "name=\"%s\", abi-major=%d, abi-minor=%d", - descriptor->name, descriptor->major, descriptor->minor); - - if (descriptor->major > __BT_PLUGIN_VERSION_MAJOR) { - if (fail_on_load_error) { - BT_LIB_LOGW_APPEND_CAUSE( - "Unknown ABI major version: abi-major=%d", - descriptor->major); - status = BT_FUNC_STATUS_ERROR; - goto error; - } else { - BT_LIB_LOGW( - "Unknown ABI major version: abi-major=%d", - descriptor->major); - continue; - } - } - + BT_LOGI("Creating plugin object for plugin: name=\"%s\"", + descriptor->name); plugin = bt_plugin_so_create_empty(shared_lib_handle); if (!plugin) { BT_LIB_LOGE_APPEND_CAUSE( @@ -1462,9 +1434,19 @@ int bt_plugin_so_create_all_from_file(const char *path, BT_ASSERT(plugin_set_out); *plugin_set_out = NULL; path_len = strlen(path); - BT_ASSERT_PRE(path_len > PLUGIN_SUFFIX_LEN, - "Path length is too short: path-length=%zu, min-length=%zu", - path_len, PLUGIN_SUFFIX_LEN); + + /* + * An SO plugin file must have a known plugin file suffix. So the file + * path must be longer than the suffix length. + */ + if (path_len <= PLUGIN_SUFFIX_LEN) { + BT_LOGI("Path is too short to be an `.so` or `.la` plugin file:" + "path=%s, path-length=%zu, min-length=%zu", + path, path_len, PLUGIN_SUFFIX_LEN); + status = BT_FUNC_STATUS_NOT_FOUND; + goto end; + } + BT_LOGI("Trying to create all SO plugins from file: path=\"%s\"", path); path_len++; @@ -1700,7 +1682,7 @@ void bt_plugin_so_on_add_component_class(struct bt_plugin *plugin, bt_list_add(&comp_class->node, &component_class_list); comp_class->so_handle = spec->shared_lib_handle; - bt_object_get_no_null_check(comp_class->so_handle); + bt_object_get_ref_no_null_check(comp_class->so_handle); /* Add our custom destroy listener */ bt_component_class_add_destroy_listener(comp_class,