db: Implement plugin loading and unloading
This commit is contained in:
parent
a3ac2587cf
commit
f94bb0a3a0
@ -43,8 +43,35 @@ static char *old_dlsearchpath;
|
|||||||
int
|
int
|
||||||
TALER_MINT_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
|
TALER_MINT_plugin_load (const struct GNUNET_CONFIGURATION_Handle *cfg)
|
||||||
{
|
{
|
||||||
|
char *plugin_name;
|
||||||
|
char *lib_name;
|
||||||
|
struct GNUNET_CONFIGURATION_Handle *cfg_dup;
|
||||||
|
|
||||||
|
if (NULL != plugin)
|
||||||
|
return GNUNET_OK;
|
||||||
|
if (GNUNET_SYSERR ==
|
||||||
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
|
"mint",
|
||||||
|
"db",
|
||||||
|
&plugin_name))
|
||||||
|
{
|
||||||
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
|
"mint",
|
||||||
|
"db");
|
||||||
return GNUNET_SYSERR;
|
return GNUNET_SYSERR;
|
||||||
}
|
}
|
||||||
|
(void) GNUNET_asprintf (&lib_name,
|
||||||
|
"libtaler_plugin_mintdb_%s",
|
||||||
|
plugin_name);
|
||||||
|
GNUNET_free (plugin_name);
|
||||||
|
cfg_dup = GNUNET_CONFIGURATION_dup (cfg);
|
||||||
|
plugin = GNUNET_PLUGIN_load (lib_name, cfg_dup);
|
||||||
|
GNUNET_CONFIGURATION_destroy (cfg_dup);
|
||||||
|
GNUNET_free (lib_name);
|
||||||
|
if (NULL == plugin)
|
||||||
|
return GNUNET_SYSERR;
|
||||||
|
return GNUNET_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -55,6 +82,8 @@ TALER_MINT_plugin_unload ()
|
|||||||
{
|
{
|
||||||
if (NULL == plugin)
|
if (NULL == plugin)
|
||||||
return;
|
return;
|
||||||
|
GNUNET_assert (NULL == GNUNET_PLUGIN_unload (plugin->library_name,
|
||||||
|
plugin));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -2289,16 +2289,17 @@ libtaler_plugin_mintdb_postgres_init (void *cls)
|
|||||||
/* FIXME: use configuration section with "postgres" in its name... */
|
/* FIXME: use configuration section with "postgres" in its name... */
|
||||||
if (GNUNET_OK !=
|
if (GNUNET_OK !=
|
||||||
GNUNET_CONFIGURATION_get_value_string (cfg,
|
GNUNET_CONFIGURATION_get_value_string (cfg,
|
||||||
"mint", "db",
|
"mint", "db_conn_str",
|
||||||
&pg->TALER_MINT_db_connection_cfg_str))
|
&pg->TALER_MINT_db_connection_cfg_str))
|
||||||
{
|
{
|
||||||
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
GNUNET_log_config_missing (GNUNET_ERROR_TYPE_ERROR,
|
||||||
"mint",
|
"mint",
|
||||||
"db");
|
"db_conn_str");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
plugin = GNUNET_new (struct TALER_MINTDB_Plugin);
|
plugin = GNUNET_new (struct TALER_MINTDB_Plugin);
|
||||||
plugin->cls = pg;
|
plugin->cls = pg;
|
||||||
|
plugin->library_name = "libtaler_plugin_mintdb_postgres";
|
||||||
plugin->get_session = &postgres_get_session;
|
plugin->get_session = &postgres_get_session;
|
||||||
plugin->drop_temporary = &postgres_drop_temporary;
|
plugin->drop_temporary = &postgres_drop_temporary;
|
||||||
plugin->create_tables = &postgres_create_tables;
|
plugin->create_tables = &postgres_create_tables;
|
||||||
|
@ -478,6 +478,11 @@ struct TALER_MINTDB_Plugin
|
|||||||
*/
|
*/
|
||||||
void *cls;
|
void *cls;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Name of the library which generated this plugin
|
||||||
|
*/
|
||||||
|
const char *library_name;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the thread-local database-handle.
|
* Get the thread-local database-handle.
|
||||||
* Connect to the db if the connection does not exist yet.
|
* Connect to the db if the connection does not exist yet.
|
||||||
|
@ -343,6 +343,7 @@ run (void *cls,
|
|||||||
if (NULL != cbc2.sig.rsa_signature)
|
if (NULL != cbc2.sig.rsa_signature)
|
||||||
GNUNET_CRYPTO_rsa_signature_free (cbc2.sig.rsa_signature);
|
GNUNET_CRYPTO_rsa_signature_free (cbc2.sig.rsa_signature);
|
||||||
dkp = NULL;
|
dkp = NULL;
|
||||||
|
TALER_MINT_plugin_unload ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user