From 95ef44ce066ce8467cc01703016d274dea76b927 Mon Sep 17 00:00:00 2001 From: Michael Jeanson Date: Mon, 2 Oct 2017 17:28:17 -0400 Subject: [PATCH] Lazy load the python plugin provider MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- lib/plugin/plugin.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/plugin/plugin.c b/lib/plugin/plugin.c index 8a4e0555..3ff50de6 100644 --- a/lib/plugin/plugin.c +++ b/lib/plugin/plugin.c @@ -60,13 +60,20 @@ static struct bt_plugin_set *(*bt_plugin_python_create_all_from_file_sym)(const char *path) = bt_plugin_python_create_all_from_file; + +static +void init_python_plugin_provider(void) {} #else /* BT_BUILT_IN_PYTHON_PLUGIN_SUPPORT */ static GModule *python_plugin_provider_module; static struct bt_plugin_set *(*bt_plugin_python_create_all_from_file_sym)(const char *path); -__attribute__((constructor)) static +static void init_python_plugin_provider(void) { + if (bt_plugin_python_create_all_from_file_sym != NULL) { + return; + } + BT_LOGD_STR("Loading Python plugin provider module."); python_plugin_provider_module = g_module_open(PYTHON_PLUGIN_PROVIDER_FILENAME, 0); @@ -169,6 +176,7 @@ struct bt_plugin_set *bt_plugin_create_all_from_file(const char *path) } /* Try Python plugins if support is available */ + init_python_plugin_provider(); if (bt_plugin_python_create_all_from_file_sym) { plugin_set = bt_plugin_python_create_all_from_file_sym(path); if (plugin_set) { -- 2.34.1