From 52384a51f64fdfdb380cb84c705e9f06e9e3ea40 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Mon, 4 Apr 2011 08:22:39 +0000 Subject: make compile --- TODO | 3 ++ src/datastore/plugin_datastore_mysql.c | 67 +++++++++---------------------- src/datastore/plugin_datastore_postgres.c | 64 ++++++++--------------------- src/include/gnunet_datastore_plugin.h | 3 +- src/include/gnunet_datastore_service.h | 4 +- 5 files changed, 42 insertions(+), 99 deletions(-) diff --git a/TODO b/TODO index f751dab16..5faf10083 100644 --- a/TODO +++ b/TODO @@ -1,4 +1,7 @@ 0.9.0pre3: [2'11] +* DATASTORE: + - get_random seems to not just return a SINGLE value, but an entire + sequence of values... => migration queue overflows! * NAT/UPNP: [Milan / Ayush / MW] - [#1609] code clean up - testing diff --git a/src/datastore/plugin_datastore_mysql.c b/src/datastore/plugin_datastore_mysql.c index fb1b13978..b56e142fb 100644 --- a/src/datastore/plugin_datastore_mysql.c +++ b/src/datastore/plugin_datastore_mysql.c @@ -1709,6 +1709,25 @@ mysql_plugin_replication_get (void *cls, } + +/** + * Get a random item for expiration. + * Call 'iter' with all values ZERO or NULL if the datastore is empty. + * + * @param cls closure + * @param iter function to call the value (once only). + * @param iter_cls closure for iter + */ +static void +mysql_plugin_expiration_get (void *cls, + PluginIterator iter, void *iter_cls) +{ + /* FIXME: not implemented! */ + iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, + GNUNET_TIME_UNIT_ZERO_ABS, 0); +} + + /** * Update the priority for a particular key in the datastore. If * the expiration time in value is different than the time found in @@ -1798,50 +1817,6 @@ mysql_plugin_iter_zero_anonymity (void *cls, } -/** - * Select a subset of the items in the datastore and call - * the given iterator for each of them. - * - * @param cls our "struct Plugin*" - * @param type entries of which type should be considered? - * Use 0 for any type. - * @param iter function to call on each matching value; - * will be called once with a NULL value at the end - * @param iter_cls closure for iter - */ -static void -mysql_plugin_iter_ascending_expiration (void *cls, - enum GNUNET_BLOCK_Type type, - PluginIterator iter, - void *iter_cls) -{ - struct Plugin *plugin = cls; - iterateHelper (plugin, type, GNUNET_YES, 2, iter, iter_cls); -} - - -/** - * Select a subset of the items in the datastore and call - * the given iterator for each of them. - * - * @param cls our "struct Plugin*" - * @param type entries of which type should be considered? - * Use 0 for any type. - * @param iter function to call on each matching value; - * will be called once with a NULL value at the end - * @param iter_cls closure for iter - */ -static void -mysql_plugin_iter_migration_order (void *cls, - enum GNUNET_BLOCK_Type type, - PluginIterator iter, - void *iter_cls) -{ - struct Plugin *plugin = cls; - iterateHelper (plugin, 0, GNUNET_NO, 3, iter, iter_cls); -} - - /** * Select a subset of the items in the datastore and call * the given iterator for each of them. @@ -1963,11 +1938,9 @@ libgnunet_plugin_datastore_mysql_init (void *cls) api->next_request = &mysql_plugin_next_request; api->get = &mysql_plugin_get; api->replication_get = &mysql_plugin_replication_get; + api->expiration_get = &mysql_plugin_expiration_get; api->update = &mysql_plugin_update; - api->iter_low_priority = &mysql_plugin_iter_low_priority; api->iter_zero_anonymity = &mysql_plugin_iter_zero_anonymity; - api->iter_ascending_expiration = &mysql_plugin_iter_ascending_expiration; - api->iter_migration_order = &mysql_plugin_iter_migration_order; api->iter_all_now = &mysql_plugin_iter_all_now; api->drop = &mysql_plugin_drop; GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, diff --git a/src/datastore/plugin_datastore_postgres.c b/src/datastore/plugin_datastore_postgres.c index c004cd59f..cdd8e405e 100644 --- a/src/datastore/plugin_datastore_postgres.c +++ b/src/datastore/plugin_datastore_postgres.c @@ -1220,51 +1220,20 @@ postgres_plugin_replication_get (void *cls, /** - * Select a subset of the items in the datastore and call - * the given iterator for each of them. - * - * @param cls our "struct Plugin*" - * @param type entries of which type should be considered? - * Use 0 for any type. - * @param iter function to call on each matching value; - * will be called once with a NULL value at the end - * @param iter_cls closure for iter - */ -static void -postgres_plugin_iter_zero_anonymity (void *cls, - enum GNUNET_BLOCK_Type type, - PluginIterator iter, - void *iter_cls) -{ - struct Plugin *plugin = cls; - - postgres_iterate (plugin, - type, GNUNET_NO, 1, - iter, iter_cls); -} - - -/** - * Select a subset of the items in the datastore and call - * the given iterator for each of them. + * Get a random item for expiration. + * Call 'iter' with all values ZERO or NULL if the datastore is empty. * - * @param cls our "struct Plugin*" - * @param type entries of which type should be considered? - * Use 0 for any type. - * @param iter function to call on each matching value; - * will be called once with a NULL value at the end + * @param cls closure + * @param iter function to call the value (once only). * @param iter_cls closure for iter */ static void -postgres_plugin_iter_ascending_expiration (void *cls, - enum GNUNET_BLOCK_Type type, - PluginIterator iter, - void *iter_cls) +postgres_plugin_expiration_get (void *cls, + PluginIterator iter, void *iter_cls) { - struct Plugin *plugin = cls; - - postgres_iterate (plugin, type, GNUNET_YES, 2, - iter, iter_cls); + /* FIXME: not implemented! */ + iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, + GNUNET_TIME_UNIT_ZERO_ABS, 0); } @@ -1280,14 +1249,15 @@ postgres_plugin_iter_ascending_expiration (void *cls, * @param iter_cls closure for iter */ static void -postgres_plugin_iter_migration_order (void *cls, - enum GNUNET_BLOCK_Type type, - PluginIterator iter, - void *iter_cls) +postgres_plugin_iter_zero_anonymity (void *cls, + enum GNUNET_BLOCK_Type type, + PluginIterator iter, + void *iter_cls) { struct Plugin *plugin = cls; - postgres_iterate (plugin, 0, GNUNET_NO, 3, + postgres_iterate (plugin, + type, GNUNET_NO, 1, iter, iter_cls); } @@ -1356,11 +1326,9 @@ libgnunet_plugin_datastore_postgres_init (void *cls) api->next_request = &postgres_plugin_next_request; api->get = &postgres_plugin_get; api->replication_get = &postgres_plugin_replication_get; + api->expiration_get = &postgres_plugin_expiration_get; api->update = &postgres_plugin_update; - api->iter_low_priority = &postgres_plugin_iter_low_priority; api->iter_zero_anonymity = &postgres_plugin_iter_zero_anonymity; - api->iter_ascending_expiration = &postgres_plugin_iter_ascending_expiration; - api->iter_migration_order = &postgres_plugin_iter_migration_order; api->iter_all_now = &postgres_plugin_iter_all_now; api->drop = &postgres_plugin_drop; GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, diff --git a/src/include/gnunet_datastore_plugin.h b/src/include/gnunet_datastore_plugin.h index 34a659163..a3f8b5f3b 100644 --- a/src/include/gnunet_datastore_plugin.h +++ b/src/include/gnunet_datastore_plugin.h @@ -149,8 +149,7 @@ typedef unsigned long long (*PluginGetSize) (void *cls); * @param replication replication-level for the content * @param expiration expiration time for the content * @param msg set to an error message (on failure) - * @return GNUNET_OK on success, GNUNET_NO if the content - * was already present (and may have been updated); + * @return GNUNET_OK on success, * GNUNET_SYSERR on failure */ typedef int (*PluginPut) (void *cls, diff --git a/src/include/gnunet_datastore_service.h b/src/include/gnunet_datastore_service.h index 284d544f5..756d2f3be 100644 --- a/src/include/gnunet_datastore_service.h +++ b/src/include/gnunet_datastore_service.h @@ -80,8 +80,8 @@ void GNUNET_DATASTORE_disconnect (struct GNUNET_DATASTORE_Handle *h, * operation. * * @param cls closure - * @param success GNUNET_SYSERR on failure, - * GNUNET_NO on timeout/queue drop + * @param success GNUNET_SYSERR on failure (including timeout/queue drop) + * GNUNET_NO if content was already there * GNUNET_YES (or other positive value) on success * @param msg NULL on success, otherwise an error message */ -- cgit v1.2.3