![]() |
GNUnet
0.11.x
|
postgres-based namecache backend More...
#include "platform.h"
#include "gnunet_namecache_plugin.h"
#include "gnunet_namecache_service.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_pq_lib.h"
#include "namecache.h"
Go to the source code of this file.
Data Structures | |
struct | Plugin |
Handle for a plugin. More... | |
Macros | |
#define | LOG(kind, ...) GNUNET_log_from (kind, "namecache-postgres", __VA_ARGS__) |
Functions | |
static int | database_setup (struct Plugin *plugin) |
Initialize the database connections and associated data structures (create tables and indices as needed as well). More... | |
static void | namecache_postgres_expire_blocks (struct Plugin *plugin) |
Removes any expired block. More... | |
static void | delete_old_block (struct Plugin *plugin, const struct GNUNET_HashCode *query, struct GNUNET_TIME_Absolute expiration_time) |
Delete older block in the datastore. More... | |
static int | namecache_postgres_cache_block (void *cls, const struct GNUNET_GNSRECORD_Block *block) |
Cache a block in the datastore. More... | |
static int | namecache_postgres_lookup_block (void *cls, const struct GNUNET_HashCode *query, GNUNET_NAMECACHE_BlockCallback iter, void *iter_cls) |
Get the block for a particular zone and label in the datastore. More... | |
static void | database_shutdown (struct Plugin *plugin) |
Shutdown database connection and associate data structures. More... | |
void * | libgnunet_plugin_namecache_postgres_init (void *cls) |
Entry point for the plugin. More... | |
void * | libgnunet_plugin_namecache_postgres_done (void *cls) |
Exit point from the plugin. More... | |
postgres-based namecache backend
Definition in file plugin_namecache_postgres.c.
#define LOG | ( | kind, | |
... | |||
) | GNUNET_log_from (kind, "namecache-postgres", __VA_ARGS__) |
Definition at line 34 of file plugin_namecache_postgres.c.
Referenced by libgnunet_plugin_namecache_postgres_done(), libgnunet_plugin_namecache_postgres_init(), and namecache_postgres_lookup_block().
|
static |
Initialize the database connections and associated data structures (create tables and indices as needed as well).
plugin | the plugin context (state for this module) |
Definition at line 60 of file plugin_namecache_postgres.c.
References Plugin::cfg, Plugin::dbh, GNUNET_CONFIGURATION_get_value_yesno(), GNUNET_OK, GNUNET_PQ_connect_with_cfg(), GNUNET_PQ_EXECUTE_STATEMENT_END, GNUNET_PQ_make_execute(), GNUNET_PQ_make_prepare(), GNUNET_PQ_make_try_execute(), GNUNET_PQ_PREPARED_STATEMENT_END, GNUNET_SYSERR, and GNUNET_YES.
Referenced by libgnunet_plugin_namecache_postgres_init().
|
static |
Removes any expired block.
plugin | the plugin |
Definition at line 130 of file plugin_namecache_postgres.c.
References Plugin::dbh, GNUNET_break, GNUNET_DB_STATUS_HARD_ERROR, GNUNET_PQ_eval_prepared_non_select(), GNUNET_PQ_query_param_absolute_time(), GNUNET_PQ_query_param_end, GNUNET_TIME_absolute_get(), and res.
Referenced by namecache_postgres_cache_block().
|
static |
Delete older block in the datastore.
plugin | the plugin |
query | query for the block |
expiration_time | how old does the block have to be for deletion |
Definition at line 154 of file plugin_namecache_postgres.c.
References Plugin::dbh, GNUNET_break, GNUNET_DB_STATUS_HARD_ERROR, GNUNET_PQ_eval_prepared_non_select(), GNUNET_PQ_query_param_absolute_time(), GNUNET_PQ_query_param_auto_from_type, GNUNET_PQ_query_param_end, and res.
Referenced by namecache_postgres_cache_block().
|
static |
Cache a block in the datastore.
cls | closure (internal context for the plugin) |
block | block to cache |
Definition at line 180 of file plugin_namecache_postgres.c.
References Plugin::dbh, delete_old_block(), GNUNET_break, GNUNET_GNSRECORD_block_get_expiration(), GNUNET_GNSRECORD_block_get_size(), GNUNET_GNSRECORD_query_from_block(), GNUNET_OK, GNUNET_PQ_eval_prepared_non_select(), GNUNET_PQ_query_param_absolute_time(), GNUNET_PQ_query_param_auto_from_type, GNUNET_PQ_query_param_end, GNUNET_PQ_query_param_fixed_size(), GNUNET_SYSERR, namecache_postgres_expire_blocks(), plugin, and res.
Referenced by libgnunet_plugin_namecache_postgres_init().
|
static |
Get the block for a particular zone and label in the datastore.
Will return at most one result to the iterator.
cls | closure (internal context for the plugin) |
query | hash of public key derived from the zone and the label |
iter | function to call with the result |
iter_cls | closure for iter |
Definition at line 228 of file plugin_namecache_postgres.c.
References bsize, Plugin::dbh, GNUNET_break, GNUNET_DB_STATUS_SUCCESS_NO_RESULTS, GNUNET_ERROR_TYPE_DEBUG, GNUNET_ERROR_TYPE_WARNING, GNUNET_NO, GNUNET_OK, GNUNET_PQ_cleanup_result(), GNUNET_PQ_eval_prepared_singleton_select(), GNUNET_PQ_query_param_auto_from_type, GNUNET_PQ_query_param_end, GNUNET_PQ_result_spec_end, GNUNET_PQ_result_spec_variable_size(), GNUNET_SYSERR, Plugin::iter, LOG, plugin, and res.
Referenced by libgnunet_plugin_namecache_postgres_init().
|
static |
Shutdown database connection and associate data structures.
plugin | the plugin context (state for this module) |
Definition at line 287 of file plugin_namecache_postgres.c.
References Plugin::dbh, and GNUNET_PQ_disconnect().
Referenced by libgnunet_plugin_namecache_postgres_done(), and libgnunet_plugin_namecache_postgres_init().
void* libgnunet_plugin_namecache_postgres_init | ( | void * | cls | ) |
Entry point for the plugin.
cls | the struct GNUNET_NAMECACHE_PluginEnvironment * |
Definition at line 301 of file plugin_namecache_postgres.c.
References Plugin::api, GNUNET_NAMECACHE_PluginFunctions::cache_block, Plugin::cfg, GNUNET_NAMECACHE_PluginFunctions::cls, database_setup(), database_shutdown(), GNUNET_ERROR_TYPE_INFO, GNUNET_new, GNUNET_OK, LOG, GNUNET_NAMECACHE_PluginFunctions::lookup_block, namecache_postgres_cache_block(), namecache_postgres_lookup_block(), and plugin.
void* libgnunet_plugin_namecache_postgres_done | ( | void * | cls | ) |
Exit point from the plugin.
cls | the plugin context (as returned by "init") |
Definition at line 333 of file plugin_namecache_postgres.c.
References Plugin::api, Plugin::cfg, GNUNET_NAMECACHE_PluginFunctions::cls, database_shutdown(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_free, LOG, and plugin.