From 45720bde1c56c414fec8a1c3d5775208c3b32139 Mon Sep 17 00:00:00 2001 From: Alessio Vanni Date: Sun, 4 Apr 2021 16:51:09 +0200 Subject: Implement function to load plugins within a specific context When `GNUNET_OS_init' is called to change the application project data, lazy-loading plugins will fail as it will not find the requested files. The function will temporarily swap the project data with the argument value and will search for plugins, within the installation directory tree inferred from that structure. Applications can still use `GNUNET_PLUGIN_load_all' to load their plugins from within their own installation directory tree, though services are recommended to use the `in_context' version to avoid falling in the same pit. Signed-off-by: Martin Schanzenbach --- src/gnsrecord/gnsrecord.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src/gnsrecord') diff --git a/src/gnsrecord/gnsrecord.c b/src/gnsrecord/gnsrecord.c index 8d5a6d95b..31749a629 100644 --- a/src/gnsrecord/gnsrecord.c +++ b/src/gnsrecord/gnsrecord.c @@ -102,15 +102,12 @@ init () if (1 == once) return; once = 1; - const struct GNUNET_OS_ProjectData *pd = GNUNET_OS_project_data_get (); - const struct GNUNET_OS_ProjectData *dpd = GNUNET_OS_project_data_default (); - if (pd != dpd) - GNUNET_OS_init (dpd); - GNUNET_PLUGIN_load_all ("libgnunet_plugin_gnsrecord_", NULL, - &add_plugin, NULL); - if (pd != dpd) - GNUNET_OS_init (pd); + GNUNET_PLUGIN_load_all_in_context (GNUNET_OS_project_data_default (), + "libgnunet_plugin_gnsrecord_", + NULL, + &add_plugin, + NULL); } -- cgit v1.2.3