Lazy load the python plugin provider
authorMichael Jeanson <mjeanson@efficios.com>
Mon, 2 Oct 2017 21:28:17 +0000 (17:28 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 2 Nov 2017 19:53:51 +0000 (15:53 -0400)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/plugin/plugin.c

index 8a4e055564b902300e889b6be3660f5e631691b9..3ff50de62161fb89464fb6df038ac7e8ba045c32 100644 (file)
 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) {
This page took 0.025291 seconds and 4 git commands to generate.