diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-07-09 14:29:34 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-07-09 14:29:34 +0000 |
commit | 03374cc39814fa4bfb8d96e1165c688c44d8342f (patch) | |
tree | ed772250c49b39d82b9708ec8df0ee3e07e366d1 /src/namestore | |
parent | 0c13a1e6fb0baffd83d413f313742a5f2b420297 (diff) | |
download | gnunet-03374cc39814fa4bfb8d96e1165c688c44d8342f.tar.gz gnunet-03374cc39814fa4bfb8d96e1165c688c44d8342f.zip |
make namestore API less brittle/sublte to use
Diffstat (limited to 'src/namestore')
-rw-r--r-- | src/namestore/gnunet-namestore-fcfsd.c | 142 | ||||
-rw-r--r-- | src/namestore/gnunet-namestore.c | 110 | ||||
-rw-r--r-- | src/namestore/namestore_api.c | 92 | ||||
-rw-r--r-- | src/namestore/namestore_api_monitor.c | 52 | ||||
-rw-r--r-- | src/namestore/plugin_rest_namestore.c | 86 | ||||
-rw-r--r-- | src/namestore/test_namestore_api.conf | 3 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_lookup_nick.c | 16 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_lookup_private.c | 19 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_monitoring.c | 23 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_monitoring_existing.c | 17 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_zone_iteration.c | 92 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_zone_iteration_nick.c | 53 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_zone_iteration_specific_zone.c | 162 | ||||
-rw-r--r-- | src/namestore/test_namestore_api_zone_iteration_stop.c | 125 |
14 files changed, 740 insertions, 252 deletions
diff --git a/src/namestore/gnunet-namestore-fcfsd.c b/src/namestore/gnunet-namestore-fcfsd.c index ed7009e02..b38761d5a 100644 --- a/src/namestore/gnunet-namestore-fcfsd.c +++ b/src/namestore/gnunet-namestore-fcfsd.c | |||
@@ -247,6 +247,62 @@ run_httpd_now () | |||
247 | 247 | ||
248 | 248 | ||
249 | /** | 249 | /** |
250 | * Function called on error in zone iteration. | ||
251 | */ | ||
252 | static void | ||
253 | zone_iteration_error (void *cls) | ||
254 | { | ||
255 | struct ZoneinfoRequest *zr = cls; | ||
256 | struct MHD_Response *response; | ||
257 | |||
258 | zr->list_it = NULL; | ||
259 | response = MHD_create_response_from_buffer (strlen ("internal error"), | ||
260 | (void *) "internal error", | ||
261 | MHD_RESPMEM_PERSISTENT); | ||
262 | MHD_queue_response (zr->connection, | ||
263 | MHD_HTTP_INTERNAL_SERVER_ERROR, | ||
264 | response); | ||
265 | MHD_destroy_response (response); | ||
266 | GNUNET_free (zr->zoneinfo); | ||
267 | GNUNET_free (zr); | ||
268 | run_httpd_now (); | ||
269 | } | ||
270 | |||
271 | |||
272 | /** | ||
273 | * Function called once the zone iteration is done. | ||
274 | */ | ||
275 | static void | ||
276 | zone_iteration_end (void *cls) | ||
277 | { | ||
278 | struct ZoneinfoRequest *zr = cls; | ||
279 | struct MHD_Response *response; | ||
280 | char* full_page; | ||
281 | |||
282 | zr->list_it = NULL; | ||
283 | |||
284 | /* return static form */ | ||
285 | GNUNET_asprintf (&full_page, | ||
286 | ZONEINFO_PAGE, | ||
287 | zr->zoneinfo, | ||
288 | zr->zoneinfo); | ||
289 | response = MHD_create_response_from_buffer (strlen (full_page), | ||
290 | (void *) full_page, | ||
291 | MHD_RESPMEM_MUST_FREE); | ||
292 | MHD_add_response_header (response, | ||
293 | MHD_HTTP_HEADER_CONTENT_TYPE, | ||
294 | MIME_HTML); | ||
295 | MHD_queue_response (zr->connection, | ||
296 | MHD_HTTP_OK, | ||
297 | response); | ||
298 | MHD_destroy_response (response); | ||
299 | GNUNET_free (zr->zoneinfo); | ||
300 | GNUNET_free (zr); | ||
301 | run_httpd_now (); | ||
302 | } | ||
303 | |||
304 | |||
305 | /** | ||
250 | * Process a record that was stored in the namestore, adding | 306 | * Process a record that was stored in the namestore, adding |
251 | * the information to the HTML. | 307 | * the information to the HTML. |
252 | * | 308 | * |
@@ -264,38 +320,10 @@ iterate_cb (void *cls, | |||
264 | const struct GNUNET_GNSRECORD_Data *rd) | 320 | const struct GNUNET_GNSRECORD_Data *rd) |
265 | { | 321 | { |
266 | struct ZoneinfoRequest *zr = cls; | 322 | struct ZoneinfoRequest *zr = cls; |
267 | struct MHD_Response *response; | ||
268 | char* full_page; | ||
269 | size_t bytes_free; | 323 | size_t bytes_free; |
270 | char* pkey; | 324 | char* pkey; |
271 | char* new_buf; | 325 | char* new_buf; |
272 | 326 | ||
273 | |||
274 | if (NULL == name) | ||
275 | { | ||
276 | zr->list_it = NULL; | ||
277 | |||
278 | /* return static form */ | ||
279 | GNUNET_asprintf (&full_page, | ||
280 | ZONEINFO_PAGE, | ||
281 | zr->zoneinfo, | ||
282 | zr->zoneinfo); | ||
283 | response = MHD_create_response_from_buffer (strlen (full_page), | ||
284 | (void *) full_page, | ||
285 | MHD_RESPMEM_MUST_FREE); | ||
286 | MHD_add_response_header (response, | ||
287 | MHD_HTTP_HEADER_CONTENT_TYPE, | ||
288 | MIME_HTML); | ||
289 | MHD_queue_response (zr->connection, | ||
290 | MHD_HTTP_OK, | ||
291 | response); | ||
292 | MHD_destroy_response (response); | ||
293 | GNUNET_free (zr->zoneinfo); | ||
294 | GNUNET_free (zr); | ||
295 | run_httpd_now (); | ||
296 | return; | ||
297 | } | ||
298 | |||
299 | if (1 != rd_len) | 327 | if (1 != rd_len) |
300 | { | 328 | { |
301 | GNUNET_NAMESTORE_zone_iterator_next (zr->list_it); | 329 | GNUNET_NAMESTORE_zone_iterator_next (zr->list_it); |
@@ -354,8 +382,12 @@ serve_zoneinfo_page (struct MHD_Connection *connection) | |||
354 | zr->write_offset = 0; | 382 | zr->write_offset = 0; |
355 | zr->list_it = GNUNET_NAMESTORE_zone_iteration_start (ns, | 383 | zr->list_it = GNUNET_NAMESTORE_zone_iteration_start (ns, |
356 | &fcfs_zone_pkey, | 384 | &fcfs_zone_pkey, |
385 | &zone_iteration_error, | ||
386 | zr, | ||
357 | &iterate_cb, | 387 | &iterate_cb, |
358 | zr); | 388 | zr, |
389 | &zone_iteration_end, | ||
390 | zr); | ||
359 | return MHD_YES; | 391 | return MHD_YES; |
360 | } | 392 | } |
361 | 393 | ||
@@ -512,6 +544,21 @@ put_continuation (void *cls, | |||
512 | 544 | ||
513 | 545 | ||
514 | /** | 546 | /** |
547 | * Function called if we had an error in zone-to-name mapping. | ||
548 | */ | ||
549 | static void | ||
550 | zone_to_name_error (void *cls) | ||
551 | { | ||
552 | struct Request *request = cls; | ||
553 | |||
554 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
555 | _("Error when mapping zone to name\n")); | ||
556 | request->phase = RP_FAIL; | ||
557 | run_httpd_now (); | ||
558 | } | ||
559 | |||
560 | |||
561 | /** | ||
515 | * Test if a name mapping was found, if so, refuse. If not, initiate storing of the record. | 562 | * Test if a name mapping was found, if so, refuse. If not, initiate storing of the record. |
516 | * | 563 | * |
517 | * @param cls closure | 564 | * @param cls closure |
@@ -529,6 +576,7 @@ zone_to_name_cb (void *cls, | |||
529 | { | 576 | { |
530 | struct Request *request = cls; | 577 | struct Request *request = cls; |
531 | struct GNUNET_GNSRECORD_Data r; | 578 | struct GNUNET_GNSRECORD_Data r; |
579 | |||
532 | request->qe = NULL; | 580 | request->qe = NULL; |
533 | 581 | ||
534 | if (0 != rd_count) | 582 | if (0 != rd_count) |
@@ -540,15 +588,6 @@ zone_to_name_cb (void *cls, | |||
540 | run_httpd_now (); | 588 | run_httpd_now (); |
541 | return; | 589 | return; |
542 | } | 590 | } |
543 | if (NULL == zone_key) | ||
544 | { | ||
545 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
546 | _("Error when mapping zone to name\n")); | ||
547 | request->phase = RP_FAIL; | ||
548 | run_httpd_now (); | ||
549 | return; | ||
550 | } | ||
551 | |||
552 | r.data = &request->pub; | 591 | r.data = &request->pub; |
553 | r.data_size = sizeof (request->pub); | 592 | r.data_size = sizeof (request->pub); |
554 | r.expiration_time = UINT64_MAX; | 593 | r.expiration_time = UINT64_MAX; |
@@ -564,6 +603,20 @@ zone_to_name_cb (void *cls, | |||
564 | 603 | ||
565 | 604 | ||
566 | /** | 605 | /** |
606 | * We encountered an error in the name lookup. | ||
607 | */ | ||
608 | static void | ||
609 | lookup_block_error (void *cls) | ||
610 | { | ||
611 | struct Request *request = cls; | ||
612 | |||
613 | request->qe = NULL; | ||
614 | request->phase = RP_FAIL; | ||
615 | run_httpd_now (); | ||
616 | } | ||
617 | |||
618 | |||
619 | /** | ||
567 | * We got a block back from the namestore. Decrypt it | 620 | * We got a block back from the namestore. Decrypt it |
568 | * and continue to process the result. | 621 | * and continue to process the result. |
569 | * | 622 | * |
@@ -585,7 +638,6 @@ lookup_block_processor (void *cls, | |||
585 | request->qe = NULL; | 638 | request->qe = NULL; |
586 | if (0 == rd_count) | 639 | if (0 == rd_count) |
587 | { | 640 | { |
588 | |||
589 | if (GNUNET_OK != | 641 | if (GNUNET_OK != |
590 | GNUNET_CRYPTO_ecdsa_public_key_from_string (request->public_key, | 642 | GNUNET_CRYPTO_ecdsa_public_key_from_string (request->public_key, |
591 | strlen (request->public_key), | 643 | strlen (request->public_key), |
@@ -599,6 +651,8 @@ lookup_block_processor (void *cls, | |||
599 | request->qe = GNUNET_NAMESTORE_zone_to_name (ns, | 651 | request->qe = GNUNET_NAMESTORE_zone_to_name (ns, |
600 | &fcfs_zone_pkey, | 652 | &fcfs_zone_pkey, |
601 | &request->pub, | 653 | &request->pub, |
654 | &zone_to_name_error, | ||
655 | request, | ||
602 | &zone_to_name_cb, | 656 | &zone_to_name_cb, |
603 | request); | 657 | request); |
604 | return; | 658 | return; |
@@ -728,10 +782,12 @@ create_response (void *cls, | |||
728 | } | 782 | } |
729 | request->phase = RP_LOOKUP; | 783 | request->phase = RP_LOOKUP; |
730 | request->qe = GNUNET_NAMESTORE_records_lookup (ns, | 784 | request->qe = GNUNET_NAMESTORE_records_lookup (ns, |
731 | &fcfs_zone_pkey, | 785 | &fcfs_zone_pkey, |
732 | request->domain_name, | 786 | request->domain_name, |
733 | &lookup_block_processor, | 787 | &lookup_block_error, |
734 | request); | 788 | request, |
789 | &lookup_block_processor, | ||
790 | request); | ||
735 | break; | 791 | break; |
736 | case RP_LOOKUP: | 792 | case RP_LOOKUP: |
737 | break; | 793 | break; |
diff --git a/src/namestore/gnunet-namestore.c b/src/namestore/gnunet-namestore.c index 43cabed2a..7a671f1b6 100644 --- a/src/namestore/gnunet-namestore.c +++ b/src/namestore/gnunet-namestore.c | |||
@@ -343,6 +343,31 @@ del_continuation (void *cls, | |||
343 | 343 | ||
344 | 344 | ||
345 | /** | 345 | /** |
346 | * Function called when we are done with a zone iteration. | ||
347 | */ | ||
348 | static void | ||
349 | zone_iteration_finished (void *cls) | ||
350 | { | ||
351 | list_it = NULL; | ||
352 | test_finished (); | ||
353 | } | ||
354 | |||
355 | |||
356 | /** | ||
357 | * Function called when we encountered an error in a zone iteration. | ||
358 | */ | ||
359 | static void | ||
360 | zone_iteration_error_cb (void *cls) | ||
361 | { | ||
362 | list_it = NULL; | ||
363 | fprintf (stderr, | ||
364 | "Error iterating over zone\n"); | ||
365 | ret = 1; | ||
366 | test_finished (); | ||
367 | } | ||
368 | |||
369 | |||
370 | /** | ||
346 | * Process a record that was stored in the namestore. | 371 | * Process a record that was stored in the namestore. |
347 | * | 372 | * |
348 | * @param cls closure | 373 | * @param cls closure |
@@ -365,12 +390,6 @@ display_record (void *cls, | |||
365 | struct GNUNET_TIME_Absolute at; | 390 | struct GNUNET_TIME_Absolute at; |
366 | struct GNUNET_TIME_Relative rt; | 391 | struct GNUNET_TIME_Relative rt; |
367 | 392 | ||
368 | if (NULL == rname) | ||
369 | { | ||
370 | list_it = NULL; | ||
371 | test_finished (); | ||
372 | return; | ||
373 | } | ||
374 | if ( (NULL != name) && | 393 | if ( (NULL != name) && |
375 | (0 != strcmp (name, rname)) ) | 394 | (0 != strcmp (name, rname)) ) |
376 | { | 395 | { |
@@ -433,6 +452,31 @@ sync_cb (void *cls) | |||
433 | 452 | ||
434 | 453 | ||
435 | /** | 454 | /** |
455 | * Function called on errors while monitoring. | ||
456 | * | ||
457 | * @param cls NULL | ||
458 | */ | ||
459 | static void | ||
460 | monitor_error_cb (void *cls) | ||
461 | { | ||
462 | FPRINTF (stderr, "%s", "Monitor disconnected and out of sync.\n"); | ||
463 | } | ||
464 | |||
465 | |||
466 | /** | ||
467 | * Function called if lookup fails. | ||
468 | */ | ||
469 | static void | ||
470 | lookup_error_cb (void *cls) | ||
471 | { | ||
472 | add_qe = NULL; | ||
473 | GNUNET_break (0); | ||
474 | ret = 1; | ||
475 | test_finished (); | ||
476 | } | ||
477 | |||
478 | |||
479 | /** | ||
436 | * We're storing a record; this function is given the existing record | 480 | * We're storing a record; this function is given the existing record |
437 | * so that we can merge the information. | 481 | * so that we can merge the information. |
438 | * | 482 | * |
@@ -454,8 +498,7 @@ get_existing_record (void *cls, | |||
454 | unsigned int i; | 498 | unsigned int i; |
455 | 499 | ||
456 | add_qe = NULL; | 500 | add_qe = NULL; |
457 | if ( (NULL != zone_key) && | 501 | if (0 != strcmp (rec_name, name)) |
458 | (0 != strcmp (rec_name, name)) ) | ||
459 | { | 502 | { |
460 | GNUNET_break (0); | 503 | GNUNET_break (0); |
461 | ret = 1; | 504 | ret = 1; |
@@ -566,6 +609,19 @@ get_existing_record (void *cls, | |||
566 | 609 | ||
567 | 610 | ||
568 | /** | 611 | /** |
612 | * Function called if we encountered an error in zone-to-name. | ||
613 | */ | ||
614 | static void | ||
615 | reverse_error_cb (void *cls) | ||
616 | { | ||
617 | reverse_qe = NULL; | ||
618 | FPRINTF (stdout, | ||
619 | "%s.zkey\n", | ||
620 | reverse_pkey); | ||
621 | } | ||
622 | |||
623 | |||
624 | /** | ||
569 | * Function called with the result of our attempt to obtain a name for a given | 625 | * Function called with the result of our attempt to obtain a name for a given |
570 | * public key. | 626 | * public key. |
571 | * | 627 | * |
@@ -596,6 +652,19 @@ handle_reverse_lookup (void *cls, | |||
596 | 652 | ||
597 | 653 | ||
598 | /** | 654 | /** |
655 | * Function called if lookup for deletion fails. | ||
656 | */ | ||
657 | static void | ||
658 | del_lookup_error_cb (void *cls) | ||
659 | { | ||
660 | del_qe = NULL; | ||
661 | GNUNET_break (0); | ||
662 | ret = 1; | ||
663 | test_finished (); | ||
664 | } | ||
665 | |||
666 | |||
667 | /** | ||
599 | * We were asked to delete something; this function is called with | 668 | * We were asked to delete something; this function is called with |
600 | * the existing records. Now we should determine what should be | 669 | * the existing records. Now we should determine what should be |
601 | * deleted and then issue the deletion operation. | 670 | * deleted and then issue the deletion operation. |
@@ -802,8 +871,13 @@ testservice_task (void *cls, | |||
802 | ret = 1; | 871 | ret = 1; |
803 | return; | 872 | return; |
804 | } | 873 | } |
805 | add_qe = GNUNET_NAMESTORE_records_lookup (ns, &zone_pkey, name, | 874 | add_qe = GNUNET_NAMESTORE_records_lookup (ns, |
806 | &get_existing_record, NULL ); | 875 | &zone_pkey, |
876 | name, | ||
877 | &lookup_error_cb, | ||
878 | NULL, | ||
879 | &get_existing_record, | ||
880 | NULL); | ||
807 | } | 881 | } |
808 | if (del) | 882 | if (del) |
809 | { | 883 | { |
@@ -819,6 +893,8 @@ testservice_task (void *cls, | |||
819 | del_qe = GNUNET_NAMESTORE_records_lookup (ns, | 893 | del_qe = GNUNET_NAMESTORE_records_lookup (ns, |
820 | &zone_pkey, | 894 | &zone_pkey, |
821 | name, | 895 | name, |
896 | &del_lookup_error_cb, | ||
897 | NULL, | ||
822 | &del_monitor, | 898 | &del_monitor, |
823 | NULL); | 899 | NULL); |
824 | } | 900 | } |
@@ -826,7 +902,11 @@ testservice_task (void *cls, | |||
826 | { | 902 | { |
827 | list_it = GNUNET_NAMESTORE_zone_iteration_start (ns, | 903 | list_it = GNUNET_NAMESTORE_zone_iteration_start (ns, |
828 | &zone_pkey, | 904 | &zone_pkey, |
905 | &zone_iteration_error_cb, | ||
906 | NULL, | ||
829 | &display_record, | 907 | &display_record, |
908 | NULL, | ||
909 | &zone_iteration_finished, | ||
830 | NULL); | 910 | NULL); |
831 | } | 911 | } |
832 | if (NULL != reverse_pkey) | 912 | if (NULL != reverse_pkey) |
@@ -846,6 +926,8 @@ testservice_task (void *cls, | |||
846 | reverse_qe = GNUNET_NAMESTORE_zone_to_name (ns, | 926 | reverse_qe = GNUNET_NAMESTORE_zone_to_name (ns, |
847 | &zone_pkey, | 927 | &zone_pkey, |
848 | &pubkey, | 928 | &pubkey, |
929 | &reverse_error_cb, | ||
930 | NULL, | ||
849 | &handle_reverse_lookup, | 931 | &handle_reverse_lookup, |
850 | NULL); | 932 | NULL); |
851 | } | 933 | } |
@@ -860,7 +942,10 @@ testservice_task (void *cls, | |||
860 | "gnunet://gns/%52s/%63s", | 942 | "gnunet://gns/%52s/%63s", |
861 | sh, | 943 | sh, |
862 | sname)) ) || | 944 | sname)) ) || |
863 | (GNUNET_OK != GNUNET_CRYPTO_ecdsa_public_key_from_string (sh, strlen (sh), &pkey)) ) | 945 | (GNUNET_OK != |
946 | GNUNET_CRYPTO_ecdsa_public_key_from_string (sh, | ||
947 | strlen (sh), | ||
948 | &pkey)) ) | ||
864 | { | 949 | { |
865 | fprintf (stderr, | 950 | fprintf (stderr, |
866 | _("Invalid URI `%s'\n"), | 951 | _("Invalid URI `%s'\n"), |
@@ -912,7 +997,10 @@ testservice_task (void *cls, | |||
912 | zm = GNUNET_NAMESTORE_zone_monitor_start (cfg, | 997 | zm = GNUNET_NAMESTORE_zone_monitor_start (cfg, |
913 | &zone_pkey, | 998 | &zone_pkey, |
914 | GNUNET_YES, | 999 | GNUNET_YES, |
1000 | &monitor_error_cb, | ||
1001 | NULL, | ||
915 | &display_record, | 1002 | &display_record, |
1003 | NULL, | ||
916 | &sync_cb, | 1004 | &sync_cb, |
917 | NULL); | 1005 | NULL); |
918 | } | 1006 | } |
diff --git a/src/namestore/namestore_api.c b/src/namestore/namestore_api.c index b8da654ce..61d8385b6 100644 --- a/src/namestore/namestore_api.c +++ b/src/namestore/namestore_api.c | |||
@@ -84,6 +84,16 @@ struct GNUNET_NAMESTORE_QueueEntry | |||
84 | void *proc_cls; | 84 | void *proc_cls; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * Function to call on errors. | ||
88 | */ | ||
89 | GNUNET_SCHEDULER_TaskCallback error_cb; | ||
90 | |||
91 | /** | ||
92 | * Closure for @e error_cb. | ||
93 | */ | ||
94 | void *error_cb_cls; | ||
95 | |||
96 | /** | ||
87 | * Envelope of the message to send to the service, if not yet | 97 | * Envelope of the message to send to the service, if not yet |
88 | * sent. | 98 | * sent. |
89 | */ | 99 | */ |
@@ -119,6 +129,16 @@ struct GNUNET_NAMESTORE_ZoneIterator | |||
119 | struct GNUNET_NAMESTORE_Handle *h; | 129 | struct GNUNET_NAMESTORE_Handle *h; |
120 | 130 | ||
121 | /** | 131 | /** |
132 | * Function to call on completion. | ||
133 | */ | ||
134 | GNUNET_SCHEDULER_TaskCallback finish_cb; | ||
135 | |||
136 | /** | ||
137 | * Closure for @e error_cb. | ||
138 | */ | ||
139 | void *finish_cb_cls; | ||
140 | |||
141 | /** | ||
122 | * The continuation to call with the results | 142 | * The continuation to call with the results |
123 | */ | 143 | */ |
124 | GNUNET_NAMESTORE_RecordMonitor proc; | 144 | GNUNET_NAMESTORE_RecordMonitor proc; |
@@ -129,6 +149,16 @@ struct GNUNET_NAMESTORE_ZoneIterator | |||
129 | void *proc_cls; | 149 | void *proc_cls; |
130 | 150 | ||
131 | /** | 151 | /** |
152 | * Function to call on errors. | ||
153 | */ | ||
154 | GNUNET_SCHEDULER_TaskCallback error_cb; | ||
155 | |||
156 | /** | ||
157 | * Closure for @e error_cb. | ||
158 | */ | ||
159 | void *error_cb_cls; | ||
160 | |||
161 | /** | ||
132 | * Envelope of the message to send to the service, if not yet | 162 | * Envelope of the message to send to the service, if not yet |
133 | * sent. | 163 | * sent. |
134 | */ | 164 | */ |
@@ -543,9 +573,11 @@ handle_record_result (void *cls, | |||
543 | ntohl (msg->gns_header.r_id)); | 573 | ntohl (msg->gns_header.r_id)); |
544 | qe = find_qe (h, | 574 | qe = find_qe (h, |
545 | ntohl (msg->gns_header.r_id)); | 575 | ntohl (msg->gns_header.r_id)); |
546 | if ( (NULL == ze) && (NULL == qe) ) | 576 | if ( (NULL == ze) && |
577 | (NULL == qe) ) | ||
547 | return; /* rid not found */ | 578 | return; /* rid not found */ |
548 | if ( (NULL != ze) && (NULL != qe) ) | 579 | if ( (NULL != ze) && |
580 | (NULL != qe) ) | ||
549 | { | 581 | { |
550 | GNUNET_break (0); /* rid ambigous */ | 582 | GNUNET_break (0); /* rid ambigous */ |
551 | force_reconnect (h); | 583 | force_reconnect (h); |
@@ -564,8 +596,8 @@ handle_record_result (void *cls, | |||
564 | force_reconnect (h); | 596 | force_reconnect (h); |
565 | return; | 597 | return; |
566 | } | 598 | } |
567 | if (NULL != ze->proc) | 599 | if (NULL != ze->finish_cb) |
568 | ze->proc (ze->proc_cls, NULL, NULL, 0, NULL); | 600 | ze->finish_cb (ze->finish_cb_cls); |
569 | free_ze (ze); | 601 | free_ze (ze); |
570 | return; | 602 | return; |
571 | } | 603 | } |
@@ -706,7 +738,8 @@ handle_zone_to_name_response (void *cls, | |||
706 | qe->proc (qe->proc_cls, | 738 | qe->proc (qe->proc_cls, |
707 | &msg->zone, | 739 | &msg->zone, |
708 | name_tmp, | 740 | name_tmp, |
709 | rd_count, rd); | 741 | rd_count, |
742 | rd); | ||
710 | /* return is important here: break would call continuation with error! */ | 743 | /* return is important here: break would call continuation with error! */ |
711 | free_qe (qe); | 744 | free_qe (qe); |
712 | return; | 745 | return; |
@@ -717,8 +750,8 @@ handle_zone_to_name_response (void *cls, | |||
717 | return; | 750 | return; |
718 | } | 751 | } |
719 | /* error case, call continuation with error */ | 752 | /* error case, call continuation with error */ |
720 | if (NULL != qe->proc) | 753 | if (NULL != qe->error_cb) |
721 | qe->proc (qe->proc_cls, NULL, NULL, 0, NULL); | 754 | qe->error_cb (qe->error_cb_cls); |
722 | free_qe (qe); | 755 | free_qe (qe); |
723 | } | 756 | } |
724 | 757 | ||
@@ -826,18 +859,18 @@ force_reconnect (struct GNUNET_NAMESTORE_Handle *h) | |||
826 | h->mq = NULL; | 859 | h->mq = NULL; |
827 | while (NULL != (ze = h->z_head)) | 860 | while (NULL != (ze = h->z_head)) |
828 | { | 861 | { |
829 | /* FIXME: This does not allow clients to distinguish | 862 | if (NULL != ze->error_cb) |
830 | iteration error from successful termination! */ | 863 | ze->error_cb (ze->error_cb_cls); |
831 | if (NULL != ze->proc) | ||
832 | ze->proc (ze->proc_cls, NULL, NULL, 0, NULL); | ||
833 | free_ze (ze); | 864 | free_ze (ze); |
834 | } | 865 | } |
835 | while (NULL != (qe = h->op_head)) | 866 | while (NULL != (qe = h->op_head)) |
836 | { | 867 | { |
837 | /* FIXME: This does not allow clients to distinguish | 868 | if (NULL != qe->error_cb) |
838 | iteration error from successful termination! */ | 869 | qe->error_cb (qe->error_cb_cls); |
839 | if (NULL != qe->proc) | 870 | if (NULL != qe->cont) |
840 | qe->proc (qe->proc_cls, NULL, NULL, 0, NULL); | 871 | qe->cont (qe->cont_cls, |
872 | GNUNET_SYSERR, | ||
873 | "failure in communication with namestore service"); | ||
841 | free_qe (qe); | 874 | free_qe (qe); |
842 | } | 875 | } |
843 | 876 | ||
@@ -1058,6 +1091,8 @@ GNUNET_NAMESTORE_set_nick (struct GNUNET_NAMESTORE_Handle *h, | |||
1058 | * @param h handle to the namestore | 1091 | * @param h handle to the namestore |
1059 | * @param pkey private key of the zone | 1092 | * @param pkey private key of the zone |
1060 | * @param label name that is being mapped (at most 255 characters long) | 1093 | * @param label name that is being mapped (at most 255 characters long) |
1094 | * @param error_cb function to call on error (i.e. disconnect) | ||
1095 | * @param error_cb_cls closure for @a error_cb | ||
1061 | * @param rm function to call with the result (with 0 records if we don't have that label) | 1096 | * @param rm function to call with the result (with 0 records if we don't have that label) |
1062 | * @param rm_cls closure for @a rm | 1097 | * @param rm_cls closure for @a rm |
1063 | * @return handle to abort the request | 1098 | * @return handle to abort the request |
@@ -1066,6 +1101,8 @@ struct GNUNET_NAMESTORE_QueueEntry * | |||
1066 | GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, | 1101 | GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, |
1067 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, | 1102 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *pkey, |
1068 | const char *label, | 1103 | const char *label, |
1104 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
1105 | void *error_cb_cls, | ||
1069 | GNUNET_NAMESTORE_RecordMonitor rm, | 1106 | GNUNET_NAMESTORE_RecordMonitor rm, |
1070 | void *rm_cls) | 1107 | void *rm_cls) |
1071 | { | 1108 | { |
@@ -1082,6 +1119,8 @@ GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, | |||
1082 | 1119 | ||
1083 | qe = GNUNET_new (struct GNUNET_NAMESTORE_QueueEntry); | 1120 | qe = GNUNET_new (struct GNUNET_NAMESTORE_QueueEntry); |
1084 | qe->h = h; | 1121 | qe->h = h; |
1122 | qe->error_cb = error_cb; | ||
1123 | qe->error_cb_cls = error_cb_cls; | ||
1085 | qe->proc = rm; | 1124 | qe->proc = rm; |
1086 | qe->proc_cls = rm_cls; | 1125 | qe->proc_cls = rm_cls; |
1087 | qe->op_id = get_op_id(h); | 1126 | qe->op_id = get_op_id(h); |
@@ -1114,6 +1153,8 @@ GNUNET_NAMESTORE_records_lookup (struct GNUNET_NAMESTORE_Handle *h, | |||
1114 | * @param h handle to the namestore | 1153 | * @param h handle to the namestore |
1115 | * @param zone public key of the zone to look up in, never NULL | 1154 | * @param zone public key of the zone to look up in, never NULL |
1116 | * @param value_zone public key of the target zone (value), never NULL | 1155 | * @param value_zone public key of the target zone (value), never NULL |
1156 | * @param error_cb function to call on error (i.e. disconnect) | ||
1157 | * @param error_cb_cls closure for @a error_cb | ||
1117 | * @param proc function to call on the matching records, or with | 1158 | * @param proc function to call on the matching records, or with |
1118 | * NULL (rd_count == 0) if there are no matching records | 1159 | * NULL (rd_count == 0) if there are no matching records |
1119 | * @param proc_cls closure for @a proc | 1160 | * @param proc_cls closure for @a proc |
@@ -1124,6 +1165,8 @@ struct GNUNET_NAMESTORE_QueueEntry * | |||
1124 | GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, | 1165 | GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, |
1125 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 1166 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
1126 | const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, | 1167 | const struct GNUNET_CRYPTO_EcdsaPublicKey *value_zone, |
1168 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
1169 | void *error_cb_cls, | ||
1127 | GNUNET_NAMESTORE_RecordMonitor proc, | 1170 | GNUNET_NAMESTORE_RecordMonitor proc, |
1128 | void *proc_cls) | 1171 | void *proc_cls) |
1129 | { | 1172 | { |
@@ -1135,6 +1178,8 @@ GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, | |||
1135 | rid = get_op_id(h); | 1178 | rid = get_op_id(h); |
1136 | qe = GNUNET_new (struct GNUNET_NAMESTORE_QueueEntry); | 1179 | qe = GNUNET_new (struct GNUNET_NAMESTORE_QueueEntry); |
1137 | qe->h = h; | 1180 | qe->h = h; |
1181 | qe->error_cb = error_cb; | ||
1182 | qe->error_cb_cls = error_cb_cls; | ||
1138 | qe->proc = proc; | 1183 | qe->proc = proc; |
1139 | qe->proc_cls = proc_cls; | 1184 | qe->proc_cls = proc_cls; |
1140 | qe->op_id = rid; | 1185 | qe->op_id = rid; |
@@ -1166,26 +1211,39 @@ GNUNET_NAMESTORE_zone_to_name (struct GNUNET_NAMESTORE_Handle *h, | |||
1166 | * | 1211 | * |
1167 | * @param h handle to the namestore | 1212 | * @param h handle to the namestore |
1168 | * @param zone zone to access, NULL for all zones | 1213 | * @param zone zone to access, NULL for all zones |
1214 | * @param error_cb function to call on error (i.e. disconnect) | ||
1215 | * @param error_cb_cls closure for @a error_cb | ||
1169 | * @param proc function to call on each name from the zone; it | 1216 | * @param proc function to call on each name from the zone; it |
1170 | * will be called repeatedly with a value (if available) | 1217 | * will be called repeatedly with a value (if available) |
1171 | * and always once at the end with a name of NULL. | ||
1172 | * @param proc_cls closure for @a proc | 1218 | * @param proc_cls closure for @a proc |
1219 | * @param finish_cb function to call on completion | ||
1220 | * @param finish_cb_cls closure for @a finish_cb | ||
1173 | * @return an iterator handle to use for iteration | 1221 | * @return an iterator handle to use for iteration |
1174 | */ | 1222 | */ |
1175 | struct GNUNET_NAMESTORE_ZoneIterator * | 1223 | struct GNUNET_NAMESTORE_ZoneIterator * |
1176 | GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, | 1224 | GNUNET_NAMESTORE_zone_iteration_start (struct GNUNET_NAMESTORE_Handle *h, |
1177 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 1225 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
1226 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
1227 | void *error_cb_cls, | ||
1178 | GNUNET_NAMESTORE_RecordMonitor proc, | 1228 | GNUNET_NAMESTORE_RecordMonitor proc, |
1179 | void *proc_cls) | 1229 | void *proc_cls, |
1230 | GNUNET_SCHEDULER_TaskCallback finish_cb, | ||
1231 | void *finish_cb_cls) | ||
1180 | { | 1232 | { |
1181 | struct GNUNET_NAMESTORE_ZoneIterator *it; | 1233 | struct GNUNET_NAMESTORE_ZoneIterator *it; |
1182 | struct GNUNET_MQ_Envelope *env; | 1234 | struct GNUNET_MQ_Envelope *env; |
1183 | struct ZoneIterationStartMessage *msg; | 1235 | struct ZoneIterationStartMessage *msg; |
1184 | uint32_t rid; | 1236 | uint32_t rid; |
1185 | 1237 | ||
1238 | LOG (GNUNET_ERROR_TYPE_DEBUG, | ||
1239 | "Sending ZONE_ITERATION_START message\n"); | ||
1186 | rid = get_op_id (h); | 1240 | rid = get_op_id (h); |
1187 | it = GNUNET_new (struct GNUNET_NAMESTORE_ZoneIterator); | 1241 | it = GNUNET_new (struct GNUNET_NAMESTORE_ZoneIterator); |
1188 | it->h = h; | 1242 | it->h = h; |
1243 | it->error_cb = error_cb; | ||
1244 | it->error_cb_cls = error_cb_cls; | ||
1245 | it->finish_cb = finish_cb; | ||
1246 | it->finish_cb_cls = finish_cb_cls; | ||
1189 | it->proc = proc; | 1247 | it->proc = proc; |
1190 | it->proc_cls = proc_cls; | 1248 | it->proc_cls = proc_cls; |
1191 | it->op_id = rid; | 1249 | it->op_id = rid; |
diff --git a/src/namestore/namestore_api_monitor.c b/src/namestore/namestore_api_monitor.c index 85131f9cc..7e75b07e5 100644 --- a/src/namestore/namestore_api_monitor.c +++ b/src/namestore/namestore_api_monitor.c | |||
@@ -51,19 +51,34 @@ struct GNUNET_NAMESTORE_ZoneMonitor | |||
51 | struct GNUNET_MQ_Handle *mq; | 51 | struct GNUNET_MQ_Handle *mq; |
52 | 52 | ||
53 | /** | 53 | /** |
54 | * Function to call on errors. | ||
55 | */ | ||
56 | GNUNET_SCHEDULER_TaskCallback error_cb; | ||
57 | |||
58 | /** | ||
59 | * Closure for @e error_cb. | ||
60 | */ | ||
61 | void *error_cb_cls; | ||
62 | |||
63 | /** | ||
54 | * Function to call on events. | 64 | * Function to call on events. |
55 | */ | 65 | */ |
56 | GNUNET_NAMESTORE_RecordMonitor monitor; | 66 | GNUNET_NAMESTORE_RecordMonitor monitor; |
57 | 67 | ||
58 | /** | 68 | /** |
69 | * Closure for @e monitor. | ||
70 | */ | ||
71 | void *monitor_cls; | ||
72 | |||
73 | /** | ||
59 | * Function called when we've synchronized. | 74 | * Function called when we've synchronized. |
60 | */ | 75 | */ |
61 | GNUNET_NAMESTORE_RecordsSynchronizedCallback sync_cb; | 76 | GNUNET_SCHEDULER_TaskCallback sync_cb; |
62 | 77 | ||
63 | /** | 78 | /** |
64 | * Closure for @e monitor and @e sync_cb. | 79 | * Closure for @e sync_cb. |
65 | */ | 80 | */ |
66 | void *cls; | 81 | void *sync_cb_cls; |
67 | 82 | ||
68 | /** | 83 | /** |
69 | * Monitored zone. | 84 | * Monitored zone. |
@@ -100,7 +115,7 @@ handle_sync (void *cls, | |||
100 | struct GNUNET_NAMESTORE_ZoneMonitor *zm = cls; | 115 | struct GNUNET_NAMESTORE_ZoneMonitor *zm = cls; |
101 | 116 | ||
102 | if (NULL != zm->sync_cb) | 117 | if (NULL != zm->sync_cb) |
103 | zm->sync_cb (zm->cls); | 118 | zm->sync_cb (zm->sync_cb_cls); |
104 | } | 119 | } |
105 | 120 | ||
106 | 121 | ||
@@ -193,7 +208,7 @@ handle_result (void *cls, | |||
193 | rd_ser_tmp, | 208 | rd_ser_tmp, |
194 | rd_count, | 209 | rd_count, |
195 | rd)); | 210 | rd)); |
196 | zm->monitor (zm->cls, | 211 | zm->monitor (zm->monitor_cls, |
197 | &lrm->private_key, | 212 | &lrm->private_key, |
198 | name_tmp, | 213 | name_tmp, |
199 | rd_count, | 214 | rd_count, |
@@ -245,11 +260,7 @@ reconnect (struct GNUNET_NAMESTORE_ZoneMonitor *zm) | |||
245 | if (NULL != zm->mq) | 260 | if (NULL != zm->mq) |
246 | { | 261 | { |
247 | GNUNET_MQ_destroy (zm->mq); | 262 | GNUNET_MQ_destroy (zm->mq); |
248 | zm->monitor (zm->cls, | 263 | zm->error_cb (zm->error_cb_cls); |
249 | NULL, | ||
250 | NULL, | ||
251 | 0, | ||
252 | NULL); | ||
253 | } | 264 | } |
254 | zm->mq = GNUNET_CLIENT_connecT (zm->cfg, | 265 | zm->mq = GNUNET_CLIENT_connecT (zm->cfg, |
255 | "namestore", | 266 | "namestore", |
@@ -278,18 +289,28 @@ reconnect (struct GNUNET_NAMESTORE_ZoneMonitor *zm) | |||
278 | * @param zone zone to monitor | 289 | * @param zone zone to monitor |
279 | * @param iterate_first #GNUNET_YES to first iterate over all existing records, | 290 | * @param iterate_first #GNUNET_YES to first iterate over all existing records, |
280 | * #GNUNET_NO to only return changes that happen from now on | 291 | * #GNUNET_NO to only return changes that happen from now on |
292 | * @param error_cb function to call on error (i.e. disconnect); note that | ||
293 | * unlike the other error callbacks in this API, a call to this | ||
294 | * function does NOT destroy the monitor handle, it merely signals | ||
295 | * that monitoring is down. You need to still explicitly call | ||
296 | * #GNUNET_NAMESTORE_zone_monitor_stop(). | ||
297 | * @param error_cb_cls closure for @a error_cb | ||
281 | * @param monitor function to call on zone changes | 298 | * @param monitor function to call on zone changes |
299 | * @param monitor_cls closure for @a monitor | ||
282 | * @param sync_cb function called when we're in sync with the namestore | 300 | * @param sync_cb function called when we're in sync with the namestore |
283 | * @param cls closure for @a monitor and @a sync_cb | 301 | * @param cls closure for @a sync_cb |
284 | * @return handle to stop monitoring | 302 | * @return handle to stop monitoring |
285 | */ | 303 | */ |
286 | struct GNUNET_NAMESTORE_ZoneMonitor * | 304 | struct GNUNET_NAMESTORE_ZoneMonitor * |
287 | GNUNET_NAMESTORE_zone_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg, | 305 | GNUNET_NAMESTORE_zone_monitor_start (const struct GNUNET_CONFIGURATION_Handle *cfg, |
288 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 306 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
289 | int iterate_first, | 307 | int iterate_first, |
308 | GNUNET_SCHEDULER_TaskCallback error_cb, | ||
309 | void *error_cb_cls, | ||
290 | GNUNET_NAMESTORE_RecordMonitor monitor, | 310 | GNUNET_NAMESTORE_RecordMonitor monitor, |
291 | GNUNET_NAMESTORE_RecordsSynchronizedCallback sync_cb, | 311 | void *monitor_cls, |
292 | void *cls) | 312 | GNUNET_SCHEDULER_TaskCallback sync_cb, |
313 | void *sync_cb_cls) | ||
293 | { | 314 | { |
294 | struct GNUNET_NAMESTORE_ZoneMonitor *zm; | 315 | struct GNUNET_NAMESTORE_ZoneMonitor *zm; |
295 | 316 | ||
@@ -297,9 +318,12 @@ GNUNET_NAMESTORE_zone_monitor_start (const struct GNUNET_CONFIGURATION_Handle *c | |||
297 | if (NULL != zone) | 318 | if (NULL != zone) |
298 | zm->zone = *zone; | 319 | zm->zone = *zone; |
299 | zm->iterate_first = iterate_first; | 320 | zm->iterate_first = iterate_first; |
321 | zm->error_cb = error_cb; | ||
322 | zm->error_cb_cls = error_cb_cls; | ||
300 | zm->monitor = monitor; | 323 | zm->monitor = monitor; |
324 | zm->monitor_cls = monitor_cls; | ||
301 | zm->sync_cb = sync_cb; | 325 | zm->sync_cb = sync_cb; |
302 | zm->cls = cls; | 326 | zm->sync_cb_cls = sync_cb_cls; |
303 | zm->cfg = cfg; | 327 | zm->cfg = cfg; |
304 | reconnect (zm); | 328 | reconnect (zm); |
305 | if (NULL == zm->mq) | 329 | if (NULL == zm->mq) |
diff --git a/src/namestore/plugin_rest_namestore.c b/src/namestore/plugin_rest_namestore.c index 35d3595ce..58ab46ca9 100644 --- a/src/namestore/plugin_rest_namestore.c +++ b/src/namestore/plugin_rest_namestore.c | |||
@@ -388,6 +388,38 @@ cleanup_handle_delayed (void *cls) | |||
388 | 388 | ||
389 | 389 | ||
390 | /** | 390 | /** |
391 | * Iteration over all results finished, build final | ||
392 | * response. | ||
393 | * | ||
394 | * @param cls the `struct RequestHandle` | ||
395 | */ | ||
396 | static void | ||
397 | namestore_list_finished (void *cls) | ||
398 | { | ||
399 | struct RequestHandle *handle = cls; | ||
400 | char *result; | ||
401 | struct MHD_Response *resp; | ||
402 | |||
403 | handle->list_it = NULL; | ||
404 | if (GNUNET_SYSERR == | ||
405 | GNUNET_JSONAPI_document_serialize (handle->resp_object, | ||
406 | &result)) | ||
407 | { | ||
408 | do_error (handle); | ||
409 | return; | ||
410 | } | ||
411 | resp = GNUNET_REST_create_response (result); | ||
412 | handle->proc (handle->proc_cls, | ||
413 | resp, | ||
414 | MHD_HTTP_OK); | ||
415 | GNUNET_free_non_null (result); | ||
416 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, | ||
417 | handle); | ||
418 | } | ||
419 | |||
420 | |||
421 | |||
422 | /** | ||
391 | * Create a response with requested records | 423 | * Create a response with requested records |
392 | * | 424 | * |
393 | * @param handle the RequestHandle | 425 | * @param handle the RequestHandle |
@@ -401,31 +433,13 @@ namestore_list_response (void *cls, | |||
401 | { | 433 | { |
402 | struct RequestHandle *handle = cls; | 434 | struct RequestHandle *handle = cls; |
403 | struct GNUNET_JSONAPI_Resource *json_resource; | 435 | struct GNUNET_JSONAPI_Resource *json_resource; |
404 | struct MHD_Response *resp; | ||
405 | json_t *result_array; | 436 | json_t *result_array; |
406 | json_t *record_obj; | 437 | json_t *record_obj; |
407 | int i; | 438 | int i; |
408 | char *result; | ||
409 | 439 | ||
410 | if (NULL == handle->resp_object) | 440 | if (NULL == handle->resp_object) |
411 | handle->resp_object = GNUNET_JSONAPI_document_new (); | 441 | handle->resp_object = GNUNET_JSONAPI_document_new (); |
412 | 442 | ||
413 | if (NULL == rname) | ||
414 | { | ||
415 | handle->list_it = NULL; | ||
416 | //Handle response | ||
417 | if (GNUNET_SYSERR == GNUNET_JSONAPI_document_serialize (handle->resp_object, &result)) | ||
418 | { | ||
419 | GNUNET_SCHEDULER_add_now (&do_error, handle); | ||
420 | return; | ||
421 | } | ||
422 | resp = GNUNET_REST_create_response (result); | ||
423 | handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); | ||
424 | GNUNET_free_non_null (result); | ||
425 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | ||
426 | return; | ||
427 | } | ||
428 | |||
429 | if ( (NULL != handle->name) && | 443 | if ( (NULL != handle->name) && |
430 | (0 != strcmp (handle->name, rname)) ) | 444 | (0 != strcmp (handle->name, rname)) ) |
431 | { | 445 | { |
@@ -464,6 +478,7 @@ namestore_list_response (void *cls, | |||
464 | GNUNET_NAMESTORE_zone_iterator_next (handle->list_it); | 478 | GNUNET_NAMESTORE_zone_iterator_next (handle->list_it); |
465 | } | 479 | } |
466 | 480 | ||
481 | |||
467 | static void | 482 | static void |
468 | create_finished (void *cls, int32_t success, const char *emsg) | 483 | create_finished (void *cls, int32_t success, const char *emsg) |
469 | { | 484 | { |
@@ -506,11 +521,10 @@ create_new_record_cont (void *cls, | |||
506 | struct RequestHandle *handle = cls; | 521 | struct RequestHandle *handle = cls; |
507 | 522 | ||
508 | handle->add_qe = NULL; | 523 | handle->add_qe = NULL; |
509 | if ( (NULL != zone_key) && | 524 | if (0 != strcmp (rec_name, handle->name)) |
510 | (0 != strcmp (rec_name, handle->name)) ) | ||
511 | { | 525 | { |
512 | GNUNET_break (0); | 526 | GNUNET_break (0); |
513 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 527 | do_error (handle); |
514 | return; | 528 | return; |
515 | } | 529 | } |
516 | 530 | ||
@@ -533,6 +547,7 @@ create_new_record_cont (void *cls, | |||
533 | handle); | 547 | handle); |
534 | } | 548 | } |
535 | 549 | ||
550 | |||
536 | static void | 551 | static void |
537 | del_finished (void *cls, | 552 | del_finished (void *cls, |
538 | int32_t success, | 553 | int32_t success, |
@@ -565,6 +580,7 @@ del_finished (void *cls, | |||
565 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 580 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); |
566 | } | 581 | } |
567 | 582 | ||
583 | |||
568 | static void | 584 | static void |
569 | del_cont (void *cls, | 585 | del_cont (void *cls, |
570 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 586 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
@@ -573,13 +589,14 @@ del_cont (void *cls, | |||
573 | const struct GNUNET_GNSRECORD_Data *rd) | 589 | const struct GNUNET_GNSRECORD_Data *rd) |
574 | { | 590 | { |
575 | struct RequestHandle *handle = cls; | 591 | struct RequestHandle *handle = cls; |
592 | |||
576 | handle->add_qe = NULL; | 593 | handle->add_qe = NULL; |
577 | if (0 == rd_count) | 594 | if (0 == rd_count) |
578 | { | 595 | { |
579 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 596 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
580 | _("There are no records under label `%s' that could be deleted.\n"), | 597 | _("There are no records under label `%s' that could be deleted.\n"), |
581 | label); | 598 | label); |
582 | GNUNET_SCHEDULER_add_now (&do_error, handle); | 599 | do_error (handle); |
583 | return; | 600 | return; |
584 | } | 601 | } |
585 | 602 | ||
@@ -591,6 +608,7 @@ del_cont (void *cls, | |||
591 | handle); | 608 | handle); |
592 | } | 609 | } |
593 | 610 | ||
611 | |||
594 | static void | 612 | static void |
595 | namestore_delete_cont (struct GNUNET_REST_RequestHandle *con, | 613 | namestore_delete_cont (struct GNUNET_REST_RequestHandle *con, |
596 | const char *url, | 614 | const char *url, |
@@ -607,10 +625,13 @@ namestore_delete_cont (struct GNUNET_REST_RequestHandle *con, | |||
607 | handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle, | 625 | handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle, |
608 | &handle->zone_pkey, | 626 | &handle->zone_pkey, |
609 | handle->name, | 627 | handle->name, |
628 | &do_error, | ||
629 | handle, | ||
610 | &del_cont, | 630 | &del_cont, |
611 | handle); | 631 | handle); |
612 | } | 632 | } |
613 | 633 | ||
634 | |||
614 | static int | 635 | static int |
615 | json_to_gnsrecord (const json_t *records_json, | 636 | json_to_gnsrecord (const json_t *records_json, |
616 | struct GNUNET_GNSRECORD_Data **rd, | 637 | struct GNUNET_GNSRECORD_Data **rd, |
@@ -713,6 +734,7 @@ json_to_gnsrecord (const json_t *records_json, | |||
713 | return GNUNET_OK; | 734 | return GNUNET_OK; |
714 | } | 735 | } |
715 | 736 | ||
737 | |||
716 | static void | 738 | static void |
717 | namestore_create_cont (struct GNUNET_REST_RequestHandle *con, | 739 | namestore_create_cont (struct GNUNET_REST_RequestHandle *con, |
718 | const char *url, | 740 | const char *url, |
@@ -730,7 +752,7 @@ namestore_create_cont (struct GNUNET_REST_RequestHandle *con, | |||
730 | GNUNET_JSON_spec_jsonapi_document (&json_obj), | 752 | GNUNET_JSON_spec_jsonapi_document (&json_obj), |
731 | GNUNET_JSON_spec_end() | 753 | GNUNET_JSON_spec_end() |
732 | }; | 754 | }; |
733 | 755 | ||
734 | if (strlen (GNUNET_REST_API_NS_NAMESTORE) != strlen (handle->url)) | 756 | if (strlen (GNUNET_REST_API_NS_NAMESTORE) != strlen (handle->url)) |
735 | { | 757 | { |
736 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 758 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -805,9 +827,13 @@ namestore_create_cont (struct GNUNET_REST_RequestHandle *con, | |||
805 | handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle, | 827 | handle->add_qe = GNUNET_NAMESTORE_records_lookup (handle->ns_handle, |
806 | &handle->zone_pkey, | 828 | &handle->zone_pkey, |
807 | handle->name, | 829 | handle->name, |
808 | &create_new_record_cont, handle ); | 830 | &do_error, |
831 | handle, | ||
832 | &create_new_record_cont, | ||
833 | handle); | ||
809 | } | 834 | } |
810 | 835 | ||
836 | |||
811 | static void | 837 | static void |
812 | namestore_zkey_response (void *cls, | 838 | namestore_zkey_response (void *cls, |
813 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 839 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
@@ -847,10 +873,9 @@ namestore_zkey_response (void *cls, | |||
847 | GNUNET_JSONAPI_document_delete (json_obj); | 873 | GNUNET_JSONAPI_document_delete (json_obj); |
848 | GNUNET_free (result); | 874 | GNUNET_free (result); |
849 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); | 875 | GNUNET_SCHEDULER_add_now (&cleanup_handle_delayed, handle); |
850 | return; | ||
851 | |||
852 | } | 876 | } |
853 | 877 | ||
878 | |||
854 | static void | 879 | static void |
855 | namestore_zkey_cont (struct GNUNET_REST_RequestHandle *con, | 880 | namestore_zkey_cont (struct GNUNET_REST_RequestHandle *con, |
856 | const char *url, | 881 | const char *url, |
@@ -887,22 +912,31 @@ namestore_zkey_cont (struct GNUNET_REST_RequestHandle *con, | |||
887 | handle->reverse_qe = GNUNET_NAMESTORE_zone_to_name (handle->ns_handle, | 912 | handle->reverse_qe = GNUNET_NAMESTORE_zone_to_name (handle->ns_handle, |
888 | &handle->zone_pkey, | 913 | &handle->zone_pkey, |
889 | &pubkey, | 914 | &pubkey, |
915 | &do_error, | ||
916 | handle, | ||
890 | &namestore_zkey_response, | 917 | &namestore_zkey_response, |
891 | handle); | 918 | handle); |
892 | } | 919 | } |
893 | 920 | ||
921 | |||
894 | static void | 922 | static void |
895 | namestore_info_cont (struct GNUNET_REST_RequestHandle *con, | 923 | namestore_info_cont (struct GNUNET_REST_RequestHandle *con, |
896 | const char *url, | 924 | const char *url, |
897 | void *cls) | 925 | void *cls) |
898 | { | 926 | { |
899 | struct RequestHandle *handle = cls; | 927 | struct RequestHandle *handle = cls; |
928 | |||
900 | handle->list_it = GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle, | 929 | handle->list_it = GNUNET_NAMESTORE_zone_iteration_start (handle->ns_handle, |
901 | &handle->zone_pkey, | 930 | &handle->zone_pkey, |
931 | &do_error, | ||
932 | handle, | ||
902 | &namestore_list_response, | 933 | &namestore_list_response, |
934 | handle, | ||
935 | &namestore_list_finished, | ||
903 | handle); | 936 | handle); |
904 | } | 937 | } |
905 | 938 | ||
939 | |||
906 | static char* | 940 | static char* |
907 | get_name_from_url (const char* url) | 941 | get_name_from_url (const char* url) |
908 | { | 942 | { |
diff --git a/src/namestore/test_namestore_api.conf b/src/namestore/test_namestore_api.conf index 5db120ea7..a1a674d89 100644 --- a/src/namestore/test_namestore_api.conf +++ b/src/namestore/test_namestore_api.conf | |||
@@ -13,3 +13,6 @@ TEMPORARY_TABLE = YES | |||
13 | 13 | ||
14 | [nse] | 14 | [nse] |
15 | WORKBITS = 0 | 15 | WORKBITS = 0 |
16 | |||
17 | [transport] | ||
18 | PLUGINS = | ||
diff --git a/src/namestore/test_namestore_api_lookup_nick.c b/src/namestore/test_namestore_api_lookup_nick.c index d6d3945b7..de958cee2 100644 --- a/src/namestore/test_namestore_api_lookup_nick.c +++ b/src/namestore/test_namestore_api_lookup_nick.c | |||
@@ -222,6 +222,13 @@ lookup_it (void *cls, | |||
222 | 222 | ||
223 | 223 | ||
224 | static void | 224 | static void |
225 | fail_cb (void *cls) | ||
226 | { | ||
227 | GNUNET_assert (0); | ||
228 | } | ||
229 | |||
230 | |||
231 | static void | ||
225 | put_cont (void *cls, int32_t success, const char *emsg) | 232 | put_cont (void *cls, int32_t success, const char *emsg) |
226 | { | 233 | { |
227 | const char *name = cls; | 234 | const char *name = cls; |
@@ -240,9 +247,16 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
240 | return; | 247 | return; |
241 | } | 248 | } |
242 | /* Lookup */ | 249 | /* Lookup */ |
243 | nsqe = GNUNET_NAMESTORE_records_lookup (nsh, privkey, name, lookup_it, NULL); | 250 | nsqe = GNUNET_NAMESTORE_records_lookup (nsh, |
251 | privkey, | ||
252 | name, | ||
253 | &fail_cb, | ||
254 | NULL, | ||
255 | &lookup_it, | ||
256 | NULL); | ||
244 | } | 257 | } |
245 | 258 | ||
259 | |||
246 | static void | 260 | static void |
247 | nick_cont (void *cls, int32_t success, const char *emsg) | 261 | nick_cont (void *cls, int32_t success, const char *emsg) |
248 | { | 262 | { |
diff --git a/src/namestore/test_namestore_api_lookup_private.c b/src/namestore/test_namestore_api_lookup_private.c index 92b2cad6f..57505c48b 100644 --- a/src/namestore/test_namestore_api_lookup_private.c +++ b/src/namestore/test_namestore_api_lookup_private.c | |||
@@ -103,7 +103,9 @@ lookup_it (void *cls, | |||
103 | { | 103 | { |
104 | nsqe = NULL; | 104 | nsqe = NULL; |
105 | 105 | ||
106 | if (0 != memcmp(privkey, zone, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) | 106 | if (0 != memcmp (privkey, |
107 | zone, | ||
108 | sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) | ||
107 | { | 109 | { |
108 | GNUNET_break(0); | 110 | GNUNET_break(0); |
109 | GNUNET_SCHEDULER_cancel (endbadly_task); | 111 | GNUNET_SCHEDULER_cancel (endbadly_task); |
@@ -144,6 +146,13 @@ lookup_it (void *cls, | |||
144 | 146 | ||
145 | 147 | ||
146 | static void | 148 | static void |
149 | fail_cb (void *cls) | ||
150 | { | ||
151 | GNUNET_assert (0); | ||
152 | } | ||
153 | |||
154 | |||
155 | static void | ||
147 | put_cont (void *cls, int32_t success, const char *emsg) | 156 | put_cont (void *cls, int32_t success, const char *emsg) |
148 | { | 157 | { |
149 | const char *name = cls; | 158 | const char *name = cls; |
@@ -162,7 +171,13 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
162 | return; | 171 | return; |
163 | } | 172 | } |
164 | /* Lookup */ | 173 | /* Lookup */ |
165 | nsqe = GNUNET_NAMESTORE_records_lookup (nsh, privkey, name, lookup_it, NULL); | 174 | nsqe = GNUNET_NAMESTORE_records_lookup (nsh, |
175 | privkey, | ||
176 | name, | ||
177 | &fail_cb, | ||
178 | NULL, | ||
179 | &lookup_it, | ||
180 | NULL); | ||
166 | } | 181 | } |
167 | 182 | ||
168 | 183 | ||
diff --git a/src/namestore/test_namestore_api_monitoring.c b/src/namestore/test_namestore_api_monitoring.c index 2ea271d50..efbd6badf 100644 --- a/src/namestore/test_namestore_api_monitoring.c +++ b/src/namestore/test_namestore_api_monitoring.c | |||
@@ -215,11 +215,11 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
215 | char *label = cls; | 215 | char *label = cls; |
216 | 216 | ||
217 | if (0 == strcmp (label, s_name_1)) | 217 | if (0 == strcmp (label, s_name_1)) |
218 | ns_ops[0] = NULL; | 218 | ns_ops[0] = NULL; |
219 | else if (0 == strcmp (label, s_name_2)) | 219 | else if (0 == strcmp (label, s_name_2)) |
220 | ns_ops[1] = NULL; | 220 | ns_ops[1] = NULL; |
221 | else if (0 == strcmp (label, s_name_3)) | 221 | else if (0 == strcmp (label, s_name_3)) |
222 | ns_ops[2] = NULL; | 222 | ns_ops[2] = NULL; |
223 | 223 | ||
224 | if (success == GNUNET_OK) | 224 | if (success == GNUNET_OK) |
225 | { | 225 | { |
@@ -261,6 +261,20 @@ create_record (unsigned int count) | |||
261 | 261 | ||
262 | 262 | ||
263 | static void | 263 | static void |
264 | fail_cb (void *cls) | ||
265 | { | ||
266 | GNUNET_assert (0); | ||
267 | } | ||
268 | |||
269 | |||
270 | static void | ||
271 | sync_cb (void *cls) | ||
272 | { | ||
273 | /* do nothing */ | ||
274 | } | ||
275 | |||
276 | |||
277 | static void | ||
264 | run (void *cls, | 278 | run (void *cls, |
265 | const struct GNUNET_CONFIGURATION_Handle *cfg, | 279 | const struct GNUNET_CONFIGURATION_Handle *cfg, |
266 | struct GNUNET_TESTING_Peer *peer) | 280 | struct GNUNET_TESTING_Peer *peer) |
@@ -288,8 +302,11 @@ run (void *cls, | |||
288 | zm = GNUNET_NAMESTORE_zone_monitor_start (cfg, | 302 | zm = GNUNET_NAMESTORE_zone_monitor_start (cfg, |
289 | privkey, | 303 | privkey, |
290 | GNUNET_YES, | 304 | GNUNET_YES, |
305 | &fail_cb, | ||
306 | NULL, | ||
291 | &zone_proc, | 307 | &zone_proc, |
292 | NULL, | 308 | NULL, |
309 | &sync_cb, | ||
293 | NULL); | 310 | NULL); |
294 | if (NULL == zm) | 311 | if (NULL == zm) |
295 | { | 312 | { |
diff --git a/src/namestore/test_namestore_api_monitoring_existing.c b/src/namestore/test_namestore_api_monitoring_existing.c index eae10e2ae..cd1838b5c 100644 --- a/src/namestore/test_namestore_api_monitoring_existing.c +++ b/src/namestore/test_namestore_api_monitoring_existing.c | |||
@@ -59,6 +59,7 @@ struct GNUNET_NAMESTORE_QueueEntry * ns_ops[3]; | |||
59 | 59 | ||
60 | static char *directory; | 60 | static char *directory; |
61 | 61 | ||
62 | |||
62 | static void | 63 | static void |
63 | do_shutdown () | 64 | do_shutdown () |
64 | { | 65 | { |
@@ -204,7 +205,20 @@ zone_proc (void *cls, | |||
204 | else | 205 | else |
205 | GNUNET_SCHEDULER_add_now (&end, NULL); | 206 | GNUNET_SCHEDULER_add_now (&end, NULL); |
206 | } | 207 | } |
208 | } | ||
209 | |||
207 | 210 | ||
211 | static void | ||
212 | fail_cb (void *cls) | ||
213 | { | ||
214 | GNUNET_assert (0); | ||
215 | } | ||
216 | |||
217 | |||
218 | static void | ||
219 | sync_cb (void *cls) | ||
220 | { | ||
221 | /* do nothing */ | ||
208 | } | 222 | } |
209 | 223 | ||
210 | 224 | ||
@@ -240,8 +254,11 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
240 | zm = GNUNET_NAMESTORE_zone_monitor_start (cfg, | 254 | zm = GNUNET_NAMESTORE_zone_monitor_start (cfg, |
241 | privkey, | 255 | privkey, |
242 | GNUNET_YES, | 256 | GNUNET_YES, |
257 | &fail_cb, | ||
258 | NULL, | ||
243 | &zone_proc, | 259 | &zone_proc, |
244 | NULL, | 260 | NULL, |
261 | &sync_cb, | ||
245 | NULL); | 262 | NULL); |
246 | if (NULL == zm) | 263 | if (NULL == zm) |
247 | { | 264 | { |
diff --git a/src/namestore/test_namestore_api_zone_iteration.c b/src/namestore/test_namestore_api_zone_iteration.c index 070c06870..8960be55d 100644 --- a/src/namestore/test_namestore_api_zone_iteration.c +++ b/src/namestore/test_namestore_api_zone_iteration.c | |||
@@ -156,6 +156,32 @@ end (void *cls) | |||
156 | 156 | ||
157 | 157 | ||
158 | static void | 158 | static void |
159 | zone_end (void *cls) | ||
160 | { | ||
161 | GNUNET_break (3 == returned_records); | ||
162 | if (3 == returned_records) | ||
163 | { | ||
164 | res = 0; /* Last iteraterator callback, we are done */ | ||
165 | zi = NULL; | ||
166 | } | ||
167 | else | ||
168 | res = 1; | ||
169 | |||
170 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
171 | "Received last result, iteration done after receing %u results\n", | ||
172 | returned_records); | ||
173 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
174 | } | ||
175 | |||
176 | |||
177 | static void | ||
178 | fail_cb (void *cls) | ||
179 | { | ||
180 | GNUNET_assert (0); | ||
181 | } | ||
182 | |||
183 | |||
184 | static void | ||
159 | zone_proc (void *cls, | 185 | zone_proc (void *cls, |
160 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 186 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
161 | const char *label, | 187 | const char *label, |
@@ -164,23 +190,6 @@ zone_proc (void *cls, | |||
164 | { | 190 | { |
165 | int failed = GNUNET_NO; | 191 | int failed = GNUNET_NO; |
166 | 192 | ||
167 | if ((zone == NULL) && (label == NULL)) | ||
168 | { | ||
169 | GNUNET_break (3 == returned_records); | ||
170 | if (3 == returned_records) | ||
171 | { | ||
172 | res = 0; /* Last iteraterator callback, we are done */ | ||
173 | zi = NULL; | ||
174 | } | ||
175 | else | ||
176 | res = 1; | ||
177 | |||
178 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
179 | "Received last result, iteration done after receing %u results\n", | ||
180 | returned_records); | ||
181 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
182 | return; | ||
183 | } | ||
184 | GNUNET_assert (NULL != zone); | 193 | GNUNET_assert (NULL != zone); |
185 | if (0 == memcmp (zone, privkey, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) | 194 | if (0 == memcmp (zone, privkey, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) |
186 | { | 195 | { |
@@ -305,7 +314,11 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
305 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n"); | 314 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n"); |
306 | zi = GNUNET_NAMESTORE_zone_iteration_start (nsh, | 315 | zi = GNUNET_NAMESTORE_zone_iteration_start (nsh, |
307 | NULL, | 316 | NULL, |
317 | &fail_cb, | ||
318 | NULL, | ||
308 | &zone_proc, | 319 | &zone_proc, |
320 | NULL, | ||
321 | &zone_end, | ||
309 | NULL); | 322 | NULL); |
310 | if (zi == NULL) | 323 | if (zi == NULL) |
311 | { | 324 | { |
@@ -352,8 +365,6 @@ empty_zone_proc (void *cls, | |||
352 | unsigned int rd_count, | 365 | unsigned int rd_count, |
353 | const struct GNUNET_GNSRECORD_Data *rd) | 366 | const struct GNUNET_GNSRECORD_Data *rd) |
354 | { | 367 | { |
355 | char *hostkey_file; | ||
356 | |||
357 | GNUNET_assert (nsh == cls); | 368 | GNUNET_assert (nsh == cls); |
358 | if (NULL != zone) | 369 | if (NULL != zone) |
359 | { | 370 | { |
@@ -375,18 +386,31 @@ empty_zone_proc (void *cls, | |||
375 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 386 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
376 | return; | 387 | return; |
377 | } | 388 | } |
389 | GNUNET_assert (0); | ||
390 | } | ||
378 | 391 | ||
379 | 392 | ||
393 | static void | ||
394 | empty_zone_end (void *cls) | ||
395 | { | ||
396 | char *hostkey_file; | ||
397 | |||
380 | zi = NULL; | 398 | zi = NULL; |
381 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 399 | GNUNET_asprintf (&hostkey_file, |
382 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 400 | "zonefiles%s%s", |
383 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 401 | DIR_SEPARATOR_STR, |
402 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | ||
403 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
404 | "Using zonekey file `%s' \n", | ||
405 | hostkey_file); | ||
384 | privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); | 406 | privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); |
385 | GNUNET_free (hostkey_file); | 407 | GNUNET_free (hostkey_file); |
386 | GNUNET_assert (privkey != NULL); | 408 | GNUNET_assert (privkey != NULL); |
387 | 409 | ||
388 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 410 | GNUNET_asprintf (&hostkey_file, |
389 | "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"); | 411 | "zonefiles%s%s", |
412 | DIR_SEPARATOR_STR, | ||
413 | "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"); | ||
390 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 414 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); |
391 | privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); | 415 | privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); |
392 | GNUNET_free (hostkey_file); | 416 | GNUNET_free (hostkey_file); |
@@ -396,7 +420,9 @@ empty_zone_proc (void *cls, | |||
396 | 420 | ||
397 | GNUNET_asprintf(&s_name_1, "dummy1"); | 421 | GNUNET_asprintf(&s_name_1, "dummy1"); |
398 | s_rd_1 = create_record(1); | 422 | s_rd_1 = create_record(1); |
399 | GNUNET_NAMESTORE_records_store (nsh, privkey, s_name_1, | 423 | GNUNET_NAMESTORE_records_store (nsh, |
424 | privkey, | ||
425 | s_name_1, | ||
400 | 1, s_rd_1, | 426 | 1, s_rd_1, |
401 | &put_cont, NULL); | 427 | &put_cont, NULL); |
402 | 428 | ||
@@ -404,8 +430,12 @@ empty_zone_proc (void *cls, | |||
404 | "Created record 2 \n"); | 430 | "Created record 2 \n"); |
405 | GNUNET_asprintf(&s_name_2, "dummy2"); | 431 | GNUNET_asprintf(&s_name_2, "dummy2"); |
406 | s_rd_2 = create_record(1); | 432 | s_rd_2 = create_record(1); |
407 | GNUNET_NAMESTORE_records_store (nsh, privkey, s_name_2, | 433 | GNUNET_NAMESTORE_records_store (nsh, |
408 | 1, s_rd_2, &put_cont, NULL); | 434 | privkey, |
435 | s_name_2, | ||
436 | 1, s_rd_2, | ||
437 | &put_cont, | ||
438 | NULL); | ||
409 | 439 | ||
410 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 440 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
411 | "Created record 3\n"); | 441 | "Created record 3\n"); |
@@ -436,7 +466,13 @@ run (void *cls, | |||
436 | GNUNET_break (NULL != nsh); | 466 | GNUNET_break (NULL != nsh); |
437 | /* first, iterate over empty namestore */ | 467 | /* first, iterate over empty namestore */ |
438 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, | 468 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, |
439 | NULL, &empty_zone_proc, nsh); | 469 | NULL, |
470 | &fail_cb, | ||
471 | NULL, | ||
472 | &empty_zone_proc, | ||
473 | nsh, | ||
474 | &empty_zone_end, | ||
475 | NULL); | ||
440 | if (NULL == zi) | 476 | if (NULL == zi) |
441 | { | 477 | { |
442 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); | 478 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); |
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 | ||
201 | static void | 201 | static void |
202 | zone_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 | |||
213 | static void | ||
202 | zone_proc (void *cls, | 214 | zone_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 | ||
256 | static void | 259 | static void |
260 | fail_cb (void *cls) | ||
261 | { | ||
262 | GNUNET_assert (0); | ||
263 | } | ||
264 | |||
265 | |||
266 | static void | ||
257 | put_cont (void *cls, int32_t success, const char *emsg) | 267 | put_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 | |||
421 | static void | ||
422 | empty_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, |
diff --git a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c index 1a0279f50..c5ae927b0 100644 --- a/src/namestore/test_namestore_api_zone_iteration_specific_zone.c +++ b/src/namestore/test_namestore_api_zone_iteration_specific_zone.c | |||
@@ -156,30 +156,21 @@ end (void *cls) | |||
156 | 156 | ||
157 | 157 | ||
158 | static void | 158 | static void |
159 | fail_cb (void *cls) | ||
160 | { | ||
161 | GNUNET_assert (0); | ||
162 | } | ||
163 | |||
164 | |||
165 | static void | ||
159 | zone_proc (void *cls, | 166 | zone_proc (void *cls, |
160 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 167 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
161 | const char *label, | 168 | const char *label, |
162 | unsigned int rd_count, | 169 | unsigned int rd_count, |
163 | const struct GNUNET_GNSRECORD_Data *rd) | 170 | const struct GNUNET_GNSRECORD_Data *rd) |
164 | { | 171 | { |
165 | int failed = GNUNET_NO; | 172 | int failed = GNUNET_NO; |
166 | if ((zone == NULL) && (label == NULL)) | ||
167 | { | ||
168 | GNUNET_break (2 == returned_records); | ||
169 | if (2 == returned_records) | ||
170 | { | ||
171 | res = 0; /* Last iteraterator callback, we are done */ | ||
172 | zi = NULL; | ||
173 | } | ||
174 | else | ||
175 | res = 1; | ||
176 | 173 | ||
177 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
178 | "Received last result, iteration done after receing %u results\n", | ||
179 | returned_records ); | ||
180 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
181 | return; | ||
182 | } | ||
183 | GNUNET_assert (NULL != zone); | 174 | GNUNET_assert (NULL != zone); |
184 | if (0 == memcmp (zone, | 175 | if (0 == memcmp (zone, |
185 | privkey, | 176 | privkey, |
@@ -258,6 +249,25 @@ zone_proc (void *cls, | |||
258 | 249 | ||
259 | 250 | ||
260 | static void | 251 | static void |
252 | zone_proc_end (void *cls) | ||
253 | { | ||
254 | GNUNET_break (2 == returned_records); | ||
255 | if (2 == returned_records) | ||
256 | { | ||
257 | res = 0; /* Last iteraterator callback, we are done */ | ||
258 | zi = NULL; | ||
259 | } | ||
260 | else | ||
261 | res = 1; | ||
262 | |||
263 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
264 | "Received last result, iteration done after receing %u results\n", | ||
265 | returned_records); | ||
266 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
267 | } | ||
268 | |||
269 | |||
270 | static void | ||
261 | put_cont (void *cls, int32_t success, const char *emsg) | 271 | put_cont (void *cls, int32_t success, const char *emsg) |
262 | { | 272 | { |
263 | static int c = 0; | 273 | static int c = 0; |
@@ -288,8 +298,12 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
288 | "All records created, starting iteration over all zones \n"); | 298 | "All records created, starting iteration over all zones \n"); |
289 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, | 299 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, |
290 | privkey, | 300 | privkey, |
301 | &fail_cb, | ||
302 | NULL, | ||
291 | &zone_proc, | 303 | &zone_proc, |
292 | NULL); | 304 | NULL, |
305 | &zone_proc_end, | ||
306 | NULL); | ||
293 | if (zi == NULL) | 307 | if (zi == NULL) |
294 | { | 308 | { |
295 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 309 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -336,42 +350,55 @@ empty_zone_proc (void *cls, | |||
336 | unsigned int rd_count, | 350 | unsigned int rd_count, |
337 | const struct GNUNET_GNSRECORD_Data *rd) | 351 | const struct GNUNET_GNSRECORD_Data *rd) |
338 | { | 352 | { |
339 | char *hostkey_file; | ||
340 | |||
341 | GNUNET_assert (nsh == cls); | 353 | GNUNET_assert (nsh == cls); |
342 | if (NULL != zone) | 354 | if (NULL != zone) |
343 | { | 355 | { |
344 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 356 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
345 | _("Expected empty zone but received zone private key\n")); | 357 | _("Expected empty zone but received zone private key\n")); |
346 | GNUNET_break (0); | 358 | GNUNET_break (0); |
347 | if (endbadly_task != NULL) | 359 | if (endbadly_task != NULL) |
348 | GNUNET_SCHEDULER_cancel (endbadly_task); | 360 | GNUNET_SCHEDULER_cancel (endbadly_task); |
349 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 361 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
350 | return; | 362 | return; |
351 | } | 363 | } |
352 | if ((NULL != label) || (NULL != rd) || (0 != rd_count)) | 364 | if ((NULL != label) || (NULL != rd) || (0 != rd_count)) |
353 | { | 365 | { |
354 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 366 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
355 | _("Expected no zone content but received data\n")); | 367 | _("Expected no zone content but received data\n")); |
356 | GNUNET_break (0); | 368 | GNUNET_break (0); |
357 | if (endbadly_task != NULL) | 369 | if (endbadly_task != NULL) |
358 | GNUNET_SCHEDULER_cancel (endbadly_task); | 370 | GNUNET_SCHEDULER_cancel (endbadly_task); |
359 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 371 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
360 | return; | 372 | return; |
361 | } | 373 | } |
374 | GNUNET_assert (0); | ||
375 | } | ||
362 | 376 | ||
363 | 377 | ||
378 | static void | ||
379 | empty_zone_proc_end (void *cls) | ||
380 | { | ||
381 | char *hostkey_file; | ||
382 | |||
364 | zi = NULL; | 383 | zi = NULL; |
365 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 384 | GNUNET_asprintf (&hostkey_file, |
366 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 385 | "zonefiles%s%s", |
367 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 386 | DIR_SEPARATOR_STR, |
368 | privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); | 387 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); |
388 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
389 | "Using zonekey file `%s'\n", | ||
390 | hostkey_file); | ||
391 | privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file (hostkey_file); | ||
369 | GNUNET_free (hostkey_file); | 392 | GNUNET_free (hostkey_file); |
370 | GNUNET_assert (privkey != NULL); | 393 | GNUNET_assert (privkey != NULL); |
371 | 394 | ||
372 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 395 | GNUNET_asprintf(&hostkey_file, |
373 | "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"); | 396 | "zonefiles%s%s", |
374 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 397 | DIR_SEPARATOR_STR, |
398 | "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"); | ||
399 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
400 | "Using zonekey file `%s' \n", | ||
401 | hostkey_file); | ||
375 | privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); | 402 | privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); |
376 | GNUNET_free (hostkey_file); | 403 | GNUNET_free (hostkey_file); |
377 | GNUNET_assert (privkey2 != NULL); | 404 | GNUNET_assert (privkey2 != NULL); |
@@ -380,25 +407,39 @@ empty_zone_proc (void *cls, | |||
380 | "Created record 1\n"); | 407 | "Created record 1\n"); |
381 | 408 | ||
382 | GNUNET_asprintf(&s_name_1, "dummy1"); | 409 | GNUNET_asprintf(&s_name_1, "dummy1"); |
383 | s_rd_1 = create_record(1); | 410 | s_rd_1 = create_record (1); |
384 | GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, | 411 | GNUNET_NAMESTORE_records_store (nsh, |
385 | 1, s_rd_1, &put_cont, NULL); | 412 | privkey, |
413 | s_name_1, | ||
414 | 1, | ||
415 | s_rd_1, | ||
416 | &put_cont, | ||
417 | NULL); | ||
386 | 418 | ||
387 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 419 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
388 | "Created record 2 \n"); | 420 | "Created record 2 \n"); |
389 | GNUNET_asprintf(&s_name_2, "dummy2"); | 421 | GNUNET_asprintf(&s_name_2, "dummy2"); |
390 | s_rd_2 = create_record(1); | 422 | s_rd_2 = create_record (1); |
391 | GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_2, | 423 | GNUNET_NAMESTORE_records_store (nsh, |
392 | 1, s_rd_2, &put_cont, NULL); | 424 | privkey, |
425 | s_name_2, | ||
426 | 1, | ||
427 | s_rd_2, | ||
428 | &put_cont, | ||
429 | NULL); | ||
393 | 430 | ||
394 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 431 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
395 | "Created record 3\n"); | 432 | "Created record 3\n"); |
396 | 433 | ||
397 | /* name in different zone */ | 434 | /* name in different zone */ |
398 | GNUNET_asprintf(&s_name_3, "dummy3"); | 435 | GNUNET_asprintf(&s_name_3, "dummy3"); |
399 | s_rd_3 = create_record(1); | 436 | s_rd_3 = create_record (1); |
400 | GNUNET_NAMESTORE_records_store(nsh, privkey2, s_name_3, | 437 | GNUNET_NAMESTORE_records_store (nsh, |
401 | 1, s_rd_3, &put_cont, NULL); | 438 | privkey2, |
439 | s_name_3, | ||
440 | 1, s_rd_3, | ||
441 | &put_cont, | ||
442 | NULL); | ||
402 | } | 443 | } |
403 | 444 | ||
404 | 445 | ||
@@ -423,7 +464,12 @@ run (void *cls, | |||
423 | /* first, iterate over empty namestore */ | 464 | /* first, iterate over empty namestore */ |
424 | zi = GNUNET_NAMESTORE_zone_iteration_start (nsh, | 465 | zi = GNUNET_NAMESTORE_zone_iteration_start (nsh, |
425 | NULL, | 466 | NULL, |
426 | &empty_zone_proc, nsh); | 467 | &fail_cb, |
468 | NULL, | ||
469 | &empty_zone_proc, | ||
470 | nsh, | ||
471 | &empty_zone_proc_end, | ||
472 | nsh); | ||
427 | if (NULL == zi) | 473 | if (NULL == zi) |
428 | { | 474 | { |
429 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 475 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
diff --git a/src/namestore/test_namestore_api_zone_iteration_stop.c b/src/namestore/test_namestore_api_zone_iteration_stop.c index 36f527da0..a5f040150 100644 --- a/src/namestore/test_namestore_api_zone_iteration_stop.c +++ b/src/namestore/test_namestore_api_zone_iteration_stop.c | |||
@@ -156,6 +156,13 @@ end (void *cls) | |||
156 | 156 | ||
157 | 157 | ||
158 | static void | 158 | static void |
159 | fail_cb (void *cls) | ||
160 | { | ||
161 | GNUNET_assert (0); | ||
162 | } | ||
163 | |||
164 | |||
165 | static void | ||
159 | zone_proc (void *cls, | 166 | zone_proc (void *cls, |
160 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, | 167 | const struct GNUNET_CRYPTO_EcdsaPrivateKey *zone, |
161 | const char *label, | 168 | const char *label, |
@@ -163,20 +170,7 @@ zone_proc (void *cls, | |||
163 | const struct GNUNET_GNSRECORD_Data *rd) | 170 | const struct GNUNET_GNSRECORD_Data *rd) |
164 | { | 171 | { |
165 | int failed = GNUNET_NO; | 172 | int failed = GNUNET_NO; |
166 | if ((zone == NULL) && (label == NULL)) | 173 | |
167 | { | ||
168 | GNUNET_break (1 <= returned_records); | ||
169 | if (1 >= returned_records) | ||
170 | res = 1; /* Last iteraterator callback, we are done */ | ||
171 | else | ||
172 | res = 0; | ||
173 | zi = NULL; | ||
174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
175 | "Received last result, iteration done after receing %u results\n", | ||
176 | returned_records ); | ||
177 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
178 | return; | ||
179 | } | ||
180 | GNUNET_assert (NULL != zone); | 174 | GNUNET_assert (NULL != zone); |
181 | if (0 == memcmp (zone, privkey, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) | 175 | if (0 == memcmp (zone, privkey, sizeof (struct GNUNET_CRYPTO_EcdsaPrivateKey))) |
182 | { | 176 | { |
@@ -288,6 +282,22 @@ zone_proc (void *cls, | |||
288 | 282 | ||
289 | 283 | ||
290 | static void | 284 | static void |
285 | zone_proc_end (void *cls) | ||
286 | { | ||
287 | GNUNET_break (1 <= returned_records); | ||
288 | if (1 >= returned_records) | ||
289 | res = 1; /* Last iteraterator callback, we are done */ | ||
290 | else | ||
291 | res = 0; | ||
292 | zi = NULL; | ||
293 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
294 | "Received last result, iteration done after receing %u results\n", | ||
295 | returned_records); | ||
296 | GNUNET_SCHEDULER_add_now (&end, NULL); | ||
297 | } | ||
298 | |||
299 | |||
300 | static void | ||
291 | put_cont (void *cls, int32_t success, const char *emsg) | 301 | put_cont (void *cls, int32_t success, const char *emsg) |
292 | { | 302 | { |
293 | static int c = 0; | 303 | static int c = 0; |
@@ -312,14 +322,20 @@ put_cont (void *cls, int32_t success, const char *emsg) | |||
312 | { | 322 | { |
313 | res = 1; | 323 | res = 1; |
314 | returned_records = 0; | 324 | returned_records = 0; |
315 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "All records created, starting iteration over all zones \n"); | 325 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
316 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, | 326 | "All records created, starting iteration over all zones \n"); |
317 | NULL, | 327 | zi = GNUNET_NAMESTORE_zone_iteration_start (nsh, |
318 | &zone_proc, | 328 | NULL, |
319 | NULL); | 329 | &fail_cb, |
330 | NULL, | ||
331 | &zone_proc, | ||
332 | NULL, | ||
333 | &zone_proc_end, | ||
334 | NULL); | ||
320 | if (zi == NULL) | 335 | if (zi == NULL) |
321 | { | 336 | { |
322 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to create zone iterator\n"); | 337 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
338 | "Failed to create zone iterator\n"); | ||
323 | GNUNET_break (0); | 339 | GNUNET_break (0); |
324 | if (NULL != endbadly_task) | 340 | if (NULL != endbadly_task) |
325 | GNUNET_SCHEDULER_cancel (endbadly_task); | 341 | GNUNET_SCHEDULER_cancel (endbadly_task); |
@@ -362,7 +378,6 @@ empty_zone_proc (void *cls, | |||
362 | unsigned int rd_count, | 378 | unsigned int rd_count, |
363 | const struct GNUNET_GNSRECORD_Data *rd) | 379 | const struct GNUNET_GNSRECORD_Data *rd) |
364 | { | 380 | { |
365 | char *hostkey_file; | ||
366 | 381 | ||
367 | GNUNET_assert (nsh == cls); | 382 | GNUNET_assert (nsh == cls); |
368 | if (NULL != zone) | 383 | if (NULL != zone) |
@@ -385,42 +400,72 @@ empty_zone_proc (void *cls, | |||
385 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); | 400 | endbadly_task = GNUNET_SCHEDULER_add_now (&endbadly, NULL); |
386 | return; | 401 | return; |
387 | } | 402 | } |
403 | GNUNET_assert (0); | ||
404 | } | ||
405 | |||
388 | 406 | ||
407 | static void | ||
408 | empty_zone_proc_end (void *cls) | ||
409 | { | ||
410 | char *hostkey_file; | ||
411 | |||
412 | GNUNET_assert (nsh == cls); | ||
389 | zi = NULL; | 413 | zi = NULL; |
390 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 414 | GNUNET_asprintf(&hostkey_file, |
391 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | 415 | "zonefiles%s%s", |
392 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 416 | DIR_SEPARATOR_STR, |
417 | "N0UJMP015AFUNR2BTNM3FKPBLG38913BL8IDMCO2H0A1LIB81960.zkey"); | ||
418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
419 | "Using zonekey file `%s' \n", | ||
420 | hostkey_file); | ||
393 | privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); | 421 | privkey = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); |
394 | GNUNET_free (hostkey_file); | 422 | GNUNET_free (hostkey_file); |
395 | GNUNET_assert (privkey != NULL); | 423 | GNUNET_assert (privkey != NULL); |
396 | 424 | ||
397 | GNUNET_asprintf(&hostkey_file,"zonefiles%s%s",DIR_SEPARATOR_STR, | 425 | GNUNET_asprintf (&hostkey_file, |
398 | "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"); | 426 | "zonefiles%s%s", |
399 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Using zonekey file `%s' \n", hostkey_file); | 427 | DIR_SEPARATOR_STR, |
428 | "HGU0A0VCU334DN7F2I9UIUMVQMM7JMSD142LIMNUGTTV9R0CF4EG.zkey"); | ||
429 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
430 | "Using zonekey file `%s'\n", | ||
431 | hostkey_file); | ||
400 | privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); | 432 | privkey2 = GNUNET_CRYPTO_ecdsa_key_create_from_file(hostkey_file); |
401 | GNUNET_free (hostkey_file); | 433 | GNUNET_free (hostkey_file); |
402 | GNUNET_assert (privkey2 != NULL); | 434 | GNUNET_assert (privkey2 != NULL); |
403 | 435 | ||
404 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 1\n"); | 436 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
437 | "Created record 1\n"); | ||
405 | 438 | ||
406 | GNUNET_asprintf(&s_name_1, "dummy1"); | 439 | GNUNET_asprintf(&s_name_1, |
440 | "dummy1"); | ||
407 | s_rd_1 = create_record(1); | 441 | s_rd_1 = create_record(1); |
408 | GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, | 442 | GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_1, |
409 | 1, s_rd_1, &put_cont, NULL); | 443 | 1, s_rd_1, &put_cont, NULL); |
410 | 444 | ||
411 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 2 \n"); | 445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
412 | GNUNET_asprintf(&s_name_2, "dummy2"); | 446 | "Created record 2 \n"); |
447 | GNUNET_asprintf(&s_name_2, | ||
448 | "dummy2"); | ||
413 | s_rd_2 = create_record(1); | 449 | s_rd_2 = create_record(1); |
414 | GNUNET_NAMESTORE_records_store(nsh, privkey, s_name_2, | 450 | GNUNET_NAMESTORE_records_store (nsh, |
415 | 1, s_rd_2, &put_cont, NULL); | 451 | privkey, |
452 | s_name_2, | ||
453 | 1, | ||
454 | s_rd_2, | ||
455 | &put_cont, NULL); | ||
416 | 456 | ||
417 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Created record 3\n"); | 457 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
458 | "Created record 3\n"); | ||
418 | 459 | ||
419 | /* name in different zone */ | 460 | /* name in different zone */ |
420 | GNUNET_asprintf(&s_name_3, "dummy3"); | 461 | GNUNET_asprintf(&s_name_3, "dummy3"); |
421 | s_rd_3 = create_record(1); | 462 | s_rd_3 = create_record(1); |
422 | GNUNET_NAMESTORE_records_store(nsh, privkey2, s_name_3, | 463 | GNUNET_NAMESTORE_records_store(nsh, |
423 | 1, s_rd_3, &put_cont, NULL); | 464 | privkey2, |
465 | s_name_3, | ||
466 | 1, | ||
467 | s_rd_3, | ||
468 | &put_cont, NULL); | ||
424 | } | 469 | } |
425 | 470 | ||
426 | 471 | ||
@@ -441,7 +486,13 @@ run (void *cls, | |||
441 | GNUNET_break (NULL != nsh); | 486 | GNUNET_break (NULL != nsh); |
442 | /* first, iterate over empty namestore */ | 487 | /* first, iterate over empty namestore */ |
443 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, | 488 | zi = GNUNET_NAMESTORE_zone_iteration_start(nsh, |
444 | NULL, &empty_zone_proc, nsh); | 489 | NULL, |
490 | &fail_cb, | ||
491 | NULL, | ||
492 | &empty_zone_proc, | ||
493 | nsh, | ||
494 | &empty_zone_proc_end, | ||
495 | nsh); | ||
445 | if (NULL == zi) | 496 | if (NULL == zi) |
446 | { | 497 | { |
447 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 498 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |