summaryrefslogtreecommitdiff
path: root/src/datacache/datacache.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/datacache/datacache.c')
-rw-r--r--src/datacache/datacache.c24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/datacache/datacache.c b/src/datacache/datacache.c
index 1ae228b86..5fc5a7481 100644
--- a/src/datacache/datacache.c
+++ b/src/datacache/datacache.c
@@ -138,6 +138,7 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
struct GNUNET_DATACACHE_Handle *ret;
char *libname;
char *name;
+ const struct GNUNET_OS_ProjectData *pd;
if (GNUNET_OK !=
GNUNET_CONFIGURATION_get_value_size (cfg, section, "QUOTA", &quota))
@@ -190,14 +191,25 @@ GNUNET_DATACACHE_create (const struct GNUNET_CONFIGURATION_Handle *cfg,
GNUNET_asprintf (&libname, "libgnunet_plugin_datacache_%s", name);
ret->short_name = name;
ret->lib_name = libname;
+ /* Load the plugin within GNUnet's default context */
+ pd = GNUNET_OS_project_data_get ();
+ GNUNET_OS_init(GNUNET_OS_project_data_default ());
ret->api = GNUNET_PLUGIN_load (libname, &ret->env);
- if (ret->api == NULL)
+ GNUNET_OS_init(pd);
+ if (NULL == ret->api)
{
- LOG (GNUNET_ERROR_TYPE_ERROR,
- _ ("Failed to load datacache plugin for `%s'\n"),
- name);
- GNUNET_DATACACHE_destroy (ret);
- return NULL;
+ /* Try to load the plugin within the application's context
+ This normally happens when the application is not GNUnet itself but a
+ third party; inside GNUnet this is effectively a double failure. */
+ ret->api = GNUNET_PLUGIN_load (libname, &ret->env);
+ if (NULL == ret->api)
+ {
+ LOG (GNUNET_ERROR_TYPE_ERROR,
+ _ ("Failed to load datacache plugin for `%s'\n"),
+ name);
+ GNUNET_DATACACHE_destroy (ret);
+ return NULL;
+ }
}
return ret;
}