diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-24 20:17:39 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-24 20:17:39 +0000 |
commit | 3140154d46212e08e0d73ed891a66213a6813075 (patch) | |
tree | 018a55a3899207664b388fcf47a679ca54ca6fbf /src/datastore/test_plugin_datastore.c | |
parent | d5fd881c2a044474b54ddf03b6ab8be8d2b75927 (diff) | |
download | gnunet-3140154d46212e08e0d73ed891a66213a6813075.tar.gz gnunet-3140154d46212e08e0d73ed891a66213a6813075.zip |
refactoring datastore API to use MQ API, also fixing misc. bugs in new mysql backend
Diffstat (limited to 'src/datastore/test_plugin_datastore.c')
-rw-r--r-- | src/datastore/test_plugin_datastore.c | 48 |
1 files changed, 35 insertions, 13 deletions
diff --git a/src/datastore/test_plugin_datastore.c b/src/datastore/test_plugin_datastore.c index 9ec0c53a2..9b85d57da 100644 --- a/src/datastore/test_plugin_datastore.c +++ b/src/datastore/test_plugin_datastore.c | |||
@@ -109,11 +109,14 @@ put_continuation (void *cls, | |||
109 | 109 | ||
110 | if (GNUNET_OK != status) | 110 | if (GNUNET_OK != status) |
111 | { | 111 | { |
112 | FPRINTF (stderr, "ERROR: `%s'\n", msg); | 112 | FPRINTF (stderr, |
113 | "ERROR: `%s'\n", | ||
114 | msg); | ||
113 | } | 115 | } |
114 | else | 116 | else |
115 | { | 117 | { |
116 | crc->api->estimate_size (crc->api->cls, &cs); | 118 | crc->api->estimate_size (crc->api->cls, |
119 | &cs); | ||
117 | GNUNET_assert (os <= cs); | 120 | GNUNET_assert (os <= cs); |
118 | os = cs; | 121 | os = cs; |
119 | stored_bytes += size; | 122 | stored_bytes += size; |
@@ -184,22 +187,30 @@ static uint64_t guid; | |||
184 | 187 | ||
185 | 188 | ||
186 | static int | 189 | static int |
187 | iterate_one_shot (void *cls, const struct GNUNET_HashCode * key, uint32_t size, | 190 | iterate_one_shot (void *cls, |
188 | const void *data, enum GNUNET_BLOCK_Type type, | 191 | const struct GNUNET_HashCode *key, |
189 | uint32_t priority, uint32_t anonymity, | 192 | uint32_t size, |
190 | struct GNUNET_TIME_Absolute expiration, uint64_t uid) | 193 | const void *data, |
194 | enum GNUNET_BLOCK_Type type, | ||
195 | uint32_t priority, | ||
196 | uint32_t anonymity, | ||
197 | struct GNUNET_TIME_Absolute expiration, | ||
198 | uint64_t uid) | ||
191 | { | 199 | { |
192 | struct CpsRunContext *crc = cls; | 200 | struct CpsRunContext *crc = cls; |
193 | 201 | ||
194 | GNUNET_assert (key != NULL); | 202 | GNUNET_assert (NULL != key); |
195 | guid = uid; | 203 | guid = uid; |
196 | crc->phase++; | 204 | crc->phase++; |
197 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 205 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
198 | "Found result type=%u, priority=%u, size=%u, expire=%s, key %s\n", | 206 | "Found result type=%u, priority=%u, size=%u, expire=%s, key %s\n", |
199 | type, priority, size, | 207 | (unsigned int) type, |
208 | (unsigned int) priority, | ||
209 | (unsigned int) size, | ||
200 | GNUNET_STRINGS_absolute_time_to_string (expiration), | 210 | GNUNET_STRINGS_absolute_time_to_string (expiration), |
201 | GNUNET_h2s (key)); | 211 | GNUNET_h2s (key)); |
202 | GNUNET_SCHEDULER_add_now (&test, crc); | 212 | GNUNET_SCHEDULER_add_now (&test, |
213 | crc); | ||
203 | return GNUNET_OK; | 214 | return GNUNET_OK; |
204 | } | 215 | } |
205 | 216 | ||
@@ -219,11 +230,14 @@ unload_plugin (struct GNUNET_DATASTORE_PluginFunctions *api, | |||
219 | char *libname; | 230 | char *libname; |
220 | 231 | ||
221 | if (GNUNET_OK != | 232 | if (GNUNET_OK != |
222 | GNUNET_CONFIGURATION_get_value_string (cfg, "DATASTORE", "DATABASE", | 233 | GNUNET_CONFIGURATION_get_value_string (cfg, |
234 | "DATASTORE", | ||
235 | "DATABASE", | ||
223 | &name)) | 236 | &name)) |
224 | { | 237 | { |
225 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 238 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
226 | _("No `%s' specified for `%s' in configuration!\n"), "DATABASE", | 239 | _("No `%s' specified for `%s' in configuration!\n"), |
240 | "DATABASE", | ||
227 | "DATASTORE"); | 241 | "DATASTORE"); |
228 | return; | 242 | return; |
229 | } | 243 | } |
@@ -290,8 +304,16 @@ test (void *cls) | |||
290 | break; | 304 | break; |
291 | } | 305 | } |
292 | gen_key (5, &key); | 306 | gen_key (5, &key); |
293 | crc->api->get_key (crc->api->cls, crc->offset++, &key, NULL, | 307 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
294 | GNUNET_BLOCK_TYPE_ANY, &iterate_one_shot, crc); | 308 | "Looking for %s\n", |
309 | GNUNET_h2s (&key)); | ||
310 | crc->api->get_key (crc->api->cls, | ||
311 | crc->offset++, | ||
312 | &key, | ||
313 | NULL, | ||
314 | GNUNET_BLOCK_TYPE_ANY, | ||
315 | &iterate_one_shot, | ||
316 | crc); | ||
295 | break; | 317 | break; |
296 | case RP_UPDATE: | 318 | case RP_UPDATE: |
297 | crc->api->update (crc->api->cls, | 319 | crc->api->update (crc->api->cls, |