diff options
-rw-r--r-- | TODO | 3 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_mysql.c | 67 | ||||
-rw-r--r-- | src/datastore/plugin_datastore_postgres.c | 64 | ||||
-rw-r--r-- | src/include/gnunet_datastore_plugin.h | 3 | ||||
-rw-r--r-- | src/include/gnunet_datastore_service.h | 4 |
5 files changed, 42 insertions, 99 deletions
@@ -1,4 +1,7 @@ | |||
1 | 0.9.0pre3: [2'11] | 1 | 0.9.0pre3: [2'11] |
2 | * DATASTORE: | ||
3 | - get_random seems to not just return a SINGLE value, but an entire | ||
4 | sequence of values... => migration queue overflows! | ||
2 | * NAT/UPNP: [Milan / Ayush / MW] | 5 | * NAT/UPNP: [Milan / Ayush / MW] |
3 | - [#1609] code clean up | 6 | - [#1609] code clean up |
4 | - testing | 7 | - 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, | |||
1709 | } | 1709 | } |
1710 | 1710 | ||
1711 | 1711 | ||
1712 | |||
1713 | /** | ||
1714 | * Get a random item for expiration. | ||
1715 | * Call 'iter' with all values ZERO or NULL if the datastore is empty. | ||
1716 | * | ||
1717 | * @param cls closure | ||
1718 | * @param iter function to call the value (once only). | ||
1719 | * @param iter_cls closure for iter | ||
1720 | */ | ||
1721 | static void | ||
1722 | mysql_plugin_expiration_get (void *cls, | ||
1723 | PluginIterator iter, void *iter_cls) | ||
1724 | { | ||
1725 | /* FIXME: not implemented! */ | ||
1726 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, | ||
1727 | GNUNET_TIME_UNIT_ZERO_ABS, 0); | ||
1728 | } | ||
1729 | |||
1730 | |||
1712 | /** | 1731 | /** |
1713 | * Update the priority for a particular key in the datastore. If | 1732 | * Update the priority for a particular key in the datastore. If |
1714 | * the expiration time in value is different than the time found in | 1733 | * the expiration time in value is different than the time found in |
@@ -1810,50 +1829,6 @@ mysql_plugin_iter_zero_anonymity (void *cls, | |||
1810 | * @param iter_cls closure for iter | 1829 | * @param iter_cls closure for iter |
1811 | */ | 1830 | */ |
1812 | static void | 1831 | static void |
1813 | mysql_plugin_iter_ascending_expiration (void *cls, | ||
1814 | enum GNUNET_BLOCK_Type type, | ||
1815 | PluginIterator iter, | ||
1816 | void *iter_cls) | ||
1817 | { | ||
1818 | struct Plugin *plugin = cls; | ||
1819 | iterateHelper (plugin, type, GNUNET_YES, 2, iter, iter_cls); | ||
1820 | } | ||
1821 | |||
1822 | |||
1823 | /** | ||
1824 | * Select a subset of the items in the datastore and call | ||
1825 | * the given iterator for each of them. | ||
1826 | * | ||
1827 | * @param cls our "struct Plugin*" | ||
1828 | * @param type entries of which type should be considered? | ||
1829 | * Use 0 for any type. | ||
1830 | * @param iter function to call on each matching value; | ||
1831 | * will be called once with a NULL value at the end | ||
1832 | * @param iter_cls closure for iter | ||
1833 | */ | ||
1834 | static void | ||
1835 | mysql_plugin_iter_migration_order (void *cls, | ||
1836 | enum GNUNET_BLOCK_Type type, | ||
1837 | PluginIterator iter, | ||
1838 | void *iter_cls) | ||
1839 | { | ||
1840 | struct Plugin *plugin = cls; | ||
1841 | iterateHelper (plugin, 0, GNUNET_NO, 3, iter, iter_cls); | ||
1842 | } | ||
1843 | |||
1844 | |||
1845 | /** | ||
1846 | * Select a subset of the items in the datastore and call | ||
1847 | * the given iterator for each of them. | ||
1848 | * | ||
1849 | * @param cls our "struct Plugin*" | ||
1850 | * @param type entries of which type should be considered? | ||
1851 | * Use 0 for any type. | ||
1852 | * @param iter function to call on each matching value; | ||
1853 | * will be called once with a NULL value at the end | ||
1854 | * @param iter_cls closure for iter | ||
1855 | */ | ||
1856 | static void | ||
1857 | mysql_plugin_iter_all_now (void *cls, | 1832 | mysql_plugin_iter_all_now (void *cls, |
1858 | enum GNUNET_BLOCK_Type type, | 1833 | enum GNUNET_BLOCK_Type type, |
1859 | PluginIterator iter, | 1834 | PluginIterator iter, |
@@ -1963,11 +1938,9 @@ libgnunet_plugin_datastore_mysql_init (void *cls) | |||
1963 | api->next_request = &mysql_plugin_next_request; | 1938 | api->next_request = &mysql_plugin_next_request; |
1964 | api->get = &mysql_plugin_get; | 1939 | api->get = &mysql_plugin_get; |
1965 | api->replication_get = &mysql_plugin_replication_get; | 1940 | api->replication_get = &mysql_plugin_replication_get; |
1941 | api->expiration_get = &mysql_plugin_expiration_get; | ||
1966 | api->update = &mysql_plugin_update; | 1942 | api->update = &mysql_plugin_update; |
1967 | api->iter_low_priority = &mysql_plugin_iter_low_priority; | ||
1968 | api->iter_zero_anonymity = &mysql_plugin_iter_zero_anonymity; | 1943 | api->iter_zero_anonymity = &mysql_plugin_iter_zero_anonymity; |
1969 | api->iter_ascending_expiration = &mysql_plugin_iter_ascending_expiration; | ||
1970 | api->iter_migration_order = &mysql_plugin_iter_migration_order; | ||
1971 | api->iter_all_now = &mysql_plugin_iter_all_now; | 1944 | api->iter_all_now = &mysql_plugin_iter_all_now; |
1972 | api->drop = &mysql_plugin_drop; | 1945 | api->drop = &mysql_plugin_drop; |
1973 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, | 1946 | 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, | |||
1220 | 1220 | ||
1221 | 1221 | ||
1222 | /** | 1222 | /** |
1223 | * Select a subset of the items in the datastore and call | 1223 | * Get a random item for expiration. |
1224 | * the given iterator for each of them. | 1224 | * Call 'iter' with all values ZERO or NULL if the datastore is empty. |
1225 | * | ||
1226 | * @param cls our "struct Plugin*" | ||
1227 | * @param type entries of which type should be considered? | ||
1228 | * Use 0 for any type. | ||
1229 | * @param iter function to call on each matching value; | ||
1230 | * will be called once with a NULL value at the end | ||
1231 | * @param iter_cls closure for iter | ||
1232 | */ | ||
1233 | static void | ||
1234 | postgres_plugin_iter_zero_anonymity (void *cls, | ||
1235 | enum GNUNET_BLOCK_Type type, | ||
1236 | PluginIterator iter, | ||
1237 | void *iter_cls) | ||
1238 | { | ||
1239 | struct Plugin *plugin = cls; | ||
1240 | |||
1241 | postgres_iterate (plugin, | ||
1242 | type, GNUNET_NO, 1, | ||
1243 | iter, iter_cls); | ||
1244 | } | ||
1245 | |||
1246 | |||
1247 | /** | ||
1248 | * Select a subset of the items in the datastore and call | ||
1249 | * the given iterator for each of them. | ||
1250 | * | 1225 | * |
1251 | * @param cls our "struct Plugin*" | 1226 | * @param cls closure |
1252 | * @param type entries of which type should be considered? | 1227 | * @param iter function to call the value (once only). |
1253 | * Use 0 for any type. | ||
1254 | * @param iter function to call on each matching value; | ||
1255 | * will be called once with a NULL value at the end | ||
1256 | * @param iter_cls closure for iter | 1228 | * @param iter_cls closure for iter |
1257 | */ | 1229 | */ |
1258 | static void | 1230 | static void |
1259 | postgres_plugin_iter_ascending_expiration (void *cls, | 1231 | postgres_plugin_expiration_get (void *cls, |
1260 | enum GNUNET_BLOCK_Type type, | 1232 | PluginIterator iter, void *iter_cls) |
1261 | PluginIterator iter, | ||
1262 | void *iter_cls) | ||
1263 | { | 1233 | { |
1264 | struct Plugin *plugin = cls; | 1234 | /* FIXME: not implemented! */ |
1265 | 1235 | iter (iter_cls, NULL, NULL, 0, NULL, 0, 0, 0, | |
1266 | postgres_iterate (plugin, type, GNUNET_YES, 2, | 1236 | GNUNET_TIME_UNIT_ZERO_ABS, 0); |
1267 | iter, iter_cls); | ||
1268 | } | 1237 | } |
1269 | 1238 | ||
1270 | 1239 | ||
@@ -1280,14 +1249,15 @@ postgres_plugin_iter_ascending_expiration (void *cls, | |||
1280 | * @param iter_cls closure for iter | 1249 | * @param iter_cls closure for iter |
1281 | */ | 1250 | */ |
1282 | static void | 1251 | static void |
1283 | postgres_plugin_iter_migration_order (void *cls, | 1252 | postgres_plugin_iter_zero_anonymity (void *cls, |
1284 | enum GNUNET_BLOCK_Type type, | 1253 | enum GNUNET_BLOCK_Type type, |
1285 | PluginIterator iter, | 1254 | PluginIterator iter, |
1286 | void *iter_cls) | 1255 | void *iter_cls) |
1287 | { | 1256 | { |
1288 | struct Plugin *plugin = cls; | 1257 | struct Plugin *plugin = cls; |
1289 | 1258 | ||
1290 | postgres_iterate (plugin, 0, GNUNET_NO, 3, | 1259 | postgres_iterate (plugin, |
1260 | type, GNUNET_NO, 1, | ||
1291 | iter, iter_cls); | 1261 | iter, iter_cls); |
1292 | } | 1262 | } |
1293 | 1263 | ||
@@ -1356,11 +1326,9 @@ libgnunet_plugin_datastore_postgres_init (void *cls) | |||
1356 | api->next_request = &postgres_plugin_next_request; | 1326 | api->next_request = &postgres_plugin_next_request; |
1357 | api->get = &postgres_plugin_get; | 1327 | api->get = &postgres_plugin_get; |
1358 | api->replication_get = &postgres_plugin_replication_get; | 1328 | api->replication_get = &postgres_plugin_replication_get; |
1329 | api->expiration_get = &postgres_plugin_expiration_get; | ||
1359 | api->update = &postgres_plugin_update; | 1330 | api->update = &postgres_plugin_update; |
1360 | api->iter_low_priority = &postgres_plugin_iter_low_priority; | ||
1361 | api->iter_zero_anonymity = &postgres_plugin_iter_zero_anonymity; | 1331 | api->iter_zero_anonymity = &postgres_plugin_iter_zero_anonymity; |
1362 | api->iter_ascending_expiration = &postgres_plugin_iter_ascending_expiration; | ||
1363 | api->iter_migration_order = &postgres_plugin_iter_migration_order; | ||
1364 | api->iter_all_now = &postgres_plugin_iter_all_now; | 1332 | api->iter_all_now = &postgres_plugin_iter_all_now; |
1365 | api->drop = &postgres_plugin_drop; | 1333 | api->drop = &postgres_plugin_drop; |
1366 | GNUNET_log_from (GNUNET_ERROR_TYPE_INFO, | 1334 | 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); | |||
149 | * @param replication replication-level for the content | 149 | * @param replication replication-level for the content |
150 | * @param expiration expiration time for the content | 150 | * @param expiration expiration time for the content |
151 | * @param msg set to an error message (on failure) | 151 | * @param msg set to an error message (on failure) |
152 | * @return GNUNET_OK on success, GNUNET_NO if the content | 152 | * @return GNUNET_OK on success, |
153 | * was already present (and may have been updated); | ||
154 | * GNUNET_SYSERR on failure | 153 | * GNUNET_SYSERR on failure |
155 | */ | 154 | */ |
156 | typedef int (*PluginPut) (void *cls, | 155 | 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, | |||
80 | * operation. | 80 | * operation. |
81 | * | 81 | * |
82 | * @param cls closure | 82 | * @param cls closure |
83 | * @param success GNUNET_SYSERR on failure, | 83 | * @param success GNUNET_SYSERR on failure (including timeout/queue drop) |
84 | * GNUNET_NO on timeout/queue drop | 84 | * GNUNET_NO if content was already there |
85 | * GNUNET_YES (or other positive value) on success | 85 | * GNUNET_YES (or other positive value) on success |
86 | * @param msg NULL on success, otherwise an error message | 86 | * @param msg NULL on success, otherwise an error message |
87 | */ | 87 | */ |