diff options
author | Omar Tarabai <tarabai@devegypt.com> | 2014-04-25 18:00:04 +0000 |
---|---|---|
committer | Omar Tarabai <tarabai@devegypt.com> | 2014-04-25 18:00:04 +0000 |
commit | f5961cc463e301090c16577f2f0cb28ca614d734 (patch) | |
tree | d864d47295159e892c5b2a824cdc380e7513a919 /src/peerstore/gnunet-service-peerstore.c | |
parent | 344f48e48e8d4f1ea631f29d8fb3ae0faf3d7ef0 (diff) | |
download | gnunet-f5961cc463e301090c16577f2f0cb28ca614d734.tar.gz gnunet-f5961cc463e301090c16577f2f0cb28ca614d734.zip |
towards PEERSTORE file plugin
Diffstat (limited to 'src/peerstore/gnunet-service-peerstore.c')
-rw-r--r-- | src/peerstore/gnunet-service-peerstore.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/src/peerstore/gnunet-service-peerstore.c b/src/peerstore/gnunet-service-peerstore.c index 2c54b6d0c..418e33703 100644 --- a/src/peerstore/gnunet-service-peerstore.c +++ b/src/peerstore/gnunet-service-peerstore.c | |||
@@ -33,6 +33,11 @@ | |||
33 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 33 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * Database handle | ||
37 | */ | ||
38 | static struct GNUNET_PEERSTORE_PluginFunctions *db; | ||
39 | |||
40 | /** | ||
36 | * Task run during shutdown. | 41 | * Task run during shutdown. |
37 | * | 42 | * |
38 | * @param cls unused | 43 | * @param cls unused |
@@ -80,16 +85,23 @@ run (void *cls, | |||
80 | if (GNUNET_OK != | 85 | if (GNUNET_OK != |
81 | GNUNET_CONFIGURATION_get_value_string (cfg, "peerstore", "DATABASE", | 86 | GNUNET_CONFIGURATION_get_value_string (cfg, "peerstore", "DATABASE", |
82 | &database)) | 87 | &database)) |
83 | { | ||
84 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n"); | 88 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "No database backend configured\n"); |
85 | return; | ||
86 | } | ||
87 | GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_peerstore_%s", database); | ||
88 | 89 | ||
89 | GNUNET_SERVER_add_handlers (server, handlers); | 90 | else |
90 | GNUNET_SERVER_disconnect_notify (server, | 91 | { |
91 | &handle_client_disconnect, | 92 | GNUNET_asprintf (&db_lib_name, "libgnunet_plugin_peerstore_%s", database); |
92 | NULL); | 93 | db = GNUNET_PLUGIN_load(db_lib_name, (void *) cfg); |
94 | GNUNET_free(database); | ||
95 | } | ||
96 | if(NULL == db) | ||
97 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, "Could not load database backend `%s'\n", db_lib_name); | ||
98 | else | ||
99 | { | ||
100 | GNUNET_SERVER_add_handlers (server, handlers); | ||
101 | GNUNET_SERVER_disconnect_notify (server, | ||
102 | &handle_client_disconnect, | ||
103 | NULL); | ||
104 | } | ||
93 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 105 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
94 | &shutdown_task, | 106 | &shutdown_task, |
95 | NULL); | 107 | NULL); |