aboutsummaryrefslogtreecommitdiff
path: root/src/namestore/test_namestore_api_zone_iteration_nick.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-07-09 14:29:34 +0000
committerChristian Grothoff <christian@grothoff.org>2016-07-09 14:29:34 +0000
commit03374cc39814fa4bfb8d96e1165c688c44d8342f (patch)
treeed772250c49b39d82b9708ec8df0ee3e07e366d1 /src/namestore/test_namestore_api_zone_iteration_nick.c
parent0c13a1e6fb0baffd83d413f313742a5f2b420297 (diff)
downloadgnunet-03374cc39814fa4bfb8d96e1165c688c44d8342f.tar.gz
gnunet-03374cc39814fa4bfb8d96e1165c688c44d8342f.zip
make namestore API less brittle/sublte to use
Diffstat (limited to 'src/namestore/test_namestore_api_zone_iteration_nick.c')
-rw-r--r--src/namestore/test_namestore_api_zone_iteration_nick.c53
1 files changed, 41 insertions, 12 deletions
diff --git a/src/namestore/test_namestore_api_zone_iteration_nick.c b/src/namestore/test_namestore_api_zone_iteration_nick.c
index 362533ef9..791702f97 100644
--- a/src/namestore/test_namestore_api_zone_iteration_nick.c
+++ b/src/namestore/test_namestore_api_zone_iteration_nick.c
@@ -199,6 +199,18 @@ check_zone_2 (const char *label,
199 199
200 200
201static void 201static void
202zone_proc_end (void *cls)
203{
204 zi = NULL;
205 res = 0;
206 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
207 "Received last result, iteration done after receing %u results\n",
208 returned_records);
209 GNUNET_SCHEDULER_add_now (&end, NULL);
210}
211
212
213static void
202zone_proc (void *cls, 214zone_proc (void *cls,
203 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, 215 const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone,
204 const char *label, 216 const char *label,
@@ -206,16 +218,7 @@ zone_proc (void *cls,
206 const struct GNUNET_GNSRECORD_Data *rd) 218 const struct GNUNET_GNSRECORD_Data *rd)
207{ 219{
208 int failed = GNUNET_NO; 220 int failed = GNUNET_NO;
209 if ((zone == NULL) && (label == NULL)) 221
210 {
211 zi = NULL;
212 res = 0;
213 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
214 "Received last result, iteration done after receing %u results\n",
215 returned_records);
216 GNUNET_SCHEDULER_add_now (&end, NULL);
217 return;
218 }
219 GNUNET_assert (NULL != zone); 222 GNUNET_assert (NULL != zone);
220 if (0 == memcmp (zone, privkey, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) 223 if (0 == memcmp (zone, privkey, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey)))
221 { 224 {
@@ -254,6 +257,13 @@ zone_proc (void *cls,
254 257
255 258
256static void 259static void
260fail_cb (void *cls)
261{
262 GNUNET_assert (0);
263}
264
265
266static void
257put_cont (void *cls, int32_t success, const char *emsg) 267put_cont (void *cls, int32_t success, const char *emsg)
258{ 268{
259 static int c = 0; 269 static int c = 0;
@@ -281,7 +291,11 @@ put_cont (void *cls, int32_t success, const char *emsg)
281 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n"); 291 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n");
282 zi = GNUNET_NAMESTORE_zone_iteration_start (nsh, 292 zi = GNUNET_NAMESTORE_zone_iteration_start (nsh,
283 NULL, 293 NULL,
294 &fail_cb,
295 NULL,
284 &zone_proc, 296 &zone_proc,
297 NULL,
298 &zone_proc_end,
285 NULL); 299 NULL);
286 if (zi == NULL) 300 if (zi == NULL)
287 { 301 {
@@ -378,8 +392,8 @@ empty_zone_proc (void *cls,
378 unsigned int rd_count, 392 unsigned int rd_count,
379 const struct GNUNET_GNSRECORD_Data *rd) 393 const struct GNUNET_GNSRECORD_Data *rd)
380{ 394{
381 char *hostkey_file;
382 GNUNET_assert (nsh == cls); 395 GNUNET_assert (nsh == cls);
396
383 if (NULL != zone) 397 if (NULL != zone)
384 { 398 {
385 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 399 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -400,6 +414,15 @@ empty_zone_proc (void *cls,
400 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); 414 endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL);
401 return; 415 return;
402 } 416 }
417 GNUNET_assert (0);
418}
419
420
421static void
422empty_zone_end (void *cls)
423{
424 char *hostkey_file;
425 GNUNET_assert (nsh == cls);
403 426
404 zi = NULL; 427 zi = NULL;
405 GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, 428 GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR,
@@ -445,7 +468,13 @@ run (void *cls,
445 468
446 /* first, iterate over empty namestore */ 469 /* first, iterate over empty namestore */
447 zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, 470 zi = GNUNET_NAMESTORE_zone_iteration_start(nsh,
448 NULL, &empty_zone_proc, nsh); 471 NULL,
472 &fail_cb,
473 NULL,
474 &empty_zone_proc,
475 nsh,
476 &empty_zone_end,
477 nsh);
449 if (NULL == zi) 478 if (NULL == zi)
450 { 479 {
451 GNUNET_log (GNUNET_ERROR_TYPE_ERROR, 480 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,