lib: rename "notification" -> "message"
[babeltrace.git] / lib / plugin / plugin-so.c
CommitLineData
55bb57e0 1/*
e2f7325d 2 * Copyright 2017-2018 Philippe Proulx <pproulx@efficios.com>
55bb57e0 3 * Copyright 2016 Jérémie Galarneau <jeremie.galarneau@efficios.com>
55bb57e0
PP
4 *
5 * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
24 */
25
3fe0bf43
PP
26#define BT_LOG_TAG "PLUGIN-SO"
27#include <babeltrace/lib-logging-internal.h>
28
c5b9b441
PP
29#include <babeltrace/assert-internal.h>
30#include <babeltrace/assert-pre-internal.h>
3d9990ac 31#include <babeltrace/compiler-internal.h>
55bb57e0
PP
32#include <babeltrace/plugin/plugin-internal.h>
33#include <babeltrace/plugin/plugin-so-internal.h>
34#include <babeltrace/plugin/plugin-dev.h>
35#include <babeltrace/plugin/plugin-internal.h>
b2e0c907 36#include <babeltrace/graph/component-class-internal.h>
0d72b8c3
PP
37#include <babeltrace/graph/component-class.h>
38#include <babeltrace/graph/component-class-source.h>
39#include <babeltrace/graph/component-class-filter.h>
40#include <babeltrace/graph/component-class-sink.h>
c55a9f58 41#include <babeltrace/types.h>
bfa9a4be 42#include <babeltrace/list-internal.h>
55bb57e0 43#include <string.h>
0fbb9a9f 44#include <stdlib.h>
55bb57e0
PP
45#include <glib.h>
46#include <gmodule.h>
47
44a3451a 48#define NATIVE_PLUGIN_SUFFIX "." G_MODULE_SUFFIX
55bb57e0
PP
49#define NATIVE_PLUGIN_SUFFIX_LEN sizeof(NATIVE_PLUGIN_SUFFIX)
50#define LIBTOOL_PLUGIN_SUFFIX ".la"
51#define LIBTOOL_PLUGIN_SUFFIX_LEN sizeof(LIBTOOL_PLUGIN_SUFFIX)
52
53#define PLUGIN_SUFFIX_LEN max_t(size_t, sizeof(NATIVE_PLUGIN_SUFFIX), \
54 sizeof(LIBTOOL_PLUGIN_SUFFIX))
55
52238017 56BT_PLUGIN_MODULE();
55bb57e0
PP
57
58/*
bfa9a4be
MD
59 * This list, global to the library, keeps all component classes that
60 * have a reference to their shared library handles. It allows iteration
61 * on all component classes still present when the destructor executes
62 * to release the shared library handle references they might still have.
55bb57e0 63 *
bfa9a4be 64 * The list items are the component classes created with
55bb57e0
PP
65 * bt_plugin_add_component_class(). They keep the shared library handle
66 * object created by their plugin alive so that the plugin's code is
67 * not discarded when it could still be in use by living components
68 * created from those component classes:
69 *
bfa9a4be 70 * [component] --ref-> [component class]-> [shlib handle]
55bb57e0 71 *
bfa9a4be 72 * It allows this use-case:
55bb57e0 73 *
c8db3219 74 * my_plugins = bt_plugin_find_all_from_file("/path/to/my-plugin.so");
55bb57e0
PP
75 * // instantiate components from a plugin's component classes
76 * // put plugins and free my_plugins here
77 * // user code of instantiated components still exists
78 *
bfa9a4be
MD
79 * An entry is removed from this list when a component class is
80 * destroyed thanks to a custom destroy listener. When the entry is
81 * removed, the entry is removed from the list, and we release the
82 * reference on the shlib handle. Assuming the original plugin object
83 * which contained some component classes is put first, when the last
84 * component class is removed from this list, the shared library handle
85 * object's reference count falls to zero and the shared library is
86 * finally closed.
55bb57e0 87 */
bfa9a4be 88
55bb57e0 89static
bfa9a4be 90BT_LIST_HEAD(component_class_list);
55bb57e0
PP
91
92__attribute__((destructor)) static
bfa9a4be
MD
93void fini_comp_class_list(void)
94{
95 struct bt_component_class *comp_class, *tmp;
96
97 bt_list_for_each_entry_safe(comp_class, tmp, &component_class_list, node) {
98 bt_list_del(&comp_class->node);
65300d60 99 BT_OBJECT_PUT_REF_AND_RESET(comp_class->so_handle);
55bb57e0 100 }
d94d92ac 101
bfa9a4be 102 BT_LOGD_STR("Released references from all component classes to shared library handles.");
55bb57e0
PP
103}
104
105static
106void bt_plugin_so_shared_lib_handle_destroy(struct bt_object *obj)
107{
108 struct bt_plugin_so_shared_lib_handle *shared_lib_handle;
109
f6ccaed9 110 BT_ASSERT(obj);
55bb57e0
PP
111 shared_lib_handle = container_of(obj,
112 struct bt_plugin_so_shared_lib_handle, base);
3fe0bf43
PP
113 const char *path = shared_lib_handle->path ?
114 shared_lib_handle->path->str : NULL;
115
116 BT_LOGD("Destroying shared library handle: addr=%p, path=\"%s\"",
117 shared_lib_handle, path);
55bb57e0
PP
118
119 if (shared_lib_handle->init_called && shared_lib_handle->exit) {
3fe0bf43 120 enum bt_plugin_status status;
55bb57e0 121
3fe0bf43
PP
122 BT_LOGD_STR("Calling user's plugin exit function.");
123 status = shared_lib_handle->exit();
124 BT_LOGD("User function returned: %s",
125 bt_plugin_status_string(status));
55bb57e0 126
3fe0bf43
PP
127 if (status < 0) {
128 BT_LOGW("User's plugin exit function failed: "
129 "path=\"%s\"", path);
55bb57e0
PP
130 }
131 }
132
133 if (shared_lib_handle->module) {
f1447220
PP
134#ifndef NDEBUG
135 /*
136 * Valgrind shows incomplete stack traces when
137 * dynamically loaded libraries are closed before it
138 * finishes. Use the BABELTRACE_NO_DLCLOSE in a debug
139 * build to avoid this.
140 */
141 const char *var = getenv("BABELTRACE_NO_DLCLOSE");
142
143 if (!var || strcmp(var, "1") != 0) {
144#endif
3fe0bf43
PP
145 BT_LOGD("Closing GModule: path=\"%s\"", path);
146
f1447220 147 if (!g_module_close(shared_lib_handle->module)) {
3fe0bf43
PP
148 BT_LOGE("Cannot close GModule: %s: path=\"%s\"",
149 g_module_error(), path);
f1447220 150 }
db5504f9
PP
151
152 shared_lib_handle->module = NULL;
f1447220 153#ifndef NDEBUG
3fe0bf43
PP
154 } else {
155 BT_LOGD("Not closing GModule because `BABELTRACE_NO_DLCLOSE=1`: "
156 "path=\"%s\"", path);
55bb57e0 157 }
f1447220 158#endif
55bb57e0
PP
159 }
160
161 if (shared_lib_handle->path) {
162 g_string_free(shared_lib_handle->path, TRUE);
db5504f9 163 shared_lib_handle->path = NULL;
55bb57e0
PP
164 }
165
166 g_free(shared_lib_handle);
167}
168
169static
170struct bt_plugin_so_shared_lib_handle *bt_plugin_so_shared_lib_handle_create(
171 const char *path)
172{
173 struct bt_plugin_so_shared_lib_handle *shared_lib_handle = NULL;
174
3fe0bf43 175 BT_LOGD("Creating shared library handle: path=\"%s\"", path);
55bb57e0
PP
176 shared_lib_handle = g_new0(struct bt_plugin_so_shared_lib_handle, 1);
177 if (!shared_lib_handle) {
3fe0bf43 178 BT_LOGE_STR("Failed to allocate one shared library handle.");
55bb57e0
PP
179 goto error;
180 }
181
3fea54f6
PP
182 bt_object_init_shared(&shared_lib_handle->base,
183 bt_plugin_so_shared_lib_handle_destroy);
55bb57e0
PP
184
185 if (!path) {
186 goto end;
187 }
188
189 shared_lib_handle->path = g_string_new(path);
190 if (!shared_lib_handle->path) {
3fe0bf43 191 BT_LOGE_STR("Failed to allocate a GString.");
55bb57e0
PP
192 goto error;
193 }
194
424b8c43 195 shared_lib_handle->module = g_module_open(path, G_MODULE_BIND_LOCAL);
55bb57e0 196 if (!shared_lib_handle->module) {
50ad9320
PP
197 /*
198 * DEBUG-level logging because we're only _trying_ to
199 * open this file as a Babeltrace plugin: if it's not,
200 * it's not an error. And because this can be tried
c8db3219 201 * during bt_plugin_find_all_from_dir(), it's not even
50ad9320
PP
202 * a warning.
203 */
204 BT_LOGD("Cannot open GModule: %s: path=\"%s\"",
3fe0bf43 205 g_module_error(), path);
55bb57e0
PP
206 goto error;
207 }
208
209 goto end;
210
211error:
65300d60 212 BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle);
55bb57e0
PP
213
214end:
3fe0bf43
PP
215 if (shared_lib_handle) {
216 BT_LOGD("Created shared library handle: path=\"%s\", addr=%p",
217 path, shared_lib_handle);
218 }
219
55bb57e0
PP
220 return shared_lib_handle;
221}
222
6fbd4105 223static
55bb57e0
PP
224void bt_plugin_so_destroy_spec_data(struct bt_plugin *plugin)
225{
226 struct bt_plugin_so_spec_data *spec = plugin->spec_data;
227
228 if (!plugin->spec_data) {
229 return;
230 }
231
f6ccaed9
PP
232 BT_ASSERT(plugin->type == BT_PLUGIN_TYPE_SO);
233 BT_ASSERT(spec);
65300d60 234 BT_OBJECT_PUT_REF_AND_RESET(spec->shared_lib_handle);
55bb57e0
PP
235 g_free(plugin->spec_data);
236 plugin->spec_data = NULL;
237}
238
239/*
240 * This function does the following:
241 *
242 * 1. Iterate on the plugin descriptor attributes section and set the
243 * plugin's attributes depending on the attribute types. This
244 * includes the name of the plugin, its description, and its
245 * initialization function, for example.
246 *
247 * 2. Iterate on the component class descriptors section and create one
248 * "full descriptor" (temporary structure) for each one that is found
249 * and attached to our plugin descriptor.
250 *
251 * 3. Iterate on the component class descriptor attributes section and
252 * set the corresponding full descriptor's attributes depending on
253 * the attribute types. This includes the description of the
254 * component class, as well as its initialization and destroy
255 * methods.
256 *
257 * 4. Call the user's plugin initialization function, if any is
258 * defined.
259 *
260 * 5. For each full component class descriptor, create a component class
261 * object, set its optional attributes, and add it to the plugin
262 * object.
263 *
264 * 6. Freeze the plugin object.
265 */
266static
267enum bt_plugin_status bt_plugin_so_init(
268 struct bt_plugin *plugin,
269 const struct __bt_plugin_descriptor *descriptor,
270 struct __bt_plugin_descriptor_attribute const * const *attrs_begin,
271 struct __bt_plugin_descriptor_attribute const * const *attrs_end,
272 struct __bt_plugin_component_class_descriptor const * const *cc_descriptors_begin,
273 struct __bt_plugin_component_class_descriptor const * const *cc_descriptors_end,
274 struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_begin,
275 struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_end)
276{
277 /*
278 * This structure's members point to the plugin's memory
279 * (do NOT free).
280 */
281 struct comp_class_full_descriptor {
282 const struct __bt_plugin_component_class_descriptor *descriptor;
283 const char *description;
279b3f15 284 const char *help;
d94d92ac
PP
285
286 union {
287 struct {
0d72b8c3
PP
288 bt_component_class_source_init_method init;
289 bt_component_class_source_finalize_method finalize;
290 bt_component_class_source_query_method query;
291 bt_component_class_source_accept_output_port_connection_method accept_output_port_connection;
292 bt_component_class_source_output_port_connected_method output_port_connected;
293 bt_component_class_source_output_port_disconnected_method output_port_disconnected;
d6e69534
PP
294 bt_component_class_source_message_iterator_init_method msg_iter_init;
295 bt_component_class_source_message_iterator_finalize_method msg_iter_finalize;
d94d92ac
PP
296 } source;
297
298 struct {
0d72b8c3
PP
299 bt_component_class_filter_init_method init;
300 bt_component_class_filter_finalize_method finalize;
301 bt_component_class_filter_query_method query;
302 bt_component_class_filter_accept_input_port_connection_method accept_input_port_connection;
303 bt_component_class_filter_accept_output_port_connection_method accept_output_port_connection;
304 bt_component_class_filter_input_port_connected_method input_port_connected;
305 bt_component_class_filter_output_port_connected_method output_port_connected;
306 bt_component_class_filter_input_port_disconnected_method input_port_disconnected;
307 bt_component_class_filter_output_port_disconnected_method output_port_disconnected;
d6e69534
PP
308 bt_component_class_filter_message_iterator_init_method msg_iter_init;
309 bt_component_class_filter_message_iterator_finalize_method msg_iter_finalize;
d94d92ac
PP
310 } filter;
311
312 struct {
0d72b8c3
PP
313 bt_component_class_sink_init_method init;
314 bt_component_class_sink_finalize_method finalize;
315 bt_component_class_sink_query_method query;
316 bt_component_class_sink_accept_input_port_connection_method accept_input_port_connection;
317 bt_component_class_sink_input_port_connected_method input_port_connected;
318 bt_component_class_sink_input_port_disconnected_method input_port_disconnected;
d94d92ac
PP
319 } sink;
320 } methods;
55bb57e0
PP
321 };
322
323 enum bt_plugin_status status = BT_PLUGIN_STATUS_OK;
324 struct __bt_plugin_descriptor_attribute const * const *cur_attr_ptr;
325 struct __bt_plugin_component_class_descriptor const * const *cur_cc_descr_ptr;
326 struct __bt_plugin_component_class_descriptor_attribute const * const *cur_cc_descr_attr_ptr;
327 struct bt_plugin_so_spec_data *spec = plugin->spec_data;
328 GArray *comp_class_full_descriptors;
329 size_t i;
330 int ret;
331
3fe0bf43
PP
332 BT_LOGD("Initializing plugin object from descriptors found in sections: "
333 "plugin-addr=%p, plugin-path=\"%s\", "
334 "attrs-begin-addr=%p, attrs-end-addr=%p, "
335 "cc-descr-begin-addr=%p, cc-descr-end-addr=%p, "
336 "cc-descr-attrs-begin-addr=%p, cc-descr-attrs-end-addr=%p",
337 plugin,
338 spec->shared_lib_handle->path ?
339 spec->shared_lib_handle->path->str : NULL,
340 attrs_begin, attrs_end,
341 cc_descriptors_begin, cc_descriptors_end,
342 cc_descr_attrs_begin, cc_descr_attrs_end);
55bb57e0
PP
343 comp_class_full_descriptors = g_array_new(FALSE, TRUE,
344 sizeof(struct comp_class_full_descriptor));
345 if (!comp_class_full_descriptors) {
3fe0bf43 346 BT_LOGE_STR("Failed to allocate a GArray.");
55bb57e0
PP
347 status = BT_PLUGIN_STATUS_ERROR;
348 goto end;
349 }
350
351 /* Set mandatory attributes */
352 spec->descriptor = descriptor;
353 bt_plugin_set_name(plugin, descriptor->name);
354
355 /*
356 * Find and set optional attributes attached to this plugin
357 * descriptor.
358 */
359 for (cur_attr_ptr = attrs_begin; cur_attr_ptr != attrs_end; cur_attr_ptr++) {
360 const struct __bt_plugin_descriptor_attribute *cur_attr =
361 *cur_attr_ptr;
362
52238017
MJ
363 if (cur_attr == NULL) {
364 continue;
365 }
366
55bb57e0
PP
367 if (cur_attr->plugin_descriptor != descriptor) {
368 continue;
369 }
370
371 switch (cur_attr->type) {
372 case BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_INIT:
373 spec->init = cur_attr->value.init;
374 break;
375 case BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_EXIT:
376 spec->shared_lib_handle->exit = cur_attr->value.exit;
377 break;
378 case BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_AUTHOR:
379 bt_plugin_set_author(plugin, cur_attr->value.author);
380 break;
381 case BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_LICENSE:
382 bt_plugin_set_license(plugin, cur_attr->value.license);
383 break;
384 case BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION:
385 bt_plugin_set_description(plugin, cur_attr->value.description);
386 break;
387 case BT_PLUGIN_DESCRIPTOR_ATTRIBUTE_TYPE_VERSION:
388 bt_plugin_set_version(plugin,
389 (unsigned int) cur_attr->value.version.major,
390 (unsigned int) cur_attr->value.version.minor,
391 (unsigned int) cur_attr->value.version.patch,
392 cur_attr->value.version.extra);
393 break;
394 default:
50ad9320
PP
395 /*
396 * WARN-level logging because this should not
397 * happen with the appropriate ABI version. If
398 * we're here, we know that for the reported
399 * version of the ABI, this attribute is
400 * unknown.
401 */
3fe0bf43
PP
402 BT_LOGW("Ignoring unknown plugin descriptor attribute: "
403 "plugin-path=\"%s\", plugin-name=\"%s\", "
404 "attr-type-name=\"%s\", attr-type-id=%d",
405 spec->shared_lib_handle->path ?
406 spec->shared_lib_handle->path->str :
407 NULL,
408 descriptor->name, cur_attr->type_name,
409 cur_attr->type);
55bb57e0
PP
410 break;
411 }
412 }
413
414 /*
415 * Find component class descriptors attached to this plugin
416 * descriptor and initialize corresponding full component class
417 * descriptors in the array.
418 */
419 for (cur_cc_descr_ptr = cc_descriptors_begin; cur_cc_descr_ptr != cc_descriptors_end; cur_cc_descr_ptr++) {
420 const struct __bt_plugin_component_class_descriptor *cur_cc_descr =
421 *cur_cc_descr_ptr;
422 struct comp_class_full_descriptor full_descriptor = {0};
423
52238017
MJ
424 if (cur_cc_descr == NULL) {
425 continue;
426 }
427
55bb57e0
PP
428 if (cur_cc_descr->plugin_descriptor != descriptor) {
429 continue;
430 }
431
432 full_descriptor.descriptor = cur_cc_descr;
433 g_array_append_val(comp_class_full_descriptors,
434 full_descriptor);
435 }
436
437 /*
438 * Find component class descriptor attributes attached to this
439 * plugin descriptor and update corresponding full component
440 * class descriptors in the array.
441 */
442 for (cur_cc_descr_attr_ptr = cc_descr_attrs_begin; cur_cc_descr_attr_ptr != cc_descr_attrs_end; cur_cc_descr_attr_ptr++) {
443 const struct __bt_plugin_component_class_descriptor_attribute *cur_cc_descr_attr =
444 *cur_cc_descr_attr_ptr;
d94d92ac 445 enum bt_component_class_type cc_type;
55bb57e0 446
52238017
MJ
447 if (cur_cc_descr_attr == NULL) {
448 continue;
449 }
450
55bb57e0
PP
451 if (cur_cc_descr_attr->comp_class_descriptor->plugin_descriptor !=
452 descriptor) {
453 continue;
454 }
455
d94d92ac
PP
456 cc_type = cur_cc_descr_attr->comp_class_descriptor->type;
457
55bb57e0
PP
458 /* Find the corresponding component class descriptor entry */
459 for (i = 0; i < comp_class_full_descriptors->len; i++) {
460 struct comp_class_full_descriptor *cc_full_descr =
461 &g_array_index(comp_class_full_descriptors,
462 struct comp_class_full_descriptor, i);
463
d94d92ac 464 if (cur_cc_descr_attr->comp_class_descriptor !=
55bb57e0 465 cc_full_descr->descriptor) {
d94d92ac
PP
466 continue;
467 }
468
469 switch (cur_cc_descr_attr->type) {
470 case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_DESCRIPTION:
471 cc_full_descr->description =
472 cur_cc_descr_attr->value.description;
473 break;
474 case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_HELP:
475 cc_full_descr->help =
476 cur_cc_descr_attr->value.help;
477 break;
478 case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INIT_METHOD:
479 switch (cc_type) {
480 case BT_COMPONENT_CLASS_TYPE_SOURCE:
481 cc_full_descr->methods.source.init =
482 cur_cc_descr_attr->value.source_init_method;
55bb57e0 483 break;
d94d92ac
PP
484 case BT_COMPONENT_CLASS_TYPE_FILTER:
485 cc_full_descr->methods.filter.init =
486 cur_cc_descr_attr->value.filter_init_method;
279b3f15 487 break;
d94d92ac
PP
488 case BT_COMPONENT_CLASS_TYPE_SINK:
489 cc_full_descr->methods.sink.init =
490 cur_cc_descr_attr->value.sink_init_method;
55bb57e0 491 break;
d94d92ac
PP
492 default:
493 abort();
494 }
495 break;
496 case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_FINALIZE_METHOD:
497 switch (cc_type) {
498 case BT_COMPONENT_CLASS_TYPE_SOURCE:
499 cc_full_descr->methods.source.finalize =
500 cur_cc_descr_attr->value.source_finalize_method;
55bb57e0 501 break;
d94d92ac
PP
502 case BT_COMPONENT_CLASS_TYPE_FILTER:
503 cc_full_descr->methods.filter.finalize =
504 cur_cc_descr_attr->value.filter_finalize_method;
8463eac2 505 break;
d94d92ac
PP
506 case BT_COMPONENT_CLASS_TYPE_SINK:
507 cc_full_descr->methods.sink.finalize =
508 cur_cc_descr_attr->value.sink_finalize_method;
72b913fb 509 break;
d94d92ac
PP
510 default:
511 abort();
512 }
513 break;
514 case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_QUERY_METHOD:
515 switch (cc_type) {
516 case BT_COMPONENT_CLASS_TYPE_SOURCE:
517 cc_full_descr->methods.source.query =
518 cur_cc_descr_attr->value.source_query_method;
0d8b4d8e 519 break;
d94d92ac
PP
520 case BT_COMPONENT_CLASS_TYPE_FILTER:
521 cc_full_descr->methods.filter.query =
522 cur_cc_descr_attr->value.filter_query_method;
55bb57e0 523 break;
d94d92ac
PP
524 case BT_COMPONENT_CLASS_TYPE_SINK:
525 cc_full_descr->methods.sink.query =
526 cur_cc_descr_attr->value.sink_query_method;
55bb57e0 527 break;
d94d92ac
PP
528 default:
529 abort();
530 }
531 break;
532 case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_INPUT_PORT_CONNECTION_METHOD:
533 switch (cc_type) {
534 case BT_COMPONENT_CLASS_TYPE_FILTER:
535 cc_full_descr->methods.filter.accept_input_port_connection =
536 cur_cc_descr_attr->value.filter_accept_input_port_connection_method;
537 break;
538 case BT_COMPONENT_CLASS_TYPE_SINK:
539 cc_full_descr->methods.sink.accept_input_port_connection =
540 cur_cc_descr_attr->value.sink_accept_input_port_connection_method;
541 break;
542 default:
543 abort();
544 }
545 break;
546 case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_ACCEPT_OUTPUT_PORT_CONNECTION_METHOD:
547 switch (cc_type) {
548 case BT_COMPONENT_CLASS_TYPE_SOURCE:
549 cc_full_descr->methods.source.accept_output_port_connection =
550 cur_cc_descr_attr->value.source_accept_output_port_connection_method;
551 break;
552 case BT_COMPONENT_CLASS_TYPE_FILTER:
553 cc_full_descr->methods.filter.accept_output_port_connection =
554 cur_cc_descr_attr->value.filter_accept_output_port_connection_method;
555 break;
556 default:
557 abort();
558 }
559 break;
560 case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_CONNECTED_METHOD:
561 switch (cc_type) {
562 case BT_COMPONENT_CLASS_TYPE_FILTER:
563 cc_full_descr->methods.filter.input_port_connected =
564 cur_cc_descr_attr->value.filter_input_port_connected_method;
565 break;
566 case BT_COMPONENT_CLASS_TYPE_SINK:
567 cc_full_descr->methods.sink.input_port_connected =
568 cur_cc_descr_attr->value.sink_input_port_connected_method;
55bb57e0 569 break;
55bb57e0 570 default:
d94d92ac
PP
571 abort();
572 }
573 break;
574 case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_CONNECTED_METHOD:
575 switch (cc_type) {
576 case BT_COMPONENT_CLASS_TYPE_SOURCE:
577 cc_full_descr->methods.source.output_port_connected =
578 cur_cc_descr_attr->value.source_output_port_connected_method;
579 break;
580 case BT_COMPONENT_CLASS_TYPE_FILTER:
581 cc_full_descr->methods.filter.output_port_connected =
582 cur_cc_descr_attr->value.filter_output_port_connected_method;
55bb57e0 583 break;
d94d92ac
PP
584 default:
585 abort();
55bb57e0 586 }
d94d92ac
PP
587 break;
588 case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_INPUT_PORT_DISCONNECTED_METHOD:
589 switch (cc_type) {
590 case BT_COMPONENT_CLASS_TYPE_FILTER:
591 cc_full_descr->methods.filter.input_port_disconnected =
592 cur_cc_descr_attr->value.filter_input_port_disconnected_method;
593 break;
594 case BT_COMPONENT_CLASS_TYPE_SINK:
595 cc_full_descr->methods.sink.input_port_disconnected =
596 cur_cc_descr_attr->value.sink_input_port_disconnected_method;
597 break;
598 default:
599 abort();
600 }
601 break;
602 case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_OUTPUT_PORT_DISCONNECTED_METHOD:
603 switch (cc_type) {
604 case BT_COMPONENT_CLASS_TYPE_SOURCE:
605 cc_full_descr->methods.source.output_port_disconnected =
606 cur_cc_descr_attr->value.source_output_port_disconnected_method;
607 break;
608 case BT_COMPONENT_CLASS_TYPE_FILTER:
609 cc_full_descr->methods.filter.output_port_disconnected =
610 cur_cc_descr_attr->value.filter_output_port_disconnected_method;
611 break;
612 default:
613 abort();
614 }
615 break;
d6e69534 616 case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_INIT_METHOD:
d94d92ac
PP
617 switch (cc_type) {
618 case BT_COMPONENT_CLASS_TYPE_SOURCE:
d6e69534
PP
619 cc_full_descr->methods.source.msg_iter_init =
620 cur_cc_descr_attr->value.source_msg_iter_init_method;
d94d92ac
PP
621 break;
622 case BT_COMPONENT_CLASS_TYPE_FILTER:
d6e69534
PP
623 cc_full_descr->methods.filter.msg_iter_init =
624 cur_cc_descr_attr->value.filter_msg_iter_init_method;
d94d92ac
PP
625 break;
626 default:
627 abort();
628 }
629 break;
d6e69534 630 case BT_PLUGIN_COMPONENT_CLASS_DESCRIPTOR_ATTRIBUTE_TYPE_MSG_ITER_FINALIZE_METHOD:
d94d92ac
PP
631 switch (cc_type) {
632 case BT_COMPONENT_CLASS_TYPE_SOURCE:
d6e69534
PP
633 cc_full_descr->methods.source.msg_iter_finalize =
634 cur_cc_descr_attr->value.source_msg_iter_finalize_method;
d94d92ac
PP
635 break;
636 case BT_COMPONENT_CLASS_TYPE_FILTER:
d6e69534
PP
637 cc_full_descr->methods.filter.msg_iter_finalize =
638 cur_cc_descr_attr->value.filter_msg_iter_finalize_method;
d94d92ac
PP
639 break;
640 default:
641 abort();
642 }
643 break;
644 default:
645 /*
646 * WARN-level logging because this
647 * should not happen with the
648 * appropriate ABI version. If we're
649 * here, we know that for the reported
650 * version of the ABI, this attribute is
651 * unknown.
652 */
653 BT_LOGW("Ignoring unknown component class descriptor attribute: "
654 "plugin-path=\"%s\", "
655 "plugin-name=\"%s\", "
656 "comp-class-name=\"%s\", "
657 "comp-class-type=%s, "
658 "attr-type-name=\"%s\", "
659 "attr-type-id=%d",
660 spec->shared_lib_handle->path ?
661 spec->shared_lib_handle->path->str :
662 NULL,
663 descriptor->name,
664 cur_cc_descr_attr->comp_class_descriptor->name,
665 bt_component_class_type_string(
666 cur_cc_descr_attr->comp_class_descriptor->type),
667 cur_cc_descr_attr->type_name,
668 cur_cc_descr_attr->type);
669 break;
55bb57e0
PP
670 }
671 }
672 }
673
674 /* Initialize plugin */
675 if (spec->init) {
3fe0bf43 676 BT_LOGD_STR("Calling user's plugin initialization function.");
55bb57e0 677 status = spec->init(plugin);
3fe0bf43
PP
678 BT_LOGD("User function returned: %s",
679 bt_plugin_status_string(status));
680
55bb57e0 681 if (status < 0) {
3fe0bf43 682 BT_LOGW_STR("User's plugin initialization function failed.");
55bb57e0
PP
683 goto end;
684 }
685 }
686
c55a9f58 687 spec->shared_lib_handle->init_called = BT_TRUE;
55bb57e0
PP
688
689 /* Add described component classes to plugin */
690 for (i = 0; i < comp_class_full_descriptors->len; i++) {
691 struct comp_class_full_descriptor *cc_full_descr =
692 &g_array_index(comp_class_full_descriptors,
693 struct comp_class_full_descriptor, i);
0d72b8c3
PP
694 struct bt_component_class *comp_class = NULL;
695 struct bt_component_class_source *src_comp_class = NULL;
696 struct bt_component_class_filter *flt_comp_class = NULL;
697 struct bt_component_class_sink *sink_comp_class = NULL;
55bb57e0 698
3fe0bf43
PP
699 BT_LOGD("Creating and setting properties of plugin's component class: "
700 "plugin-path=\"%s\", plugin-name=\"%s\", "
701 "comp-class-name=\"%s\", comp-class-type=%s",
702 spec->shared_lib_handle->path ?
703 spec->shared_lib_handle->path->str :
704 NULL,
705 descriptor->name,
706 cc_full_descr->descriptor->name,
707 bt_component_class_type_string(
708 cc_full_descr->descriptor->type));
709
55bb57e0
PP
710 switch (cc_full_descr->descriptor->type) {
711 case BT_COMPONENT_CLASS_TYPE_SOURCE:
0d72b8c3 712 src_comp_class = bt_component_class_source_create(
55bb57e0 713 cc_full_descr->descriptor->name,
d6e69534 714 cc_full_descr->descriptor->methods.source.msg_iter_next);
0d72b8c3 715 comp_class = bt_component_class_source_as_component_class(
d94d92ac 716 src_comp_class);
55bb57e0
PP
717 break;
718 case BT_COMPONENT_CLASS_TYPE_FILTER:
0d72b8c3 719 flt_comp_class = bt_component_class_filter_create(
55bb57e0 720 cc_full_descr->descriptor->name,
d6e69534 721 cc_full_descr->descriptor->methods.source.msg_iter_next);
0d72b8c3 722 comp_class = bt_component_class_filter_as_component_class(
d94d92ac 723 flt_comp_class);
55bb57e0
PP
724 break;
725 case BT_COMPONENT_CLASS_TYPE_SINK:
0d72b8c3 726 sink_comp_class = bt_component_class_sink_create(
55bb57e0
PP
727 cc_full_descr->descriptor->name,
728 cc_full_descr->descriptor->methods.sink.consume);
0d72b8c3 729 comp_class = bt_component_class_sink_as_component_class(
d94d92ac 730 sink_comp_class);
55bb57e0
PP
731 break;
732 default:
50ad9320
PP
733 /*
734 * WARN-level logging because this should not
735 * happen with the appropriate ABI version. If
736 * we're here, we know that for the reported
737 * version of the ABI, this component class type
738 * is unknown.
739 */
3fe0bf43
PP
740 BT_LOGW("Ignoring unknown component class type: "
741 "plugin-path=\"%s\", plugin-name=\"%s\", "
742 "comp-class-name=\"%s\", comp-class-type=%d",
743 spec->shared_lib_handle->path->str ?
744 spec->shared_lib_handle->path->str :
745 NULL,
746 descriptor->name,
55bb57e0 747 cc_full_descr->descriptor->name,
3fe0bf43 748 cc_full_descr->descriptor->type);
55bb57e0
PP
749 continue;
750 }
751
752 if (!comp_class) {
3fe0bf43 753 BT_LOGE_STR("Cannot create component class.");
55bb57e0
PP
754 status = BT_PLUGIN_STATUS_ERROR;
755 goto end;
756 }
757
758 if (cc_full_descr->description) {
0d72b8c3 759 ret = bt_component_class_set_description(
d94d92ac 760 comp_class, cc_full_descr->description);
55bb57e0 761 if (ret) {
3fe0bf43 762 BT_LOGE_STR("Cannot set component class's description.");
55bb57e0 763 status = BT_PLUGIN_STATUS_ERROR;
65300d60 764 BT_OBJECT_PUT_REF_AND_RESET(comp_class);
55bb57e0
PP
765 goto end;
766 }
767 }
768
279b3f15 769 if (cc_full_descr->help) {
0d72b8c3 770 ret = bt_component_class_set_help(comp_class,
279b3f15
PP
771 cc_full_descr->help);
772 if (ret) {
3fe0bf43 773 BT_LOGE_STR("Cannot set component class's help string.");
279b3f15 774 status = BT_PLUGIN_STATUS_ERROR;
65300d60 775 BT_OBJECT_PUT_REF_AND_RESET(comp_class);
279b3f15
PP
776 goto end;
777 }
778 }
779
d94d92ac
PP
780 switch (cc_full_descr->descriptor->type) {
781 case BT_COMPONENT_CLASS_TYPE_SOURCE:
782 if (cc_full_descr->methods.source.init) {
0d72b8c3 783 ret = bt_component_class_source_set_init_method(
d94d92ac
PP
784 src_comp_class,
785 cc_full_descr->methods.source.init);
786 if (ret) {
787 BT_LOGE_STR("Cannot set source component class's initialization method.");
788 status = BT_PLUGIN_STATUS_ERROR;
789 BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
790 goto end;
791 }
55bb57e0 792 }
55bb57e0 793
d94d92ac 794 if (cc_full_descr->methods.source.finalize) {
0d72b8c3 795 ret = bt_component_class_source_set_finalize_method(
d94d92ac
PP
796 src_comp_class,
797 cc_full_descr->methods.source.finalize);
798 if (ret) {
799 BT_LOGE_STR("Cannot set source component class's finalization method.");
800 status = BT_PLUGIN_STATUS_ERROR;
801 BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
802 goto end;
803 }
55bb57e0 804 }
55bb57e0 805
d94d92ac 806 if (cc_full_descr->methods.source.query) {
0d72b8c3 807 ret = bt_component_class_source_set_query_method(
d94d92ac
PP
808 src_comp_class,
809 cc_full_descr->methods.source.query);
810 if (ret) {
811 BT_LOGE_STR("Cannot set source component class's query method.");
812 status = BT_PLUGIN_STATUS_ERROR;
813 BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
814 goto end;
815 }
8463eac2 816 }
8463eac2 817
d94d92ac 818 if (cc_full_descr->methods.source.accept_output_port_connection) {
0d72b8c3 819 ret = bt_component_class_source_set_accept_output_port_connection_method(
d94d92ac
PP
820 src_comp_class,
821 cc_full_descr->methods.source.accept_output_port_connection);
822 if (ret) {
823 BT_LOGE_STR("Cannot set source component class's \"accept input output connection\" method.");
824 status = BT_PLUGIN_STATUS_ERROR;
825 BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
826 goto end;
827 }
72b913fb 828 }
72b913fb 829
d94d92ac 830 if (cc_full_descr->methods.source.output_port_connected) {
0d72b8c3 831 ret = bt_component_class_source_set_output_port_connected_method(
d94d92ac
PP
832 src_comp_class,
833 cc_full_descr->methods.source.output_port_connected);
834 if (ret) {
835 BT_LOGE_STR("Cannot set source component class's \"output port connected\" method.");
836 status = BT_PLUGIN_STATUS_ERROR;
837 BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
838 goto end;
839 }
0d8b4d8e 840 }
0d8b4d8e 841
d94d92ac 842 if (cc_full_descr->methods.source.output_port_disconnected) {
0d72b8c3 843 ret = bt_component_class_source_set_output_port_disconnected_method(
d94d92ac
PP
844 src_comp_class,
845 cc_full_descr->methods.source.output_port_disconnected);
846 if (ret) {
847 BT_LOGE_STR("Cannot set source component class's \"output port disconnected\" method.");
848 status = BT_PLUGIN_STATUS_ERROR;
849 BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
850 goto end;
851 }
2d41b99e 852 }
2d41b99e 853
d6e69534
PP
854 if (cc_full_descr->methods.source.msg_iter_init) {
855 ret = bt_component_class_source_set_message_iterator_init_method(
d94d92ac 856 src_comp_class,
d6e69534 857 cc_full_descr->methods.source.msg_iter_init);
55bb57e0 858 if (ret) {
d6e69534 859 BT_LOGE_STR("Cannot set source component class's message iterator initialization method.");
55bb57e0 860 status = BT_PLUGIN_STATUS_ERROR;
d94d92ac 861 BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
55bb57e0
PP
862 goto end;
863 }
864 }
865
d6e69534
PP
866 if (cc_full_descr->methods.source.msg_iter_finalize) {
867 ret = bt_component_class_source_set_message_iterator_finalize_method(
d94d92ac 868 src_comp_class,
d6e69534 869 cc_full_descr->methods.source.msg_iter_finalize);
55bb57e0 870 if (ret) {
d6e69534 871 BT_LOGE_STR("Cannot set source component class's message iterator finalization method.");
55bb57e0 872 status = BT_PLUGIN_STATUS_ERROR;
d94d92ac 873 BT_OBJECT_PUT_REF_AND_RESET(src_comp_class);
55bb57e0
PP
874 goto end;
875 }
876 }
d94d92ac 877
55bb57e0
PP
878 break;
879 case BT_COMPONENT_CLASS_TYPE_FILTER:
d94d92ac 880 if (cc_full_descr->methods.filter.init) {
0d72b8c3 881 ret = bt_component_class_filter_set_init_method(
d94d92ac
PP
882 flt_comp_class,
883 cc_full_descr->methods.filter.init);
884 if (ret) {
885 BT_LOGE_STR("Cannot set filter component class's initialization method.");
886 status = BT_PLUGIN_STATUS_ERROR;
887 BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
888 goto end;
889 }
890 }
891
892 if (cc_full_descr->methods.filter.finalize) {
0d72b8c3 893 ret = bt_component_class_filter_set_finalize_method(
d94d92ac
PP
894 flt_comp_class,
895 cc_full_descr->methods.filter.finalize);
896 if (ret) {
897 BT_LOGE_STR("Cannot set filter component class's finalization method.");
898 status = BT_PLUGIN_STATUS_ERROR;
899 BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
900 goto end;
901 }
902 }
903
904 if (cc_full_descr->methods.filter.query) {
0d72b8c3 905 ret = bt_component_class_filter_set_query_method(
d94d92ac
PP
906 flt_comp_class,
907 cc_full_descr->methods.filter.query);
908 if (ret) {
909 BT_LOGE_STR("Cannot set filter component class's query method.");
910 status = BT_PLUGIN_STATUS_ERROR;
911 BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
912 goto end;
913 }
914 }
915
916 if (cc_full_descr->methods.filter.accept_input_port_connection) {
0d72b8c3 917 ret = bt_component_class_filter_set_accept_input_port_connection_method(
d94d92ac
PP
918 flt_comp_class,
919 cc_full_descr->methods.filter.accept_input_port_connection);
920 if (ret) {
921 BT_LOGE_STR("Cannot set filter component class's \"accept input port connection\" method.");
922 status = BT_PLUGIN_STATUS_ERROR;
923 BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
924 goto end;
925 }
926 }
927
928 if (cc_full_descr->methods.filter.accept_output_port_connection) {
0d72b8c3 929 ret = bt_component_class_filter_set_accept_output_port_connection_method(
d94d92ac
PP
930 flt_comp_class,
931 cc_full_descr->methods.filter.accept_output_port_connection);
932 if (ret) {
933 BT_LOGE_STR("Cannot set filter component class's \"accept input output connection\" method.");
934 status = BT_PLUGIN_STATUS_ERROR;
935 BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
936 goto end;
937 }
938 }
939
940 if (cc_full_descr->methods.filter.input_port_connected) {
0d72b8c3 941 ret = bt_component_class_filter_set_input_port_connected_method(
d94d92ac
PP
942 flt_comp_class,
943 cc_full_descr->methods.filter.input_port_connected);
944 if (ret) {
945 BT_LOGE_STR("Cannot set filter component class's \"input port connected\" method.");
946 status = BT_PLUGIN_STATUS_ERROR;
947 BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
948 goto end;
949 }
950 }
951
952 if (cc_full_descr->methods.filter.output_port_connected) {
0d72b8c3 953 ret = bt_component_class_filter_set_output_port_connected_method(
d94d92ac
PP
954 flt_comp_class,
955 cc_full_descr->methods.filter.output_port_connected);
956 if (ret) {
957 BT_LOGE_STR("Cannot set filter component class's \"output port connected\" method.");
958 status = BT_PLUGIN_STATUS_ERROR;
959 BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
960 goto end;
961 }
962 }
963
964 if (cc_full_descr->methods.filter.input_port_disconnected) {
0d72b8c3 965 ret = bt_component_class_filter_set_input_port_disconnected_method(
d94d92ac
PP
966 flt_comp_class,
967 cc_full_descr->methods.filter.input_port_disconnected);
968 if (ret) {
969 BT_LOGE_STR("Cannot set filter component class's \"input port disconnected\" method.");
970 status = BT_PLUGIN_STATUS_ERROR;
971 BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
972 goto end;
973 }
974 }
975
976 if (cc_full_descr->methods.filter.output_port_disconnected) {
0d72b8c3 977 ret = bt_component_class_filter_set_output_port_disconnected_method(
d94d92ac
PP
978 flt_comp_class,
979 cc_full_descr->methods.filter.output_port_disconnected);
980 if (ret) {
981 BT_LOGE_STR("Cannot set filter component class's \"output port disconnected\" method.");
982 status = BT_PLUGIN_STATUS_ERROR;
983 BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
984 goto end;
985 }
986 }
987
d6e69534
PP
988 if (cc_full_descr->methods.filter.msg_iter_init) {
989 ret = bt_component_class_filter_set_message_iterator_init_method(
d94d92ac 990 flt_comp_class,
d6e69534 991 cc_full_descr->methods.filter.msg_iter_init);
55bb57e0 992 if (ret) {
d6e69534 993 BT_LOGE_STR("Cannot set filter component class's message iterator initialization method.");
55bb57e0 994 status = BT_PLUGIN_STATUS_ERROR;
d94d92ac 995 BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
55bb57e0
PP
996 goto end;
997 }
998 }
999
d6e69534
PP
1000 if (cc_full_descr->methods.filter.msg_iter_finalize) {
1001 ret = bt_component_class_filter_set_message_iterator_finalize_method(
d94d92ac 1002 flt_comp_class,
d6e69534 1003 cc_full_descr->methods.filter.msg_iter_finalize);
55bb57e0 1004 if (ret) {
d6e69534 1005 BT_LOGE_STR("Cannot set filter component class's message iterator finalization method.");
55bb57e0 1006 status = BT_PLUGIN_STATUS_ERROR;
d94d92ac 1007 BT_OBJECT_PUT_REF_AND_RESET(flt_comp_class);
55bb57e0
PP
1008 goto end;
1009 }
1010 }
d94d92ac 1011
55bb57e0
PP
1012 break;
1013 case BT_COMPONENT_CLASS_TYPE_SINK:
d94d92ac 1014 if (cc_full_descr->methods.sink.init) {
0d72b8c3 1015 ret = bt_component_class_sink_set_init_method(
d94d92ac
PP
1016 sink_comp_class,
1017 cc_full_descr->methods.sink.init);
1018 if (ret) {
1019 BT_LOGE_STR("Cannot set sink component class's initialization method.");
1020 status = BT_PLUGIN_STATUS_ERROR;
1021 BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
1022 goto end;
1023 }
1024 }
1025
1026 if (cc_full_descr->methods.sink.finalize) {
0d72b8c3 1027 ret = bt_component_class_sink_set_finalize_method(
d94d92ac
PP
1028 sink_comp_class,
1029 cc_full_descr->methods.sink.finalize);
1030 if (ret) {
1031 BT_LOGE_STR("Cannot set sink component class's finalization method.");
1032 status = BT_PLUGIN_STATUS_ERROR;
1033 BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
1034 goto end;
1035 }
1036 }
1037
1038 if (cc_full_descr->methods.sink.query) {
0d72b8c3 1039 ret = bt_component_class_sink_set_query_method(
d94d92ac
PP
1040 sink_comp_class,
1041 cc_full_descr->methods.sink.query);
1042 if (ret) {
1043 BT_LOGE_STR("Cannot set sink component class's query method.");
1044 status = BT_PLUGIN_STATUS_ERROR;
1045 BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
1046 goto end;
1047 }
1048 }
1049
1050 if (cc_full_descr->methods.sink.accept_input_port_connection) {
0d72b8c3 1051 ret = bt_component_class_sink_set_accept_input_port_connection_method(
d94d92ac
PP
1052 sink_comp_class,
1053 cc_full_descr->methods.sink.accept_input_port_connection);
1054 if (ret) {
1055 BT_LOGE_STR("Cannot set sink component class's \"accept input port connection\" method.");
1056 status = BT_PLUGIN_STATUS_ERROR;
1057 BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
1058 goto end;
1059 }
1060 }
1061
1062 if (cc_full_descr->methods.sink.input_port_connected) {
0d72b8c3 1063 ret = bt_component_class_sink_set_input_port_connected_method(
d94d92ac
PP
1064 sink_comp_class,
1065 cc_full_descr->methods.sink.input_port_connected);
1066 if (ret) {
1067 BT_LOGE_STR("Cannot set sink component class's \"input port connected\" method.");
1068 status = BT_PLUGIN_STATUS_ERROR;
1069 BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
1070 goto end;
1071 }
1072 }
1073
1074 if (cc_full_descr->methods.sink.input_port_disconnected) {
0d72b8c3 1075 ret = bt_component_class_sink_set_input_port_disconnected_method(
d94d92ac
PP
1076 sink_comp_class,
1077 cc_full_descr->methods.sink.input_port_disconnected);
1078 if (ret) {
1079 BT_LOGE_STR("Cannot set sink component class's \"input port disconnected\" method.");
1080 status = BT_PLUGIN_STATUS_ERROR;
1081 BT_OBJECT_PUT_REF_AND_RESET(sink_comp_class);
1082 goto end;
1083 }
1084 }
1085
55bb57e0
PP
1086 break;
1087 default:
0fbb9a9f 1088 abort();
55bb57e0
PP
1089 }
1090
1091 /*
1092 * Add component class to the plugin object.
1093 *
1094 * This will call back
1095 * bt_plugin_so_on_add_component_class() so that we can
d94d92ac
PP
1096 * add a mapping in the component class list when we
1097 * know the component class is successfully added.
55bb57e0
PP
1098 */
1099 status = bt_plugin_add_component_class(plugin,
d94d92ac 1100 (void *) comp_class);
65300d60 1101 BT_OBJECT_PUT_REF_AND_RESET(comp_class);
55bb57e0 1102 if (status < 0) {
3fe0bf43 1103 BT_LOGE("Cannot add component class to plugin.");
55bb57e0
PP
1104 goto end;
1105 }
1106 }
1107
55bb57e0
PP
1108end:
1109 g_array_free(comp_class_full_descriptors, TRUE);
1110 return status;
1111}
1112
1113static
1114struct bt_plugin *bt_plugin_so_create_empty(
1115 struct bt_plugin_so_shared_lib_handle *shared_lib_handle)
1116{
1117 struct bt_plugin *plugin;
1118 struct bt_plugin_so_spec_data *spec;
1119
1120 plugin = bt_plugin_create_empty(BT_PLUGIN_TYPE_SO);
1121 if (!plugin) {
1122 goto error;
1123 }
1124
6fbd4105 1125 plugin->destroy_spec_data = bt_plugin_so_destroy_spec_data;
55bb57e0
PP
1126 plugin->spec_data = g_new0(struct bt_plugin_so_spec_data, 1);
1127 if (!plugin->spec_data) {
3fe0bf43 1128 BT_LOGE_STR("Failed to allocate one SO plugin specific data structure.");
55bb57e0
PP
1129 goto error;
1130 }
1131
1132 spec = plugin->spec_data;
398454ed
PP
1133 spec->shared_lib_handle = shared_lib_handle;
1134 bt_object_get_no_null_check(spec->shared_lib_handle);
55bb57e0
PP
1135 goto end;
1136
1137error:
65300d60 1138 BT_OBJECT_PUT_REF_AND_RESET(plugin);
55bb57e0
PP
1139
1140end:
1141 return plugin;
1142}
1143
52238017
MJ
1144static
1145size_t count_non_null_items_in_section(const void *begin, const void *end)
1146{
1147 size_t count = 0;
1148 const int * const *begin_int = (const int * const *) begin;
1149 const int * const *end_int = (const int * const *) end;
1150 const int * const *iter;
1151
1152 for (iter = begin_int; iter != end_int; iter++) {
1153 if (*iter) {
1154 count++;
1155 }
1156 }
1157
1158 return count;
1159}
1160
55bb57e0 1161static
a8ff38ef 1162struct bt_plugin_set *bt_plugin_so_create_all_from_sections(
55bb57e0
PP
1163 struct bt_plugin_so_shared_lib_handle *shared_lib_handle,
1164 struct __bt_plugin_descriptor const * const *descriptors_begin,
1165 struct __bt_plugin_descriptor const * const *descriptors_end,
1166 struct __bt_plugin_descriptor_attribute const * const *attrs_begin,
1167 struct __bt_plugin_descriptor_attribute const * const *attrs_end,
1168 struct __bt_plugin_component_class_descriptor const * const *cc_descriptors_begin,
1169 struct __bt_plugin_component_class_descriptor const * const *cc_descriptors_end,
1170 struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_begin,
1171 struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_end)
1172{
1173 size_t descriptor_count;
1174 size_t attrs_count;
1175 size_t cc_descriptors_count;
1176 size_t cc_descr_attrs_count;
1177 size_t i;
a8ff38ef 1178 struct bt_plugin_set *plugin_set = NULL;
55bb57e0 1179
52238017
MJ
1180 descriptor_count = count_non_null_items_in_section(descriptors_begin, descriptors_end);
1181 attrs_count = count_non_null_items_in_section(attrs_begin, attrs_end);
1182 cc_descriptors_count = count_non_null_items_in_section(cc_descriptors_begin, cc_descriptors_end);
1183 cc_descr_attrs_count = count_non_null_items_in_section(cc_descr_attrs_begin, cc_descr_attrs_end);
3fe0bf43
PP
1184
1185 BT_LOGD("Creating all SO plugins from sections: "
1186 "plugin-path=\"%s\", "
1187 "descr-begin-addr=%p, descr-end-addr=%p, "
1188 "attrs-begin-addr=%p, attrs-end-addr=%p, "
1189 "cc-descr-begin-addr=%p, cc-descr-end-addr=%p, "
1190 "cc-descr-attrs-begin-addr=%p, cc-descr-attrs-end-addr=%p, "
1191 "descr-count=%zu, attrs-count=%zu, "
1192 "cc-descr-count=%zu, cc-descr-attrs-count=%zu",
1193 shared_lib_handle->path ? shared_lib_handle->path->str : NULL,
1194 descriptors_begin, descriptors_end,
1195 attrs_begin, attrs_end,
1196 cc_descriptors_begin, cc_descriptors_end,
1197 cc_descr_attrs_begin, cc_descr_attrs_end,
1198 descriptor_count, attrs_count,
1199 cc_descriptors_count, cc_descr_attrs_count);
a8ff38ef
PP
1200 plugin_set = bt_plugin_set_create();
1201 if (!plugin_set) {
3fe0bf43 1202 BT_LOGE_STR("Cannot create empty plugin set.");
55bb57e0
PP
1203 goto error;
1204 }
1205
52238017 1206 for (i = 0; i < descriptors_end - descriptors_begin; i++) {
55bb57e0
PP
1207 enum bt_plugin_status status;
1208 const struct __bt_plugin_descriptor *descriptor =
1209 descriptors_begin[i];
1210 struct bt_plugin *plugin;
1211
52238017
MJ
1212 if (descriptor == NULL) {
1213 continue;
1214 }
1215
3fe0bf43
PP
1216 BT_LOGD("Creating plugin object for plugin: "
1217 "name=\"%s\", abi-major=%d, abi-minor=%d",
1218 descriptor->name, descriptor->major, descriptor->minor);
55bb57e0
PP
1219
1220 if (descriptor->major > __BT_PLUGIN_VERSION_MAJOR) {
50ad9320
PP
1221 /*
1222 * DEBUG-level logging because we're only
1223 * _trying_ to open this file as a compatible
1224 * Babeltrace plugin: if it's not, it's not an
1225 * error. And because this can be tried during
c8db3219 1226 * bt_plugin_find_all_from_dir(), it's not
50ad9320
PP
1227 * even a warning.
1228 */
1229 BT_LOGD("Unknown ABI major version: abi-major=%d",
55bb57e0
PP
1230 descriptor->major);
1231 goto error;
1232 }
1233
1234 plugin = bt_plugin_so_create_empty(shared_lib_handle);
1235 if (!plugin) {
3fe0bf43 1236 BT_LOGE_STR("Cannot create empty shared library handle.");
55bb57e0
PP
1237 goto error;
1238 }
1239
1240 if (shared_lib_handle && shared_lib_handle->path) {
1241 bt_plugin_set_path(plugin, shared_lib_handle->path->str);
1242 }
1243
1244 status = bt_plugin_so_init(plugin, descriptor, attrs_begin,
1245 attrs_end, cc_descriptors_begin, cc_descriptors_end,
1246 cc_descr_attrs_begin, cc_descr_attrs_end);
1247 if (status < 0) {
50ad9320
PP
1248 /*
1249 * DEBUG-level logging because we're only
1250 * _trying_ to open this file as a compatible
1251 * Babeltrace plugin: if it's not, it's not an
1252 * error. And because this can be tried during
c8db3219 1253 * bt_plugin_find_all_from_dir(), it's not
50ad9320
PP
1254 * even a warning.
1255 */
1256 BT_LOGD_STR("Cannot initialize SO plugin object from sections.");
65300d60 1257 BT_OBJECT_PUT_REF_AND_RESET(plugin);
55bb57e0
PP
1258 goto error;
1259 }
1260
a8ff38ef
PP
1261 /* Add to plugin set */
1262 bt_plugin_set_add_plugin(plugin_set, plugin);
65300d60 1263 bt_object_put_ref(plugin);
55bb57e0
PP
1264 }
1265
1266 goto end;
1267
1268error:
65300d60 1269 BT_OBJECT_PUT_REF_AND_RESET(plugin_set);
55bb57e0
PP
1270
1271end:
a8ff38ef 1272 return plugin_set;
55bb57e0
PP
1273}
1274
1275BT_HIDDEN
a8ff38ef 1276struct bt_plugin_set *bt_plugin_so_create_all_from_static(void)
55bb57e0 1277{
a8ff38ef 1278 struct bt_plugin_set *plugin_set = NULL;
55bb57e0
PP
1279 struct bt_plugin_so_shared_lib_handle *shared_lib_handle =
1280 bt_plugin_so_shared_lib_handle_create(NULL);
1281
1282 if (!shared_lib_handle) {
1283 goto end;
1284 }
1285
3fe0bf43 1286 BT_LOGD_STR("Creating all SO plugins from built-in plugins.");
a8ff38ef 1287 plugin_set = bt_plugin_so_create_all_from_sections(shared_lib_handle,
52238017
MJ
1288 __bt_get_begin_section_plugin_descriptors(),
1289 __bt_get_end_section_plugin_descriptors(),
1290 __bt_get_begin_section_plugin_descriptor_attributes(),
1291 __bt_get_end_section_plugin_descriptor_attributes(),
1292 __bt_get_begin_section_component_class_descriptors(),
1293 __bt_get_end_section_component_class_descriptors(),
1294 __bt_get_begin_section_component_class_descriptor_attributes(),
1295 __bt_get_end_section_component_class_descriptor_attributes());
55bb57e0
PP
1296
1297end:
65300d60 1298 BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle);
55bb57e0 1299
a8ff38ef 1300 return plugin_set;
55bb57e0
PP
1301}
1302
1303BT_HIDDEN
a8ff38ef 1304struct bt_plugin_set *bt_plugin_so_create_all_from_file(const char *path)
55bb57e0
PP
1305{
1306 size_t path_len;
a8ff38ef 1307 struct bt_plugin_set *plugin_set = NULL;
55bb57e0
PP
1308 struct __bt_plugin_descriptor const * const *descriptors_begin = NULL;
1309 struct __bt_plugin_descriptor const * const *descriptors_end = NULL;
1310 struct __bt_plugin_descriptor_attribute const * const *attrs_begin = NULL;
1311 struct __bt_plugin_descriptor_attribute const * const *attrs_end = NULL;
1312 struct __bt_plugin_component_class_descriptor const * const *cc_descriptors_begin = NULL;
1313 struct __bt_plugin_component_class_descriptor const * const *cc_descriptors_end = NULL;
1314 struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_begin = NULL;
1315 struct __bt_plugin_component_class_descriptor_attribute const * const *cc_descr_attrs_end = NULL;
52238017
MJ
1316 struct __bt_plugin_descriptor const * const *(*get_begin_section_plugin_descriptors)(void);
1317 struct __bt_plugin_descriptor const * const *(*get_end_section_plugin_descriptors)(void);
1318 struct __bt_plugin_descriptor_attribute const * const *(*get_begin_section_plugin_descriptor_attributes)(void);
1319 struct __bt_plugin_descriptor_attribute const * const *(*get_end_section_plugin_descriptor_attributes)(void);
1320 struct __bt_plugin_component_class_descriptor const * const *(*get_begin_section_component_class_descriptors)(void);
1321 struct __bt_plugin_component_class_descriptor const * const *(*get_end_section_component_class_descriptors)(void);
1322 struct __bt_plugin_component_class_descriptor_attribute const * const *(*get_begin_section_component_class_descriptor_attributes)(void);
1323 struct __bt_plugin_component_class_descriptor_attribute const * const *(*get_end_section_component_class_descriptor_attributes)(void);
c55a9f58 1324 bt_bool is_libtool_wrapper = BT_FALSE, is_shared_object = BT_FALSE;
55bb57e0
PP
1325 struct bt_plugin_so_shared_lib_handle *shared_lib_handle = NULL;
1326
1327 if (!path) {
3fe0bf43 1328 BT_LOGW_STR("Invalid parameter: path is NULL.");
55bb57e0
PP
1329 goto end;
1330 }
1331
3fe0bf43 1332 BT_LOGD("Creating all SO plugins from file: path=\"%s\"", path);
55bb57e0
PP
1333 path_len = strlen(path);
1334 if (path_len <= PLUGIN_SUFFIX_LEN) {
3fe0bf43
PP
1335 BT_LOGW("Invalid parameter: path length is too short: "
1336 "path-length=%zu", path_len);
55bb57e0
PP
1337 goto end;
1338 }
1339
1340 path_len++;
1341 /*
1342 * Check if the file ends with a known plugin file type suffix (i.e. .so
1343 * or .la on Linux).
1344 */
1345 is_libtool_wrapper = !strncmp(LIBTOOL_PLUGIN_SUFFIX,
1346 path + path_len - LIBTOOL_PLUGIN_SUFFIX_LEN,
1347 LIBTOOL_PLUGIN_SUFFIX_LEN);
1348 is_shared_object = !strncmp(NATIVE_PLUGIN_SUFFIX,
1349 path + path_len - NATIVE_PLUGIN_SUFFIX_LEN,
1350 NATIVE_PLUGIN_SUFFIX_LEN);
1351 if (!is_shared_object && !is_libtool_wrapper) {
3fe0bf43
PP
1352 /* Name indicates this is not a plugin file; not an error */
1353 BT_LOGV("File is not a SO plugin file: path=\"%s\"", path);
55bb57e0
PP
1354 goto end;
1355 }
1356
1357 shared_lib_handle = bt_plugin_so_shared_lib_handle_create(path);
1358 if (!shared_lib_handle) {
50ad9320 1359 BT_LOGD_STR("Cannot create shared library handle.");
55bb57e0
PP
1360 goto end;
1361 }
1362
52238017
MJ
1363 if (g_module_symbol(shared_lib_handle->module, "__bt_get_begin_section_plugin_descriptors",
1364 (gpointer *) &get_begin_section_plugin_descriptors)) {
1365 descriptors_begin = get_begin_section_plugin_descriptors();
1366 } else {
3fe0bf43
PP
1367 BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
1368 "symbol=\"%s\"", path,
52238017 1369 "__bt_get_begin_section_plugin_descriptors");
55bb57e0
PP
1370 goto end;
1371 }
1372
52238017
MJ
1373 if (g_module_symbol(shared_lib_handle->module, "__bt_get_end_section_plugin_descriptors",
1374 (gpointer *) &get_end_section_plugin_descriptors)) {
1375 descriptors_end = get_end_section_plugin_descriptors();
1376 } else {
3fe0bf43
PP
1377 BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
1378 "symbol=\"%s\"", path,
52238017 1379 "__bt_get_end_section_plugin_descriptors");
55bb57e0
PP
1380 goto end;
1381 }
1382
52238017
MJ
1383 if (g_module_symbol(shared_lib_handle->module, "__bt_get_begin_section_plugin_descriptor_attributes",
1384 (gpointer *) &get_begin_section_plugin_descriptor_attributes)) {
1385 attrs_begin = get_begin_section_plugin_descriptor_attributes();
1386 } else {
3fe0bf43
PP
1387 BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
1388 "symbol=\"%s\"", path,
52238017 1389 "__bt_get_begin_section_plugin_descriptor_attributes");
55bb57e0
PP
1390 }
1391
52238017
MJ
1392 if (g_module_symbol(shared_lib_handle->module, "__bt_get_end_section_plugin_descriptor_attributes",
1393 (gpointer *) &get_end_section_plugin_descriptor_attributes)) {
1394 attrs_end = get_end_section_plugin_descriptor_attributes();
1395 } else {
3fe0bf43
PP
1396 BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
1397 "symbol=\"%s\"", path,
52238017 1398 "__bt_get_end_section_plugin_descriptor_attributes");
55bb57e0
PP
1399 }
1400
1401 if ((!!attrs_begin - !!attrs_end) != 0) {
3fe0bf43
PP
1402 BT_LOGD("Found section start or end symbol, but not both: "
1403 "path=\"%s\", symbol-start=\"%s\", "
1404 "symbol-end=\"%s\", symbol-start-addr=%p, "
1405 "symbol-end-addr=%p",
52238017
MJ
1406 path, "__bt_get_begin_section_plugin_descriptor_attributes",
1407 "__bt_get_end_section_plugin_descriptor_attributes",
3fe0bf43 1408 attrs_begin, attrs_end);
55bb57e0
PP
1409 goto end;
1410 }
1411
52238017
MJ
1412 if (g_module_symbol(shared_lib_handle->module, "__bt_get_begin_section_component_class_descriptors",
1413 (gpointer *) &get_begin_section_component_class_descriptors)) {
1414 cc_descriptors_begin = get_begin_section_component_class_descriptors();
1415 } else {
3fe0bf43
PP
1416 BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
1417 "symbol=\"%s\"", path,
52238017 1418 "__bt_get_begin_section_component_class_descriptors");
55bb57e0
PP
1419 }
1420
52238017
MJ
1421 if (g_module_symbol(shared_lib_handle->module, "__bt_get_end_section_component_class_descriptors",
1422 (gpointer *) &get_end_section_component_class_descriptors)) {
1423 cc_descriptors_end = get_end_section_component_class_descriptors();
1424 } else {
3fe0bf43
PP
1425 BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
1426 "symbol=\"%s\"", path,
52238017 1427 "__bt_get_end_section_component_class_descriptors");
55bb57e0
PP
1428 }
1429
1430 if ((!!cc_descriptors_begin - !!cc_descriptors_end) != 0) {
3fe0bf43
PP
1431 BT_LOGD("Found section start or end symbol, but not both: "
1432 "path=\"%s\", symbol-start=\"%s\", "
1433 "symbol-end=\"%s\", symbol-start-addr=%p, "
1434 "symbol-end-addr=%p",
52238017
MJ
1435 path, "__bt_get_begin_section_component_class_descriptors",
1436 "__bt_get_end_section_component_class_descriptors",
3fe0bf43 1437 cc_descriptors_begin, cc_descriptors_end);
55bb57e0
PP
1438 goto end;
1439 }
1440
52238017
MJ
1441 if (g_module_symbol(shared_lib_handle->module, "__bt_get_begin_section_component_class_descriptor_attributes",
1442 (gpointer *) &get_begin_section_component_class_descriptor_attributes)) {
1443 cc_descr_attrs_begin = get_begin_section_component_class_descriptor_attributes();
1444 } else {
3fe0bf43
PP
1445 BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
1446 "symbol=\"%s\"", path,
52238017 1447 "__bt_get_begin_section_component_class_descriptor_attributes");
55bb57e0
PP
1448 }
1449
52238017
MJ
1450 if (g_module_symbol(shared_lib_handle->module, "__bt_get_end_section_component_class_descriptor_attributes",
1451 (gpointer *) &get_end_section_component_class_descriptor_attributes)) {
1452 cc_descr_attrs_end = get_end_section_component_class_descriptor_attributes();
1453 } else {
3fe0bf43
PP
1454 BT_LOGD("Cannot resolve plugin symbol: path=\"%s\", "
1455 "symbol=\"%s\"", path,
52238017 1456 "__bt_get_end_section_component_class_descriptor_attributes");
55bb57e0
PP
1457 }
1458
1459 if ((!!cc_descr_attrs_begin - !!cc_descr_attrs_end) != 0) {
3fe0bf43
PP
1460 BT_LOGD("Found section start or end symbol, but not both: "
1461 "path=\"%s\", symbol-start=\"%s\", "
1462 "symbol-end=\"%s\", symbol-start-addr=%p, "
1463 "symbol-end-addr=%p",
52238017
MJ
1464 path, "__bt_get_begin_section_component_class_descriptor_attributes",
1465 "__bt_get_end_section_component_class_descriptor_attributes",
3fe0bf43 1466 cc_descr_attrs_begin, cc_descr_attrs_end);
55bb57e0
PP
1467 goto end;
1468 }
1469
1470 /* Initialize plugin */
3fe0bf43 1471 BT_LOGD_STR("Initializing plugin object.");
a8ff38ef 1472 plugin_set = bt_plugin_so_create_all_from_sections(shared_lib_handle,
55bb57e0
PP
1473 descriptors_begin, descriptors_end, attrs_begin, attrs_end,
1474 cc_descriptors_begin, cc_descriptors_end,
1475 cc_descr_attrs_begin, cc_descr_attrs_end);
1476
1477end:
65300d60 1478 BT_OBJECT_PUT_REF_AND_RESET(shared_lib_handle);
a8ff38ef 1479 return plugin_set;
55bb57e0
PP
1480}
1481
1482static
1483void plugin_comp_class_destroy_listener(struct bt_component_class *comp_class,
1484 void *data)
1485{
bfa9a4be 1486 bt_list_del(&comp_class->node);
65300d60 1487 BT_OBJECT_PUT_REF_AND_RESET(comp_class->so_handle);
bfa9a4be 1488 BT_LOGV("Component class destroyed: removed entry from list: "
3fe0bf43 1489 "comp-cls-addr=%p", comp_class);
55bb57e0
PP
1490}
1491
1492BT_HIDDEN
3230ee6b 1493void bt_plugin_so_on_add_component_class(struct bt_plugin *plugin,
55bb57e0
PP
1494 struct bt_component_class *comp_class)
1495{
55bb57e0
PP
1496 struct bt_plugin_so_spec_data *spec = plugin->spec_data;
1497
f6ccaed9
PP
1498 BT_ASSERT(plugin->spec_data);
1499 BT_ASSERT(plugin->type == BT_PLUGIN_TYPE_SO);
55bb57e0 1500
bfa9a4be 1501 bt_list_add(&comp_class->node, &component_class_list);
398454ed
PP
1502 comp_class->so_handle = spec->shared_lib_handle;
1503 bt_object_get_no_null_check(comp_class->so_handle);
55bb57e0
PP
1504
1505 /* Add our custom destroy listener */
3230ee6b 1506 bt_component_class_add_destroy_listener(comp_class,
55bb57e0 1507 plugin_comp_class_destroy_listener, NULL);
55bb57e0 1508}
This page took 0.110487 seconds and 4 git commands to generate.