diff options
author | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-28 00:47:17 +0000 |
---|---|---|
committer | Martin Schanzenbach <mschanzenbach@posteo.de> | 2012-06-28 00:47:17 +0000 |
commit | 146d71432ed366ccd3e576f4b3e261ace67cf757 (patch) | |
tree | 23d1bc94cfabd932a860c1b7a465a383dc96101b /src/gns | |
parent | e5b1e32c9b441c00fbd7aed2a060583388bdd441 (diff) | |
download | gnunet-146d71432ed366ccd3e576f4b3e261ace67cf757.tar.gz gnunet-146d71432ed366ccd3e576f4b3e261ace67cf757.zip |
-big commit, make new ns and valgrind happy
Diffstat (limited to 'src/gns')
-rw-r--r-- | src/gns/gnunet-service-gns.c | 10 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.c | 631 | ||||
-rw-r--r-- | src/gns/gnunet-service-gns_resolver.h | 31 | ||||
-rw-r--r-- | src/gns/test_gns_cname_lookup.c | 9 | ||||
-rw-r--r-- | src/gns/test_gns_dht_delegated_lookup.c | 5 | ||||
-rw-r--r-- | src/gns/test_gns_dht_threepeer.c | 20 | ||||
-rw-r--r-- | src/gns/test_gns_max_queries.c | 2 | ||||
-rw-r--r-- | src/gns/test_gns_ns_lookup.c | 2 | ||||
-rw-r--r-- | src/gns/test_gns_pseu_shorten.c | 10 | ||||
-rw-r--r-- | src/gns/test_gns_revocation.c | 2 | ||||
-rw-r--r-- | src/gns/test_gns_simple_delegated_lookup.c | 2 | ||||
-rw-r--r-- | src/gns/test_gns_simple_get_authority.c | 8 | ||||
-rw-r--r-- | src/gns/test_gns_simple_lookup.c | 2 | ||||
-rw-r--r-- | src/gns/test_gns_simple_mx_lookup.c | 2 | ||||
-rw-r--r-- | src/gns/test_gns_simple_shorten.c | 8 | ||||
-rw-r--r-- | src/gns/test_gns_simple_srv_lookup.c | 2 | ||||
-rw-r--r-- | src/gns/test_gns_simple_zkey_lookup.c | 2 |
17 files changed, 507 insertions, 241 deletions
diff --git a/src/gns/gnunet-service-gns.c b/src/gns/gnunet-service-gns.c index fa2b3e2e2..1ebfd5e93 100644 --- a/src/gns/gnunet-service-gns.c +++ b/src/gns/gnunet-service-gns.c | |||
@@ -199,6 +199,8 @@ static int v4_enabled; | |||
199 | static void | 199 | static void |
200 | on_resolver_cleanup(void) | 200 | on_resolver_cleanup(void) |
201 | { | 201 | { |
202 | if (NULL != namestore_iter) | ||
203 | GNUNET_NAMESTORE_zone_iteration_stop (namestore_iter); | ||
202 | GNUNET_NAMESTORE_disconnect(namestore_handle); | 204 | GNUNET_NAMESTORE_disconnect(namestore_handle); |
203 | GNUNET_DHT_disconnect(dht_handle); | 205 | GNUNET_DHT_disconnect(dht_handle); |
204 | } | 206 | } |
@@ -238,7 +240,7 @@ static void | |||
238 | update_zone_dht_next(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 240 | update_zone_dht_next(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
239 | { | 241 | { |
240 | zone_update_taskid = GNUNET_SCHEDULER_NO_TASK; | 242 | zone_update_taskid = GNUNET_SCHEDULER_NO_TASK; |
241 | GNUNET_NAMESTORE_zone_iterator_next(namestore_iter); | 243 | GNUNET_NAMESTORE_zone_iterator_next (namestore_iter); |
242 | } | 244 | } |
243 | 245 | ||
244 | /** | 246 | /** |
@@ -298,6 +300,7 @@ put_gns_record(void *cls, | |||
298 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 300 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
299 | "Zone iteration finished. Rescheduling put in %ds\n", | 301 | "Zone iteration finished. Rescheduling put in %ds\n", |
300 | dht_max_update_interval); | 302 | dht_max_update_interval); |
303 | namestore_iter = NULL; | ||
301 | zone_update_taskid = GNUNET_SCHEDULER_add_delayed ( | 304 | zone_update_taskid = GNUNET_SCHEDULER_add_delayed ( |
302 | GNUNET_TIME_relative_multiply( | 305 | GNUNET_TIME_relative_multiply( |
303 | GNUNET_TIME_UNIT_SECONDS, | 306 | GNUNET_TIME_UNIT_SECONDS, |
@@ -854,7 +857,7 @@ send_lookup_response(void* cls, | |||
854 | rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT); | 857 | rmsg->header.type = htons(GNUNET_MESSAGE_TYPE_GNS_LOOKUP_RESULT); |
855 | rmsg->header.size = | 858 | rmsg->header.size = |
856 | htons(len+sizeof(struct GNUNET_GNS_ClientLookupResultMessage)); | 859 | htons(len+sizeof(struct GNUNET_GNS_ClientLookupResultMessage)); |
857 | 860 | ||
858 | GNUNET_NAMESTORE_records_serialize (rd_count, rd, len, (char*)&rmsg[1]); | 861 | GNUNET_NAMESTORE_records_serialize (rd_count, rd, len, (char*)&rmsg[1]); |
859 | 862 | ||
860 | GNUNET_SERVER_notification_context_unicast (nc, clh->client, | 863 | GNUNET_SERVER_notification_context_unicast (nc, clh->client, |
@@ -932,7 +935,8 @@ handle_lookup(void *cls, | |||
932 | } | 935 | } |
933 | 936 | ||
934 | namelen = strlen(name)+1; | 937 | namelen = strlen(name)+1; |
935 | clh = GNUNET_malloc(sizeof(struct ClientLookupHandle)); | 938 | clh = GNUNET_malloc (sizeof (struct ClientLookupHandle)); |
939 | memset (clh, 0, sizeof (struct ClientLookupHandle)); | ||
936 | clh->client = client; | 940 | clh->client = client; |
937 | clh->name = GNUNET_malloc(namelen); | 941 | clh->name = GNUNET_malloc(namelen); |
938 | strcpy(clh->name, name); | 942 | strcpy(clh->name, name); |
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c index 230efb999..56e6e39ef 100644 --- a/src/gns/gnunet-service-gns_resolver.c +++ b/src/gns/gnunet-service-gns_resolver.c | |||
@@ -67,11 +67,21 @@ static struct GNUNET_DHT_Handle *dht_handle; | |||
67 | static struct GNUNET_CONTAINER_Heap *dht_lookup_heap; | 67 | static struct GNUNET_CONTAINER_Heap *dht_lookup_heap; |
68 | 68 | ||
69 | /** | 69 | /** |
70 | * Heap for namestore queues | ||
71 | */ | ||
72 | static struct GNUNET_CONTAINER_Heap *ns_task_heap; | ||
73 | |||
74 | /** | ||
70 | * Maximum amount of parallel queries in background | 75 | * Maximum amount of parallel queries in background |
71 | */ | 76 | */ |
72 | static unsigned long long max_allowed_background_queries; | 77 | static unsigned long long max_allowed_background_queries; |
73 | 78 | ||
74 | /** | 79 | /** |
80 | * Maximum amount of parallel namestore tasks in background | ||
81 | */ | ||
82 | static unsigned long long max_allowed_ns_tasks; | ||
83 | |||
84 | /** | ||
75 | * Wheather or not to ignore pending records | 85 | * Wheather or not to ignore pending records |
76 | */ | 86 | */ |
77 | static int ignore_pending_records; | 87 | static int ignore_pending_records; |
@@ -92,6 +102,36 @@ static struct GetPseuAuthorityHandle *gph_head; | |||
92 | static struct GetPseuAuthorityHandle *gph_tail; | 102 | static struct GetPseuAuthorityHandle *gph_tail; |
93 | 103 | ||
94 | /** | 104 | /** |
105 | * Resolver lookup list | ||
106 | */ | ||
107 | static struct ResolverHandle *rlh_head; | ||
108 | |||
109 | /** | ||
110 | * Resolver lookup list | ||
111 | */ | ||
112 | static struct ResolverHandle *rlh_tail; | ||
113 | |||
114 | /** | ||
115 | * Resolver shorten list | ||
116 | */ | ||
117 | static struct ResolverHandle *nsh_head; | ||
118 | |||
119 | /** | ||
120 | * Resolver shorten list | ||
121 | */ | ||
122 | static struct ResolverHandle *nsh_tail; | ||
123 | |||
124 | /** | ||
125 | * Resolver get auth list | ||
126 | */ | ||
127 | static struct ResolverHandle *nah_head; | ||
128 | |||
129 | /** | ||
130 | * Resolver get auth list | ||
131 | */ | ||
132 | static struct ResolverHandle *nah_tail; | ||
133 | |||
134 | /** | ||
95 | * a resolution identifier pool variable | 135 | * a resolution identifier pool variable |
96 | * FIXME overflow? | 136 | * FIXME overflow? |
97 | * This is a non critical identifier useful for debugging | 137 | * This is a non critical identifier useful for debugging |
@@ -166,6 +206,26 @@ static void | |||
166 | shorten_authority_chain (struct GetPseuAuthorityHandle *gph); | 206 | shorten_authority_chain (struct GetPseuAuthorityHandle *gph); |
167 | 207 | ||
168 | 208 | ||
209 | static void | ||
210 | create_pseu_cont (void* cls, int32_t success, const char* emsg) | ||
211 | { | ||
212 | //FIXME do sth with error | ||
213 | struct GetPseuAuthorityHandle* gph = (struct GetPseuAuthorityHandle*)cls; | ||
214 | struct AuthorityChain *iter; | ||
215 | |||
216 | gph->namestore_task = NULL; | ||
217 | do | ||
218 | { | ||
219 | iter = gph->ahead->next; | ||
220 | GNUNET_free (gph->ahead); | ||
221 | gph->ahead = iter; | ||
222 | } while (iter != NULL); | ||
223 | GNUNET_CRYPTO_rsa_key_free (gph->key); | ||
224 | GNUNET_CONTAINER_DLL_remove (gph_head, gph_tail, gph); | ||
225 | GNUNET_free (gph); | ||
226 | } | ||
227 | |||
228 | |||
169 | /** | 229 | /** |
170 | * Namestore calls this function if we have record for this name. | 230 | * Namestore calls this function if we have record for this name. |
171 | * (or with rd_count=0 to indicate no matches) | 231 | * (or with rd_count=0 to indicate no matches) |
@@ -190,6 +250,7 @@ process_pseu_lookup_ns (void* cls, | |||
190 | struct GNUNET_NAMESTORE_RecordData new_pkey; | 250 | struct GNUNET_NAMESTORE_RecordData new_pkey; |
191 | struct AuthorityChain *iter; | 251 | struct AuthorityChain *iter; |
192 | 252 | ||
253 | gph->namestore_task = NULL; | ||
193 | if (rd_count > 0) | 254 | if (rd_count > 0) |
194 | { | 255 | { |
195 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 256 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
@@ -226,7 +287,7 @@ process_pseu_lookup_ns (void* cls, | |||
226 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 287 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
227 | "GNS_AUTO_PSEU: Trying delegated name %s\n", gph->name); | 288 | "GNS_AUTO_PSEU: Trying delegated name %s\n", gph->name); |
228 | memcpy (gph->test_name, gph->name, strlen (gph->name)+1); | 289 | memcpy (gph->test_name, gph->name, strlen (gph->name)+1); |
229 | GNUNET_NAMESTORE_lookup_record (namestore_handle, | 290 | gph->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, |
230 | &gph->our_zone, | 291 | &gph->our_zone, |
231 | gph->test_name, | 292 | gph->test_name, |
232 | GNUNET_NAMESTORE_TYPE_ANY, | 293 | GNUNET_NAMESTORE_TYPE_ANY, |
@@ -246,22 +307,12 @@ process_pseu_lookup_ns (void* cls, | |||
246 | new_pkey.flags = GNUNET_NAMESTORE_RF_AUTHORITY | 307 | new_pkey.flags = GNUNET_NAMESTORE_RF_AUTHORITY |
247 | | GNUNET_NAMESTORE_RF_PRIVATE | 308 | | GNUNET_NAMESTORE_RF_PRIVATE |
248 | | GNUNET_NAMESTORE_RF_PENDING; | 309 | | GNUNET_NAMESTORE_RF_PENDING; |
249 | GNUNET_NAMESTORE_record_create (namestore_handle, | 310 | gph->namestore_task = GNUNET_NAMESTORE_record_create (namestore_handle, |
250 | gph->key, | 311 | gph->key, |
251 | gph->test_name, | 312 | gph->test_name, |
252 | &new_pkey, | 313 | &new_pkey, |
253 | NULL, //cont | 314 | &create_pseu_cont, //cont |
254 | NULL); //cls | 315 | gph); //cls |
255 | do | ||
256 | { | ||
257 | iter = gph->ahead->next; | ||
258 | GNUNET_free (gph->ahead); | ||
259 | gph->ahead = iter; | ||
260 | } while (iter != NULL); | ||
261 | GNUNET_CRYPTO_rsa_key_free (gph->key); | ||
262 | GNUNET_CONTAINER_DLL_remove (gph_head, gph_tail, gph); | ||
263 | GNUNET_free (gph); | ||
264 | |||
265 | } | 316 | } |
266 | 317 | ||
267 | /** | 318 | /** |
@@ -289,7 +340,7 @@ process_pseu_result (struct GetPseuAuthorityHandle* gph, char* name) | |||
289 | /** | 340 | /** |
290 | * Check for collision | 341 | * Check for collision |
291 | */ | 342 | */ |
292 | GNUNET_NAMESTORE_lookup_record (namestore_handle, | 343 | gph->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, |
293 | &gph->our_zone, | 344 | &gph->our_zone, |
294 | gph->test_name, | 345 | gph->test_name, |
295 | GNUNET_NAMESTORE_TYPE_ANY, | 346 | GNUNET_NAMESTORE_TYPE_ANY, |
@@ -479,6 +530,7 @@ process_auth_discovery_ns_result(void* cls, | |||
479 | struct GetPseuAuthorityHandle* gph = (struct GetPseuAuthorityHandle*)cls; | 530 | struct GetPseuAuthorityHandle* gph = (struct GetPseuAuthorityHandle*)cls; |
480 | struct AuthorityChain *iter; | 531 | struct AuthorityChain *iter; |
481 | 532 | ||
533 | gph->namestore_task = NULL; | ||
482 | /* no pseu found */ | 534 | /* no pseu found */ |
483 | if (rd_count == 0) | 535 | if (rd_count == 0) |
484 | { | 536 | { |
@@ -567,7 +619,8 @@ process_zone_to_name_discover (void *cls, | |||
567 | { | 619 | { |
568 | struct GetPseuAuthorityHandle* gph = (struct GetPseuAuthorityHandle*)cls; | 620 | struct GetPseuAuthorityHandle* gph = (struct GetPseuAuthorityHandle*)cls; |
569 | struct AuthorityChain *iter; | 621 | struct AuthorityChain *iter; |
570 | 622 | ||
623 | gph->namestore_task = NULL; | ||
571 | /* we found a match in our own zone */ | 624 | /* we found a match in our own zone */ |
572 | if (rd_len != 0) | 625 | if (rd_len != 0) |
573 | { | 626 | { |
@@ -588,7 +641,7 @@ process_zone_to_name_discover (void *cls, | |||
588 | else | 641 | else |
589 | { | 642 | { |
590 | 643 | ||
591 | GNUNET_NAMESTORE_lookup_record (namestore_handle, | 644 | gph->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, |
592 | &gph->ahead->zone, | 645 | &gph->ahead->zone, |
593 | "+", | 646 | "+", |
594 | GNUNET_GNS_RECORD_PSEU, | 647 | GNUNET_GNS_RECORD_PSEU, |
@@ -612,7 +665,7 @@ shorten_authority_chain (struct GetPseuAuthorityHandle *gph) | |||
612 | "GNS_AUTO_PSEU: New authority %s discovered\n", | 665 | "GNS_AUTO_PSEU: New authority %s discovered\n", |
613 | gph->ahead->name); | 666 | gph->ahead->name); |
614 | 667 | ||
615 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | 668 | gph->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, |
616 | &gph->our_zone, | 669 | &gph->our_zone, |
617 | &gph->ahead->zone, | 670 | &gph->ahead->zone, |
618 | &process_zone_to_name_discover, | 671 | &process_zone_to_name_discover, |
@@ -685,12 +738,22 @@ gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh, | |||
685 | local_zone = lz; | 738 | local_zone = lz; |
686 | dht_lookup_heap = | 739 | dht_lookup_heap = |
687 | GNUNET_CONTAINER_heap_create(GNUNET_CONTAINER_HEAP_ORDER_MIN); | 740 | GNUNET_CONTAINER_heap_create(GNUNET_CONTAINER_HEAP_ORDER_MIN); |
741 | ns_task_heap = | ||
742 | GNUNET_CONTAINER_heap_create(GNUNET_CONTAINER_HEAP_ORDER_MIN); | ||
688 | max_allowed_background_queries = max_bg_queries; | 743 | max_allowed_background_queries = max_bg_queries; |
744 | max_allowed_ns_tasks = GNUNET_GNS_MAX_NS_TASKS; | ||
745 | |||
689 | ignore_pending_records = ignore_pending; | 746 | ignore_pending_records = ignore_pending; |
690 | 747 | ||
691 | gph_head = NULL; | 748 | gph_head = NULL; |
692 | gph_tail = NULL; | 749 | gph_tail = NULL; |
693 | 750 | rlh_head = NULL; | |
751 | rlh_tail = NULL; | ||
752 | nsh_head = NULL; | ||
753 | nsh_tail = NULL; | ||
754 | nah_head = NULL; | ||
755 | nah_tail = NULL; | ||
756 | |||
694 | GNUNET_RESOLVER_connect (cfg); | 757 | GNUNET_RESOLVER_connect (cfg); |
695 | 758 | ||
696 | if (NULL == vpn_handle) | 759 | if (NULL == vpn_handle) |
@@ -713,8 +776,55 @@ gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh, | |||
713 | return GNUNET_SYSERR; | 776 | return GNUNET_SYSERR; |
714 | } | 777 | } |
715 | 778 | ||
779 | |||
716 | /** | 780 | /** |
717 | * Cleanup background lookups | 781 | * Cleanup ns tasks |
782 | * | ||
783 | * @param cls closure to iterator | ||
784 | * @param node heap nodes | ||
785 | * @param element the namestorebgtask | ||
786 | * @param cost heap cost | ||
787 | * @return always GNUNET_YES | ||
788 | */ | ||
789 | static int | ||
790 | cleanup_pending_ns_tasks(void* cls, | ||
791 | struct GNUNET_CONTAINER_HeapNode *node, | ||
792 | void *element, | ||
793 | GNUNET_CONTAINER_HeapCostType cost) | ||
794 | { | ||
795 | struct NamestoreBGTask *nbg = (struct NamestoreBGTask *)element; | ||
796 | ResolverCleanupContinuation cont = cls; | ||
797 | |||
798 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
799 | "GNS_CLEANUP: Terminating ns task\n"); | ||
800 | GNUNET_NAMESTORE_cancel (nbg->qe); | ||
801 | |||
802 | GNUNET_CONTAINER_heap_remove_node(node); | ||
803 | |||
804 | if (GNUNET_CONTAINER_heap_get_size(ns_task_heap) == 0) | ||
805 | cont(); | ||
806 | |||
807 | return GNUNET_YES; | ||
808 | } | ||
809 | |||
810 | |||
811 | /** | ||
812 | * finish lookup | ||
813 | * | ||
814 | * @param rh resolver handle | ||
815 | * @param rlh record lookup handle | ||
816 | * @param rd_count number of results | ||
817 | * @param rd results | ||
818 | */ | ||
819 | static void | ||
820 | finish_lookup (struct ResolverHandle *rh, | ||
821 | struct RecordLookupHandle* rlh, | ||
822 | unsigned int rd_count, | ||
823 | const struct GNUNET_NAMESTORE_RecordData *rd); | ||
824 | |||
825 | |||
826 | /** | ||
827 | * Cleanup background lookups FIXME get rid of this?? | ||
718 | * | 828 | * |
719 | * @param cls closure to iterator | 829 | * @param cls closure to iterator |
720 | * @param node heap nodes | 830 | * @param node heap nodes |
@@ -723,10 +833,10 @@ gns_resolver_init(struct GNUNET_NAMESTORE_Handle *nh, | |||
723 | * @return always GNUNET_YES | 833 | * @return always GNUNET_YES |
724 | */ | 834 | */ |
725 | static int | 835 | static int |
726 | cleanup_pending_background_queries(void* cls, | 836 | cleanup_pending_background_queries (void* cls, |
727 | struct GNUNET_CONTAINER_HeapNode *node, | 837 | struct GNUNET_CONTAINER_HeapNode *node, |
728 | void *element, | 838 | void *element, |
729 | GNUNET_CONTAINER_HeapCostType cost) | 839 | GNUNET_CONTAINER_HeapCostType cost) |
730 | { | 840 | { |
731 | struct ResolverHandle *rh = (struct ResolverHandle *)element; | 841 | struct ResolverHandle *rh = (struct ResolverHandle *)element; |
732 | ResolverCleanupContinuation cont = cls; | 842 | ResolverCleanupContinuation cont = cls; |
@@ -734,14 +844,24 @@ cleanup_pending_background_queries(void* cls, | |||
734 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 844 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
735 | "GNS_CLEANUP-%llu: Terminating background lookup for %s\n", | 845 | "GNS_CLEANUP-%llu: Terminating background lookup for %s\n", |
736 | rh->id, rh->name); | 846 | rh->id, rh->name); |
737 | GNUNET_DHT_get_stop(rh->get_handle); | 847 | |
738 | rh->get_handle = NULL; | 848 | //finish_lookup (rh, rh->proc_cls, 0, NULL); |
739 | rh->proc(rh->proc_cls, rh, 0, NULL); | 849 | //rh->get_handle = NULL; |
850 | //rh->proc(rh->proc_cls, rh, 0, NULL); | ||
740 | 851 | ||
741 | GNUNET_CONTAINER_heap_remove_node(node); | 852 | GNUNET_CONTAINER_heap_remove_node(node); |
742 | 853 | ||
743 | if (GNUNET_CONTAINER_heap_get_size(dht_lookup_heap) == 0) | 854 | if (GNUNET_CONTAINER_heap_get_size(dht_lookup_heap) == 0) |
744 | cont(); | 855 | { |
856 | if (GNUNET_CONTAINER_heap_get_size(ns_task_heap) == 0) | ||
857 | cont(); | ||
858 | else | ||
859 | { | ||
860 | GNUNET_CONTAINER_heap_iterate (ns_task_heap, | ||
861 | &cleanup_pending_ns_tasks, | ||
862 | cont); | ||
863 | } | ||
864 | } | ||
745 | 865 | ||
746 | 866 | ||
747 | return GNUNET_YES; | 867 | return GNUNET_YES; |
@@ -749,17 +869,80 @@ cleanup_pending_background_queries(void* cls, | |||
749 | 869 | ||
750 | 870 | ||
751 | /** | 871 | /** |
872 | * Helper function to free resolver handle | ||
873 | * | ||
874 | * @param rh the handle to free | ||
875 | */ | ||
876 | static void | ||
877 | free_resolver_handle (struct ResolverHandle* rh) | ||
878 | { | ||
879 | struct AuthorityChain *ac; | ||
880 | struct AuthorityChain *ac_next; | ||
881 | |||
882 | if (NULL == rh) | ||
883 | return; | ||
884 | |||
885 | ac = rh->authority_chain_head; | ||
886 | |||
887 | while (NULL != ac) | ||
888 | { | ||
889 | ac_next = ac->next; | ||
890 | GNUNET_free(ac); | ||
891 | ac = ac_next; | ||
892 | } | ||
893 | |||
894 | if (NULL != rh->get_handle) | ||
895 | GNUNET_DHT_get_stop (rh->get_handle); | ||
896 | |||
897 | if (NULL != rh->dns_raw_packet) | ||
898 | GNUNET_free (rh->dns_raw_packet); | ||
899 | |||
900 | if (NULL != rh->namestore_task) | ||
901 | GNUNET_NAMESTORE_cancel (rh->namestore_task); | ||
902 | rh->namestore_task = NULL; | ||
903 | |||
904 | if (GNUNET_SCHEDULER_NO_TASK != rh->dns_read_task) | ||
905 | GNUNET_SCHEDULER_cancel (rh->dns_read_task); | ||
906 | |||
907 | if (GNUNET_SCHEDULER_NO_TASK != rh->timeout_task) | ||
908 | GNUNET_SCHEDULER_cancel (rh->timeout_task); | ||
909 | |||
910 | if (NULL != rh->dns_sock) | ||
911 | GNUNET_NETWORK_socket_close (rh->dns_sock); | ||
912 | if (NULL != rh->dns_resolver_handle) | ||
913 | GNUNET_RESOLVER_request_cancel (rh->dns_resolver_handle); | ||
914 | GNUNET_free(rh); | ||
915 | } | ||
916 | |||
917 | |||
918 | /** | ||
919 | * finish shorten | ||
920 | * | ||
921 | * @param rh resolver handle | ||
922 | * @param nsh name shorten handle | ||
923 | */ | ||
924 | static void | ||
925 | finish_shorten (struct ResolverHandle *rh, | ||
926 | struct NameShortenHandle *nsh); | ||
927 | /** | ||
928 | * finish get auth | ||
929 | * | ||
930 | * @param rh resolver handle | ||
931 | * @param nah get name authority handle | ||
932 | */ | ||
933 | static void | ||
934 | finish_get_auth (struct ResolverHandle *rh, | ||
935 | struct GetNameAuthorityHandle* rlh); | ||
936 | /** | ||
752 | * Shutdown resolver | 937 | * Shutdown resolver |
753 | */ | 938 | */ |
754 | void | 939 | void |
755 | gns_resolver_cleanup(ResolverCleanupContinuation cont) | 940 | gns_resolver_cleanup (ResolverCleanupContinuation cont) |
756 | { | 941 | { |
757 | unsigned int s = GNUNET_CONTAINER_heap_get_size(dht_lookup_heap); | 942 | unsigned int s; |
758 | struct GetPseuAuthorityHandle *tmp; | 943 | struct GetPseuAuthorityHandle *tmp; |
759 | struct AuthorityChain *iter; | 944 | struct AuthorityChain *iter; |
760 | 945 | ||
761 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
762 | "GNS_CLEANUP: %d pending background queries to terminate\n", s); | ||
763 | 946 | ||
764 | tmp = gph_head; | 947 | tmp = gph_head; |
765 | for (tmp = gph_head; tmp != NULL; tmp = gph_head) | 948 | for (tmp = gph_head; tmp != NULL; tmp = gph_head) |
@@ -770,6 +953,10 @@ gns_resolver_cleanup(ResolverCleanupContinuation cont) | |||
770 | if (tmp->timeout != GNUNET_SCHEDULER_NO_TASK) | 953 | if (tmp->timeout != GNUNET_SCHEDULER_NO_TASK) |
771 | GNUNET_SCHEDULER_cancel (tmp->timeout); | 954 | GNUNET_SCHEDULER_cancel (tmp->timeout); |
772 | tmp->timeout = GNUNET_SCHEDULER_NO_TASK; | 955 | tmp->timeout = GNUNET_SCHEDULER_NO_TASK; |
956 | |||
957 | if (NULL != tmp->namestore_task) | ||
958 | GNUNET_NAMESTORE_cancel (tmp->namestore_task); | ||
959 | tmp->namestore_task = NULL; | ||
773 | 960 | ||
774 | iter = tmp->ahead; | 961 | iter = tmp->ahead; |
775 | do | 962 | do |
@@ -783,45 +970,40 @@ gns_resolver_cleanup(ResolverCleanupContinuation cont) | |||
783 | GNUNET_CONTAINER_DLL_remove (gph_head, gph_tail, tmp); | 970 | GNUNET_CONTAINER_DLL_remove (gph_head, gph_tail, tmp); |
784 | GNUNET_free (tmp); | 971 | GNUNET_free (tmp); |
785 | } | 972 | } |
973 | |||
974 | while (NULL != rlh_head) | ||
975 | { | ||
976 | finish_lookup (rlh_head, rlh_head->proc_cls, 0, NULL); | ||
977 | } | ||
786 | 978 | ||
787 | 979 | while (NULL != nsh_head) | |
980 | { | ||
981 | finish_shorten (nsh_head, nsh_head->proc_cls); | ||
982 | } | ||
983 | |||
984 | while (NULL != nah_head) | ||
985 | { | ||
986 | finish_get_auth (nah_head, nah_head->proc_cls); | ||
987 | } | ||
988 | |||
989 | s = GNUNET_CONTAINER_heap_get_size(dht_lookup_heap); | ||
990 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
991 | "GNS_CLEANUP: %d pending background queries to terminate\n", s); | ||
788 | if (0 != s) | 992 | if (0 != s) |
789 | GNUNET_CONTAINER_heap_iterate (dht_lookup_heap, | 993 | GNUNET_CONTAINER_heap_iterate (dht_lookup_heap, |
790 | &cleanup_pending_background_queries, | 994 | &cleanup_pending_background_queries, |
791 | cont); | 995 | cont); |
996 | else if (0 != GNUNET_CONTAINER_heap_get_size(ns_task_heap)) | ||
997 | { | ||
998 | GNUNET_CONTAINER_heap_iterate (ns_task_heap, | ||
999 | &cleanup_pending_ns_tasks, | ||
1000 | cont); | ||
1001 | } | ||
792 | else | 1002 | else |
793 | cont(); | 1003 | cont(); |
794 | } | 1004 | } |
795 | 1005 | ||
796 | 1006 | ||
797 | /** | ||
798 | * Helper function to free resolver handle | ||
799 | * | ||
800 | * @param rh the handle to free | ||
801 | */ | ||
802 | static void | ||
803 | free_resolver_handle(struct ResolverHandle* rh) | ||
804 | { | ||
805 | struct AuthorityChain *ac; | ||
806 | struct AuthorityChain *ac_next; | ||
807 | |||
808 | if (NULL == rh) | ||
809 | return; | ||
810 | |||
811 | ac = rh->authority_chain_head; | ||
812 | |||
813 | while (NULL != ac) | ||
814 | { | ||
815 | ac_next = ac->next; | ||
816 | GNUNET_free(ac); | ||
817 | ac = ac_next; | ||
818 | } | ||
819 | |||
820 | if (NULL != rh->dns_raw_packet) | ||
821 | GNUNET_free (rh->dns_raw_packet); | ||
822 | |||
823 | GNUNET_free(rh); | ||
824 | } | ||
825 | 1007 | ||
826 | 1008 | ||
827 | /** | 1009 | /** |
@@ -836,6 +1018,11 @@ on_namestore_record_put_result(void *cls, | |||
836 | int32_t success, | 1018 | int32_t success, |
837 | const char *emsg) | 1019 | const char *emsg) |
838 | { | 1020 | { |
1021 | struct NamestoreBGTask *nbg = cls; | ||
1022 | |||
1023 | GNUNET_CONTAINER_heap_remove_node (nbg->node); | ||
1024 | GNUNET_free (nbg); | ||
1025 | |||
839 | if (GNUNET_NO == success) | 1026 | if (GNUNET_NO == success) |
840 | { | 1027 | { |
841 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 1028 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
@@ -991,6 +1178,8 @@ process_record_result_dht(void* cls, | |||
991 | num_records = ntohl(nrb->rd_count); | 1178 | num_records = ntohl(nrb->rd_count); |
992 | { | 1179 | { |
993 | struct GNUNET_NAMESTORE_RecordData rd[num_records]; | 1180 | struct GNUNET_NAMESTORE_RecordData rd[num_records]; |
1181 | struct NamestoreBGTask *ns_heap_root; | ||
1182 | struct NamestoreBGTask *namestore_bg_task; | ||
994 | 1183 | ||
995 | rd_data += strlen(name) + 1 + sizeof(struct GNSNameRecordBlock); | 1184 | rd_data += strlen(name) + 1 + sizeof(struct GNSNameRecordBlock); |
996 | rd_size = size - strlen(name) - 1 - sizeof(struct GNSNameRecordBlock); | 1185 | rd_size = size - strlen(name) - 1 - sizeof(struct GNSNameRecordBlock); |
@@ -1032,9 +1221,20 @@ process_record_result_dht(void* cls, | |||
1032 | * FIXME check pubkey against existing key in namestore? | 1221 | * FIXME check pubkey against existing key in namestore? |
1033 | * https://gnunet.org/bugs/view.php?id=2179 | 1222 | * https://gnunet.org/bugs/view.php?id=2179 |
1034 | */ | 1223 | */ |
1224 | if (max_allowed_ns_tasks <= | ||
1225 | GNUNET_CONTAINER_heap_get_size (ns_task_heap)) | ||
1226 | { | ||
1227 | ns_heap_root = GNUNET_CONTAINER_heap_remove_root (ns_task_heap); | ||
1228 | GNUNET_NAMESTORE_cancel (ns_heap_root->qe); | ||
1035 | 1229 | ||
1230 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
1231 | "GNS_PHASE_REC-%d: Replacing oldest background ns task\n", | ||
1232 | rh->id); | ||
1233 | } | ||
1234 | |||
1036 | /* Save to namestore */ | 1235 | /* Save to namestore */ |
1037 | GNUNET_NAMESTORE_record_put (namestore_handle, | 1236 | namestore_bg_task = GNUNET_malloc (sizeof (struct NamestoreBGTask)); |
1237 | namestore_bg_task->qe = GNUNET_NAMESTORE_record_put (namestore_handle, | ||
1038 | &nrb->public_key, | 1238 | &nrb->public_key, |
1039 | name, | 1239 | name, |
1040 | exp, | 1240 | exp, |
@@ -1042,13 +1242,17 @@ process_record_result_dht(void* cls, | |||
1042 | rd, | 1242 | rd, |
1043 | &nrb->signature, | 1243 | &nrb->signature, |
1044 | &on_namestore_record_put_result, //cont | 1244 | &on_namestore_record_put_result, //cont |
1045 | NULL); //cls | 1245 | namestore_bg_task); |
1046 | 1246 | ||
1247 | namestore_bg_task->node = GNUNET_CONTAINER_heap_insert (ns_task_heap, | ||
1248 | namestore_bg_task, | ||
1249 | GNUNET_TIME_absolute_get().abs_value); | ||
1047 | 1250 | ||
1251 | |||
1048 | if (rh->answered) | 1252 | if (rh->answered) |
1049 | rh->proc(rh->proc_cls, rh, num_records, rd); | 1253 | rh->proc(rh->proc_cls, rh, num_records, rd); |
1050 | else | 1254 | else |
1051 | rh->proc(rh->proc_cls, rh, 0, NULL); | 1255 | rh->proc(rh->proc_cls, rh, 0, NULL); |
1052 | } | 1256 | } |
1053 | 1257 | ||
1054 | } | 1258 | } |
@@ -1177,6 +1381,8 @@ process_record_result_ns (void* cls, | |||
1177 | 1381 | ||
1178 | rh = (struct ResolverHandle *) cls; | 1382 | rh = (struct ResolverHandle *) cls; |
1179 | rlh = (struct RecordLookupHandle *)rh->proc_cls; | 1383 | rlh = (struct RecordLookupHandle *)rh->proc_cls; |
1384 | |||
1385 | rh->namestore_task = NULL; | ||
1180 | GNUNET_CRYPTO_short_hash(key, | 1386 | GNUNET_CRYPTO_short_hash(key, |
1181 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), | 1387 | sizeof(struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded), |
1182 | &zone); | 1388 | &zone); |
@@ -1336,19 +1542,7 @@ process_record_result_vpn (void* cls, int af, const void *address) | |||
1336 | } | 1542 | } |
1337 | 1543 | ||
1338 | 1544 | ||
1339 | /** | 1545 | |
1340 | * finish lookup | ||
1341 | * | ||
1342 | * @param rh resolver handle | ||
1343 | * @param rlh record lookup handle | ||
1344 | * @param rd_count number of results | ||
1345 | * @param rd results | ||
1346 | */ | ||
1347 | static void | ||
1348 | finish_lookup(struct ResolverHandle *rh, | ||
1349 | struct RecordLookupHandle* rlh, | ||
1350 | unsigned int rd_count, | ||
1351 | const struct GNUNET_NAMESTORE_RecordData *rd); | ||
1352 | 1546 | ||
1353 | /** | 1547 | /** |
1354 | * Process VPN lookup result for record | 1548 | * Process VPN lookup result for record |
@@ -1373,7 +1567,6 @@ handle_record_vpn (void* cls, struct ResolverHandle *rh, | |||
1373 | rh->status); | 1567 | rh->status); |
1374 | /* give up, cannot resolve */ | 1568 | /* give up, cannot resolve */ |
1375 | finish_lookup(rh, rlh, 0, NULL); | 1569 | finish_lookup(rh, rlh, 0, NULL); |
1376 | free_resolver_handle(rh); | ||
1377 | return; | 1570 | return; |
1378 | } | 1571 | } |
1379 | 1572 | ||
@@ -1382,8 +1575,6 @@ handle_record_vpn (void* cls, struct ResolverHandle *rh, | |||
1382 | "GNS_PHASE_REC_VPN-%d: Record resolved from VPN!", rh->id); | 1575 | "GNS_PHASE_REC_VPN-%d: Record resolved from VPN!", rh->id); |
1383 | 1576 | ||
1384 | finish_lookup(rh, rlh, rd_count, rd); | 1577 | finish_lookup(rh, rlh, rd_count, rd); |
1385 | |||
1386 | free_resolver_handle(rh); | ||
1387 | } | 1578 | } |
1388 | 1579 | ||
1389 | 1580 | ||
@@ -1412,7 +1603,6 @@ handle_dns_resolver (void *cls, | |||
1412 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 1603 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
1413 | "No address found in DNS!\n"); | 1604 | "No address found in DNS!\n"); |
1414 | finish_lookup (rh, rlh, 0, NULL); | 1605 | finish_lookup (rh, rlh, 0, NULL); |
1415 | free_resolver_handle (rh); | ||
1416 | return; | 1606 | return; |
1417 | } | 1607 | } |
1418 | 1608 | ||
@@ -1435,8 +1625,7 @@ handle_dns_resolver (void *cls, | |||
1435 | rd.flags = 0; | 1625 | rd.flags = 0; |
1436 | 1626 | ||
1437 | finish_lookup (rh, rlh, 1, &rd); | 1627 | finish_lookup (rh, rlh, 1, &rd); |
1438 | GNUNET_RESOLVER_request_cancel (rh->dns_resolver_handle); | 1628 | |
1439 | free_resolver_handle (rh); | ||
1440 | } | 1629 | } |
1441 | 1630 | ||
1442 | /** | 1631 | /** |
@@ -1456,7 +1645,6 @@ resolve_dns_name (struct ResolverHandle *rh) | |||
1456 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1645 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1457 | "Can only resolve A/AAAA via stub... abort\n"); | 1646 | "Can only resolve A/AAAA via stub... abort\n"); |
1458 | finish_lookup (rh, rlh, 0, NULL); | 1647 | finish_lookup (rh, rlh, 0, NULL); |
1459 | free_resolver_handle (rh); | ||
1460 | return; | 1648 | return; |
1461 | } | 1649 | } |
1462 | 1650 | ||
@@ -1506,8 +1694,6 @@ read_dns_response (void *cls, | |||
1506 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1694 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1507 | "Terminating DNS query %d\n", tc->reason); | 1695 | "Terminating DNS query %d\n", tc->reason); |
1508 | finish_lookup (rh, rlh, 0, NULL); | 1696 | finish_lookup (rh, rlh, 0, NULL); |
1509 | GNUNET_NETWORK_socket_close (rh->dns_sock); | ||
1510 | free_resolver_handle (rh); | ||
1511 | return; | 1697 | return; |
1512 | } | 1698 | } |
1513 | 1699 | ||
@@ -1521,8 +1707,6 @@ read_dns_response (void *cls, | |||
1521 | { | 1707 | { |
1522 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "recvfrom"); | 1708 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR, "recvfrom"); |
1523 | finish_lookup (rh, rlh, 0, NULL); | 1709 | finish_lookup (rh, rlh, 0, NULL); |
1524 | GNUNET_NETWORK_socket_close (rh->dns_sock); | ||
1525 | free_resolver_handle (rh); | ||
1526 | return; | 1710 | return; |
1527 | } | 1711 | } |
1528 | 1712 | ||
@@ -1533,8 +1717,6 @@ read_dns_response (void *cls, | |||
1533 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1717 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1534 | "Failed to parse DNS reply!\n"); | 1718 | "Failed to parse DNS reply!\n"); |
1535 | finish_lookup (rh, rlh, 0, NULL); | 1719 | finish_lookup (rh, rlh, 0, NULL); |
1536 | GNUNET_NETWORK_socket_close (rh->dns_sock); | ||
1537 | free_resolver_handle (rh); | ||
1538 | return; | 1720 | return; |
1539 | } | 1721 | } |
1540 | 1722 | ||
@@ -1569,9 +1751,7 @@ read_dns_response (void *cls, | |||
1569 | rd.flags = 0; | 1751 | rd.flags = 0; |
1570 | rd.expiration_time = packet->answers[i].expiration_time.abs_value; | 1752 | rd.expiration_time = packet->answers[i].expiration_time.abs_value; |
1571 | finish_lookup (rh, rlh, 1, &rd); | 1753 | finish_lookup (rh, rlh, 1, &rd); |
1572 | GNUNET_NETWORK_socket_close (rh->dns_sock); | ||
1573 | GNUNET_DNSPARSER_free_packet (packet); | 1754 | GNUNET_DNSPARSER_free_packet (packet); |
1574 | free_resolver_handle (rh); | ||
1575 | return; | 1755 | return; |
1576 | } | 1756 | } |
1577 | } | 1757 | } |
@@ -1636,8 +1816,6 @@ read_dns_response (void *cls, | |||
1636 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1816 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1637 | "Nothing useful in DNS reply!\n"); | 1817 | "Nothing useful in DNS reply!\n"); |
1638 | finish_lookup (rh, rlh, 0, NULL); | 1818 | finish_lookup (rh, rlh, 0, NULL); |
1639 | GNUNET_NETWORK_socket_close (rh->dns_sock); | ||
1640 | free_resolver_handle (rh); | ||
1641 | GNUNET_DNSPARSER_free_packet (packet); | 1819 | GNUNET_DNSPARSER_free_packet (packet); |
1642 | return; | 1820 | return; |
1643 | } | 1821 | } |
@@ -1742,7 +1920,6 @@ resolve_record_dns (struct ResolverHandle *rh, | |||
1742 | "GNS_PHASE_REC_DNS-%llu: Error creating udp socket for dns!\n", | 1920 | "GNS_PHASE_REC_DNS-%llu: Error creating udp socket for dns!\n", |
1743 | rh->id); | 1921 | rh->id); |
1744 | finish_lookup (rh, rlh, 0, NULL); | 1922 | finish_lookup (rh, rlh, 0, NULL); |
1745 | free_resolver_handle (rh); | ||
1746 | return; | 1923 | return; |
1747 | } | 1924 | } |
1748 | 1925 | ||
@@ -1756,9 +1933,7 @@ resolve_record_dns (struct ResolverHandle *rh, | |||
1756 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 1933 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
1757 | "GNS_PHASE_REC_DNS-%llu: Error binding udp socket for dns!\n", | 1934 | "GNS_PHASE_REC_DNS-%llu: Error binding udp socket for dns!\n", |
1758 | rh->id); | 1935 | rh->id); |
1759 | GNUNET_NETWORK_socket_close (rh->dns_sock); | ||
1760 | finish_lookup (rh, rlh, 0, NULL); | 1936 | finish_lookup (rh, rlh, 0, NULL); |
1761 | free_resolver_handle (rh); | ||
1762 | return; | 1937 | return; |
1763 | } | 1938 | } |
1764 | 1939 | ||
@@ -1788,7 +1963,6 @@ resolve_record_dns (struct ResolverHandle *rh, | |||
1788 | rh->id); | 1963 | rh->id); |
1789 | GNUNET_NETWORK_socket_close (rh->dns_sock); | 1964 | GNUNET_NETWORK_socket_close (rh->dns_sock); |
1790 | finish_lookup (rh, rlh, 0, NULL); | 1965 | finish_lookup (rh, rlh, 0, NULL); |
1791 | free_resolver_handle (rh); | ||
1792 | return; | 1966 | return; |
1793 | } | 1967 | } |
1794 | 1968 | ||
@@ -1862,7 +2036,6 @@ resolve_record_vpn (struct ResolverHandle *rh, | |||
1862 | "GNS_PHASE_REC_VPN-%llu: VPN not connected!\n", | 2036 | "GNS_PHASE_REC_VPN-%llu: VPN not connected!\n", |
1863 | rh->id); | 2037 | rh->id); |
1864 | finish_lookup (rh, rh->proc_cls, 0, NULL); | 2038 | finish_lookup (rh, rh->proc_cls, 0, NULL); |
1865 | free_resolver_handle (rh); | ||
1866 | return; | 2039 | return; |
1867 | } | 2040 | } |
1868 | 2041 | ||
@@ -1917,7 +2090,7 @@ resolve_record_ns(struct ResolverHandle *rh) | |||
1917 | * since we tried to resolve it to an authority | 2090 | * since we tried to resolve it to an authority |
1918 | * and failed. | 2091 | * and failed. |
1919 | **/ | 2092 | **/ |
1920 | GNUNET_NAMESTORE_lookup_record(namestore_handle, | 2093 | rh->namestore_task = GNUNET_NAMESTORE_lookup_record(namestore_handle, |
1921 | &rh->authority, | 2094 | &rh->authority, |
1922 | rh->name, | 2095 | rh->name, |
1923 | rlh->record_type, | 2096 | rlh->record_type, |
@@ -2044,6 +2217,7 @@ process_pkey_revocation_result_ns (void *cls, | |||
2044 | struct GNUNET_TIME_Relative remaining_time; | 2217 | struct GNUNET_TIME_Relative remaining_time; |
2045 | int i; | 2218 | int i; |
2046 | 2219 | ||
2220 | rh->namestore_task = NULL; | ||
2047 | remaining_time = GNUNET_TIME_absolute_get_remaining (expiration); | 2221 | remaining_time = GNUNET_TIME_absolute_get_remaining (expiration); |
2048 | 2222 | ||
2049 | for (i = 0; i < rd_count; i++) | 2223 | for (i = 0; i < rd_count; i++) |
@@ -2099,6 +2273,40 @@ process_pkey_revocation_result_ns (void *cls, | |||
2099 | 2273 | ||
2100 | 2274 | ||
2101 | /** | 2275 | /** |
2276 | * Callback when record data is put into namestore | ||
2277 | * | ||
2278 | * @param cls the closure | ||
2279 | * @param success GNUNET_OK on success | ||
2280 | * @param emsg the error message. NULL if SUCCESS==GNUNET_OK | ||
2281 | */ | ||
2282 | void | ||
2283 | on_namestore_delegation_put_result(void *cls, | ||
2284 | int32_t success, | ||
2285 | const char *emsg) | ||
2286 | { | ||
2287 | struct NamestoreBGTask *nbg = cls; | ||
2288 | |||
2289 | GNUNET_CONTAINER_heap_remove_node (nbg->node); | ||
2290 | GNUNET_free (nbg); | ||
2291 | |||
2292 | if (GNUNET_NO == success) | ||
2293 | { | ||
2294 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2295 | "GNS_NS: records already in namestore\n"); | ||
2296 | return; | ||
2297 | } | ||
2298 | else if (GNUNET_YES == success) | ||
2299 | { | ||
2300 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2301 | "GNS_NS: records successfully put in namestore\n"); | ||
2302 | return; | ||
2303 | } | ||
2304 | |||
2305 | GNUNET_log(GNUNET_ERROR_TYPE_ERROR, | ||
2306 | "GNS_NS: Error putting records into namestore: %s\n", emsg); | ||
2307 | } | ||
2308 | |||
2309 | /** | ||
2102 | * Function called when we get a result from the dht | 2310 | * Function called when we get a result from the dht |
2103 | * for our query. Recursively tries to resolve authorities | 2311 | * for our query. Recursively tries to resolve authorities |
2104 | * for name in DHT. | 2312 | * for name in DHT. |
@@ -2160,6 +2368,8 @@ process_delegation_result_dht(void* cls, | |||
2160 | name = (char*)&nrb[1]; | 2368 | name = (char*)&nrb[1]; |
2161 | { | 2369 | { |
2162 | struct GNUNET_NAMESTORE_RecordData rd[num_records]; | 2370 | struct GNUNET_NAMESTORE_RecordData rd[num_records]; |
2371 | struct NamestoreBGTask *ns_heap_root; | ||
2372 | struct NamestoreBGTask *namestore_bg_task; | ||
2163 | 2373 | ||
2164 | rd_data += strlen(name) + 1 + sizeof(struct GNSNameRecordBlock); | 2374 | rd_data += strlen(name) + 1 + sizeof(struct GNSNameRecordBlock); |
2165 | rd_size = size - strlen(name) - 1 - sizeof(struct GNSNameRecordBlock); | 2375 | rd_size = size - strlen(name) - 1 - sizeof(struct GNSNameRecordBlock); |
@@ -2246,18 +2456,34 @@ process_delegation_result_dht(void* cls, | |||
2246 | if (0 != GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_tail->zone, | 2456 | if (0 != GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_tail->zone, |
2247 | &zone)) | 2457 | &zone)) |
2248 | { | 2458 | { |
2249 | GNUNET_NAMESTORE_record_put (namestore_handle, | 2459 | if (max_allowed_ns_tasks <= |
2460 | GNUNET_CONTAINER_heap_get_size (ns_task_heap)) | ||
2461 | { | ||
2462 | ns_heap_root = GNUNET_CONTAINER_heap_remove_root (ns_task_heap); | ||
2463 | GNUNET_NAMESTORE_cancel (ns_heap_root->qe); | ||
2464 | |||
2465 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
2466 | "GNS_PHASE_REC-%d: Replacing oldest background ns task\n", | ||
2467 | rh->id); | ||
2468 | } | ||
2469 | |||
2470 | namestore_bg_task = GNUNET_malloc (sizeof (struct NamestoreBGTask)); | ||
2471 | |||
2472 | namestore_bg_task->node = GNUNET_CONTAINER_heap_insert (ns_task_heap, | ||
2473 | namestore_bg_task, | ||
2474 | GNUNET_TIME_absolute_get().abs_value); | ||
2475 | namestore_bg_task->qe = GNUNET_NAMESTORE_record_put (namestore_handle, | ||
2250 | &nrb->public_key, | 2476 | &nrb->public_key, |
2251 | name, | 2477 | name, |
2252 | exp, | 2478 | exp, |
2253 | num_records, | 2479 | num_records, |
2254 | rd, | 2480 | rd, |
2255 | &nrb->signature, | 2481 | &nrb->signature, |
2256 | &on_namestore_record_put_result, //cont | 2482 | &on_namestore_delegation_put_result, //cont |
2257 | NULL); //cls | 2483 | namestore_bg_task); //cls |
2258 | } | 2484 | } |
2259 | } | 2485 | } |
2260 | 2486 | ||
2261 | if (rh->answered) | 2487 | if (rh->answered) |
2262 | { | 2488 | { |
2263 | rh->answered = 0; | 2489 | rh->answered = 0; |
@@ -2266,8 +2492,8 @@ process_delegation_result_dht(void* cls, | |||
2266 | * FIXME in this case. should we ask namestore again? | 2492 | * FIXME in this case. should we ask namestore again? |
2267 | */ | 2493 | */ |
2268 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2494 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2269 | "GNS_PHASE_DELEGATE_DHT-%llu: Answer from DHT for %s. Yet to resolve: %s\n", | 2495 | "GNS_PHASE_DELEGATE_DHT-%llu: Answer from DHT for %s. Yet to resolve: %s\n", |
2270 | rh->id, rh->authority_name, rh->name); | 2496 | rh->id, rh->authority_name, rh->name); |
2271 | 2497 | ||
2272 | if (strcmp(rh->name, "") == 0) | 2498 | if (strcmp(rh->name, "") == 0) |
2273 | { | 2499 | { |
@@ -2285,32 +2511,13 @@ process_delegation_result_dht(void* cls, | |||
2285 | rh->proc = &handle_delegation_ns; | 2511 | rh->proc = &handle_delegation_ns; |
2286 | 2512 | ||
2287 | /* Check for key revocation and delegate */ | 2513 | /* Check for key revocation and delegate */ |
2288 | GNUNET_NAMESTORE_lookup_record (namestore_handle, | 2514 | rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, |
2289 | &rh->authority, | 2515 | &rh->authority, |
2290 | "+", | 2516 | "+", |
2291 | GNUNET_GNS_RECORD_REV, | 2517 | GNUNET_GNS_RECORD_REV, |
2292 | &process_pkey_revocation_result_ns, | 2518 | &process_pkey_revocation_result_ns, |
2293 | rh); | 2519 | rh); |
2294 | 2520 | ||
2295 | /*if (strcmp(rh->name, "") == 0) | ||
2296 | { | ||
2297 | if ((rh->priv_key != NULL) && is_canonical (rh->name)) | ||
2298 | { | ||
2299 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
2300 | "GNS_PHASE_DELEGATE_DHT-%llu: Trying to shorten authority chain\n", | ||
2301 | rh->id); | ||
2302 | start_shorten (rh->authority_chain_tail, | ||
2303 | rh->priv_key); | ||
2304 | } | ||
2305 | |||
2306 | rh->proc(rh->proc_cls, rh, 0, NULL); | ||
2307 | } | ||
2308 | else | ||
2309 | { | ||
2310 | rh->proc = &handle_delegation_ns; | ||
2311 | resolve_delegation_ns (rh); | ||
2312 | } | ||
2313 | */ | ||
2314 | return; | 2521 | return; |
2315 | } | 2522 | } |
2316 | 2523 | ||
@@ -2330,7 +2537,7 @@ process_delegation_result_dht(void* cls, | |||
2330 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2537 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2331 | "GNS_PHASE_DELEGATE_DHT-%llu: %s restored\n", rh->id, rh->name); | 2538 | "GNS_PHASE_DELEGATE_DHT-%llu: %s restored\n", rh->id, rh->name); |
2332 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2539 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2333 | "GNS_PHASE_DELEGATE_DHT-%llu: DHT authority lookup found no match!\n", | 2540 | "GNS_PHASE_DELEGATE_DHT-%llu: DHT authority lookup found no match!\n", |
2334 | rh->id); | 2541 | rh->id); |
2335 | rh->proc(rh->proc_cls, rh, 0, NULL); | 2542 | rh->proc(rh->proc_cls, rh, 0, NULL); |
2336 | } | 2543 | } |
@@ -2382,10 +2589,10 @@ expand_plus(char* dest, char* src, char* repl) | |||
2382 | * finish lookup | 2589 | * finish lookup |
2383 | */ | 2590 | */ |
2384 | static void | 2591 | static void |
2385 | finish_lookup(struct ResolverHandle *rh, | 2592 | finish_lookup (struct ResolverHandle *rh, |
2386 | struct RecordLookupHandle* rlh, | 2593 | struct RecordLookupHandle* rlh, |
2387 | unsigned int rd_count, | 2594 | unsigned int rd_count, |
2388 | const struct GNUNET_NAMESTORE_RecordData *rd) | 2595 | const struct GNUNET_NAMESTORE_RecordData *rd) |
2389 | { | 2596 | { |
2390 | int i; | 2597 | int i; |
2391 | char new_rr_data[MAX_DNS_NAME_LENGTH]; | 2598 | char new_rr_data[MAX_DNS_NAME_LENGTH]; |
@@ -2407,6 +2614,8 @@ finish_lookup(struct ResolverHandle *rh, | |||
2407 | rh->timeout_task = GNUNET_SCHEDULER_NO_TASK; | 2614 | rh->timeout_task = GNUNET_SCHEDULER_NO_TASK; |
2408 | } | 2615 | } |
2409 | 2616 | ||
2617 | GNUNET_CONTAINER_DLL_remove (rlh_head, rlh_tail, rh); | ||
2618 | |||
2410 | if (rd_count > 0) | 2619 | if (rd_count > 0) |
2411 | memcpy(p_rd, rd, rd_count*sizeof(struct GNUNET_NAMESTORE_RecordData)); | 2620 | memcpy(p_rd, rd, rd_count*sizeof(struct GNUNET_NAMESTORE_RecordData)); |
2412 | 2621 | ||
@@ -2492,7 +2701,7 @@ finish_lookup(struct ResolverHandle *rh, | |||
2492 | 2701 | ||
2493 | rlh->proc(rlh->proc_cls, rd_count, p_rd); | 2702 | rlh->proc(rlh->proc_cls, rd_count, p_rd); |
2494 | GNUNET_free(rlh); | 2703 | GNUNET_free(rlh); |
2495 | 2704 | free_resolver_handle (rh); | |
2496 | } | 2705 | } |
2497 | 2706 | ||
2498 | /** | 2707 | /** |
@@ -2518,7 +2727,6 @@ handle_record_dht(void* cls, struct ResolverHandle *rh, | |||
2518 | rh->id, rh->name); | 2727 | rh->id, rh->name); |
2519 | /* give up, cannot resolve */ | 2728 | /* give up, cannot resolve */ |
2520 | finish_lookup(rh, rlh, 0, NULL); | 2729 | finish_lookup(rh, rlh, 0, NULL); |
2521 | free_resolver_handle(rh); | ||
2522 | return; | 2730 | return; |
2523 | } | 2731 | } |
2524 | 2732 | ||
@@ -2527,7 +2735,6 @@ handle_record_dht(void* cls, struct ResolverHandle *rh, | |||
2527 | "GNS_PHASE_REC-%d: Record resolved from DHT!", rh->id); | 2735 | "GNS_PHASE_REC-%d: Record resolved from DHT!", rh->id); |
2528 | 2736 | ||
2529 | finish_lookup(rh, rlh, rd_count, rd); | 2737 | finish_lookup(rh, rlh, rd_count, rd); |
2530 | free_resolver_handle(rh); | ||
2531 | 2738 | ||
2532 | } | 2739 | } |
2533 | 2740 | ||
@@ -2592,17 +2799,15 @@ handle_record_ns (void* cls, struct ResolverHandle *rh, | |||
2592 | } | 2799 | } |
2593 | /* give up, cannot resolve */ | 2800 | /* give up, cannot resolve */ |
2594 | finish_lookup(rh, rlh, 0, NULL); | 2801 | finish_lookup(rh, rlh, 0, NULL); |
2595 | free_resolver_handle(rh); | ||
2596 | return; | 2802 | return; |
2597 | } | 2803 | } |
2598 | 2804 | ||
2599 | /* results found yay */ | 2805 | /* results found yay */ |
2600 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2806 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
2601 | "GNS_PHASE_REC-%d: Record resolved from namestore!", rh->id); | 2807 | "GNS_PHASE_REC-%d: Record resolved from namestore!\n", rh->id); |
2602 | 2808 | ||
2603 | finish_lookup(rh, rlh, rd_count, rd); | 2809 | finish_lookup(rh, rlh, rd_count, rd); |
2604 | 2810 | ||
2605 | free_resolver_handle(rh); | ||
2606 | 2811 | ||
2607 | } | 2812 | } |
2608 | 2813 | ||
@@ -2693,7 +2898,6 @@ handle_delegation_dht(void* cls, struct ResolverHandle *rh, | |||
2693 | "GNS_PHASE_DELEGATE_DHT-%llu: Resolved queried PKEY via DHT.\n", | 2898 | "GNS_PHASE_DELEGATE_DHT-%llu: Resolved queried PKEY via DHT.\n", |
2694 | rh->id); | 2899 | rh->id); |
2695 | finish_lookup(rh, rlh, rd_count, rd); | 2900 | finish_lookup(rh, rlh, rd_count, rd); |
2696 | free_resolver_handle(rh); | ||
2697 | return; | 2901 | return; |
2698 | } | 2902 | } |
2699 | /* We resolved full name for delegation. resolving record */ | 2903 | /* We resolved full name for delegation. resolving record */ |
@@ -2724,7 +2928,6 @@ handle_delegation_dht(void* cls, struct ResolverHandle *rh, | |||
2724 | "GNS_PHASE_DELEGATE_DHT-%llu: Cannot fully resolve delegation for %s via DHT!\n", | 2928 | "GNS_PHASE_DELEGATE_DHT-%llu: Cannot fully resolve delegation for %s via DHT!\n", |
2725 | rh->id, rh->name); | 2929 | rh->id, rh->name); |
2726 | finish_lookup(rh, rlh, 0, NULL); | 2930 | finish_lookup(rh, rlh, 0, NULL); |
2727 | free_resolver_handle(rh); | ||
2728 | } | 2931 | } |
2729 | 2932 | ||
2730 | 2933 | ||
@@ -2769,7 +2972,8 @@ resolve_delegation_dht(struct ResolverHandle *rh) | |||
2769 | { | 2972 | { |
2770 | /* terminate oldest lookup */ | 2973 | /* terminate oldest lookup */ |
2771 | rh_heap_root = GNUNET_CONTAINER_heap_remove_root (dht_lookup_heap); | 2974 | rh_heap_root = GNUNET_CONTAINER_heap_remove_root (dht_lookup_heap); |
2772 | GNUNET_DHT_get_stop(rh_heap_root->get_handle); | 2975 | GNUNET_DHT_get_stop (rh_heap_root->get_handle); |
2976 | rh_heap_root->get_handle = NULL; | ||
2773 | rh_heap_root->dht_heap_node = NULL; | 2977 | rh_heap_root->dht_heap_node = NULL; |
2774 | 2978 | ||
2775 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 2979 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
@@ -2827,7 +3031,6 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh, | |||
2827 | if (rh->status & RSL_PKEY_REVOKED) | 3031 | if (rh->status & RSL_PKEY_REVOKED) |
2828 | { | 3032 | { |
2829 | finish_lookup (rh, rlh, 0, NULL); | 3033 | finish_lookup (rh, rlh, 0, NULL); |
2830 | free_resolver_handle (rh); | ||
2831 | return; | 3034 | return; |
2832 | } | 3035 | } |
2833 | 3036 | ||
@@ -2847,7 +3050,6 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh, | |||
2847 | rh->id); | 3050 | rh->id); |
2848 | strcpy (rh->name, rh->authority_name); | 3051 | strcpy (rh->name, rh->authority_name); |
2849 | finish_lookup (rh, rlh, rd_count, rd); | 3052 | finish_lookup (rh, rlh, rd_count, rd); |
2850 | free_resolver_handle (rh); | ||
2851 | return; | 3053 | return; |
2852 | } | 3054 | } |
2853 | 3055 | ||
@@ -2872,6 +3074,7 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh, | |||
2872 | rlh->proc, | 3074 | rlh->proc, |
2873 | rlh->proc_cls); | 3075 | rlh->proc_cls); |
2874 | GNUNET_free (rlh); | 3076 | GNUNET_free (rlh); |
3077 | GNUNET_CONTAINER_DLL_remove (rlh_head, rlh_tail, rh); | ||
2875 | free_resolver_handle (rh); | 3078 | free_resolver_handle (rh); |
2876 | return; | 3079 | return; |
2877 | } | 3080 | } |
@@ -2892,7 +3095,6 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh, | |||
2892 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried VPNRR in NS.\n", | 3095 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried VPNRR in NS.\n", |
2893 | rh->id); | 3096 | rh->id); |
2894 | finish_lookup(rh, rlh, rd_count, rd); | 3097 | finish_lookup(rh, rlh, rd_count, rd); |
2895 | free_resolver_handle(rh); | ||
2896 | return; | 3098 | return; |
2897 | } | 3099 | } |
2898 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3100 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
@@ -2911,7 +3113,6 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh, | |||
2911 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried NSRR in NS.\n", | 3113 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried NSRR in NS.\n", |
2912 | rh->id); | 3114 | rh->id); |
2913 | finish_lookup(rh, rlh, rd_count, rd); | 3115 | finish_lookup(rh, rlh, rd_count, rd); |
2914 | free_resolver_handle(rh); | ||
2915 | return; | 3116 | return; |
2916 | } | 3117 | } |
2917 | 3118 | ||
@@ -2931,7 +3132,6 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh, | |||
2931 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved PKEY is revoked.\n", | 3132 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved PKEY is revoked.\n", |
2932 | rh->id); | 3133 | rh->id); |
2933 | finish_lookup (rh, rlh, 0, NULL); | 3134 | finish_lookup (rh, rlh, 0, NULL); |
2934 | free_resolver_handle (rh); | ||
2935 | return; | 3135 | return; |
2936 | } | 3136 | } |
2937 | else if (rlh->record_type == GNUNET_GNS_RECORD_PKEY) | 3137 | else if (rlh->record_type == GNUNET_GNS_RECORD_PKEY) |
@@ -2941,7 +3141,6 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh, | |||
2941 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried PKEY in NS.\n", | 3141 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried PKEY in NS.\n", |
2942 | rh->id); | 3142 | rh->id); |
2943 | finish_lookup(rh, rlh, rd_count, rd); | 3143 | finish_lookup(rh, rlh, rd_count, rd); |
2944 | free_resolver_handle(rh); | ||
2945 | return; | 3144 | return; |
2946 | } | 3145 | } |
2947 | } | 3146 | } |
@@ -2962,7 +3161,6 @@ handle_delegation_ns (void* cls, struct ResolverHandle *rh, | |||
2962 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried NSRR in NS.\n", | 3161 | "GNS_PHASE_DELEGATE_NS-%llu: Resolved queried NSRR in NS.\n", |
2963 | rh->id); | 3162 | rh->id); |
2964 | finish_lookup(rh, rlh, rd_count, rd); | 3163 | finish_lookup(rh, rlh, rd_count, rd); |
2965 | free_resolver_handle(rh); | ||
2966 | return; | 3164 | return; |
2967 | } | 3165 | } |
2968 | 3166 | ||
@@ -3055,7 +3253,8 @@ process_delegation_result_ns (void* cls, | |||
3055 | unsigned int i; | 3253 | unsigned int i; |
3056 | struct GNUNET_TIME_Absolute et; | 3254 | struct GNUNET_TIME_Absolute et; |
3057 | 3255 | ||
3058 | rh = (struct ResolverHandle *)cls; | 3256 | rh = (struct ResolverHandle *)cls; |
3257 | rh->namestore_task = NULL; | ||
3059 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3258 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
3060 | "GNS_PHASE_DELEGATE_NS-%llu: Got %d records from authority lookup\n", | 3259 | "GNS_PHASE_DELEGATE_NS-%llu: Got %d records from authority lookup\n", |
3061 | rh->id, rd_count); | 3260 | rh->id, rd_count); |
@@ -3224,7 +3423,7 @@ process_delegation_result_ns (void* cls, | |||
3224 | auth); | 3423 | auth); |
3225 | 3424 | ||
3226 | /* Check for key revocation and delegate */ | 3425 | /* Check for key revocation and delegate */ |
3227 | GNUNET_NAMESTORE_lookup_record (namestore_handle, | 3426 | rh->namestore_task = GNUNET_NAMESTORE_lookup_record (namestore_handle, |
3228 | &rh->authority, | 3427 | &rh->authority, |
3229 | "+", | 3428 | "+", |
3230 | GNUNET_GNS_RECORD_REV, | 3429 | GNUNET_GNS_RECORD_REV, |
@@ -3280,7 +3479,7 @@ resolve_delegation_ns (struct ResolverHandle *rh) | |||
3280 | "GNS_PHASE_DELEGATE_NS-%llu: Resolving delegation for %s\n", | 3479 | "GNS_PHASE_DELEGATE_NS-%llu: Resolving delegation for %s\n", |
3281 | rh->id, rh->name); | 3480 | rh->id, rh->name); |
3282 | pop_tld(rh->name, rh->authority_name); | 3481 | pop_tld(rh->name, rh->authority_name); |
3283 | GNUNET_NAMESTORE_lookup_record(namestore_handle, | 3482 | rh->namestore_task = GNUNET_NAMESTORE_lookup_record(namestore_handle, |
3284 | &rh->authority, | 3483 | &rh->authority, |
3285 | rh->authority_name, | 3484 | rh->authority_name, |
3286 | GNUNET_GNS_RECORD_ANY, | 3485 | GNUNET_GNS_RECORD_ANY, |
@@ -3334,9 +3533,10 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
3334 | return; | 3533 | return; |
3335 | } | 3534 | } |
3336 | 3535 | ||
3337 | rlh = GNUNET_malloc(sizeof(struct RecordLookupHandle)); | 3536 | rlh = GNUNET_malloc (sizeof(struct RecordLookupHandle)); |
3338 | rh = GNUNET_malloc(sizeof (struct ResolverHandle)); | 3537 | rh = GNUNET_malloc (sizeof (struct ResolverHandle)); |
3339 | 3538 | ||
3539 | memset (rh, 0, sizeof (struct ResolverHandle)); | ||
3340 | rh->authority = zone; | 3540 | rh->authority = zone; |
3341 | rh->id = rid++; | 3541 | rh->id = rid++; |
3342 | rh->proc_cls = rlh; | 3542 | rh->proc_cls = rlh; |
@@ -3345,6 +3545,9 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
3345 | rh->get_handle = NULL; | 3545 | rh->get_handle = NULL; |
3346 | rh->private_local_zone = pzone; | 3546 | rh->private_local_zone = pzone; |
3347 | rh->only_cached = only_cached; | 3547 | rh->only_cached = only_cached; |
3548 | rh->namestore_task = NULL; | ||
3549 | |||
3550 | GNUNET_CONTAINER_DLL_insert (rlh_head, rlh_tail, rh); | ||
3348 | 3551 | ||
3349 | if (NULL == key) | 3552 | if (NULL == key) |
3350 | { | 3553 | { |
@@ -3407,9 +3610,11 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
3407 | { | 3610 | { |
3408 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 3611 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
3409 | "Cannot convert ZKEY %s to hash!\n", string_hash); | 3612 | "Cannot convert ZKEY %s to hash!\n", string_hash); |
3410 | GNUNET_free(rh); | 3613 | |
3411 | GNUNET_free(rlh); | 3614 | GNUNET_CONTAINER_DLL_remove (rlh_head, rlh_tail, rh); |
3412 | proc(cls, 0, NULL); | 3615 | GNUNET_free (rh); |
3616 | GNUNET_free (rlh); | ||
3617 | proc (cls, 0, NULL); | ||
3413 | return; | 3618 | return; |
3414 | } | 3619 | } |
3415 | 3620 | ||
@@ -3421,10 +3626,10 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
3421 | /** | 3626 | /** |
3422 | * Presumably GNUNET tld | 3627 | * Presumably GNUNET tld |
3423 | */ | 3628 | */ |
3424 | memset(rh->name, 0, | 3629 | memset (rh->name, 0, |
3425 | strlen(name)-strlen(GNUNET_GNS_TLD)); | 3630 | strlen(name)-strlen(GNUNET_GNS_TLD)); |
3426 | memcpy(rh->name, name, | 3631 | memcpy (rh->name, name, |
3427 | strlen(name)-strlen(GNUNET_GNS_TLD) - 1); | 3632 | strlen(name)-strlen(GNUNET_GNS_TLD) - 1); |
3428 | } | 3633 | } |
3429 | } | 3634 | } |
3430 | 3635 | ||
@@ -3452,6 +3657,19 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone, | |||
3452 | 3657 | ||
3453 | /******** END Record Resolver ***********/ | 3658 | /******** END Record Resolver ***********/ |
3454 | 3659 | ||
3660 | static void | ||
3661 | finish_shorten (struct ResolverHandle *rh, | ||
3662 | struct NameShortenHandle *nsh) | ||
3663 | { | ||
3664 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
3665 | "Sending %s as shorten result\n", nsh->result); | ||
3666 | nsh->proc (nsh->proc_cls, nsh->result); | ||
3667 | GNUNET_CONTAINER_DLL_remove (nsh_head, nsh_tail, rh); | ||
3668 | GNUNET_free (nsh); | ||
3669 | free_resolver_handle (rh); | ||
3670 | } | ||
3671 | |||
3672 | |||
3455 | /** | 3673 | /** |
3456 | * Callback calles by namestore for a zone to name | 3674 | * Callback calles by namestore for a zone to name |
3457 | * result | 3675 | * result |
@@ -3503,6 +3721,7 @@ process_zone_to_name_shorten_shorten (void *cls, | |||
3503 | char tmp_name[MAX_DNS_NAME_LENGTH]; | 3721 | char tmp_name[MAX_DNS_NAME_LENGTH]; |
3504 | size_t answer_len; | 3722 | size_t answer_len; |
3505 | 3723 | ||
3724 | rh->namestore_task = NULL; | ||
3506 | /* we found a match in our own root zone */ | 3725 | /* we found a match in our own root zone */ |
3507 | if (rd_len != 0) | 3726 | if (rd_len != 0) |
3508 | { | 3727 | { |
@@ -3561,11 +3780,7 @@ process_zone_to_name_shorten_shorten (void *cls, | |||
3561 | */ | 3780 | */ |
3562 | if ((rh->authority_chain_head->next == NULL)) | 3781 | if ((rh->authority_chain_head->next == NULL)) |
3563 | { | 3782 | { |
3564 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 3783 | finish_shorten (rh, nsh); |
3565 | "Sending %s as shorten result\n", nsh->result); | ||
3566 | nsh->proc(nsh->proc_cls, nsh->result); | ||
3567 | GNUNET_free (nsh); | ||
3568 | free_resolver_handle (rh); | ||
3569 | return; | 3784 | return; |
3570 | } | 3785 | } |
3571 | next_authority = rh->authority_chain_head; | 3786 | next_authority = rh->authority_chain_head; |
@@ -3582,7 +3797,9 @@ process_zone_to_name_shorten_shorten (void *cls, | |||
3582 | rh->authority_chain_tail, | 3797 | rh->authority_chain_tail, |
3583 | next_authority); | 3798 | next_authority); |
3584 | 3799 | ||
3585 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | 3800 | GNUNET_free (next_authority); |
3801 | |||
3802 | rh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, | ||
3586 | &rh->authority_chain_tail->zone, | 3803 | &rh->authority_chain_tail->zone, |
3587 | &rh->authority_chain_head->zone, | 3804 | &rh->authority_chain_head->zone, |
3588 | &process_zone_to_name_shorten_root, | 3805 | &process_zone_to_name_shorten_root, |
@@ -3618,6 +3835,7 @@ process_zone_to_name_shorten_private (void *cls, | |||
3618 | char tmp_name[MAX_DNS_NAME_LENGTH]; | 3835 | char tmp_name[MAX_DNS_NAME_LENGTH]; |
3619 | size_t answer_len; | 3836 | size_t answer_len; |
3620 | 3837 | ||
3838 | rh->namestore_task = NULL; | ||
3621 | /* we found a match in our own root zone */ | 3839 | /* we found a match in our own root zone */ |
3622 | if (rd_len != 0) | 3840 | if (rd_len != 0) |
3623 | { | 3841 | { |
@@ -3660,7 +3878,7 @@ process_zone_to_name_shorten_private (void *cls, | |||
3660 | if (nsh->shorten_zone != NULL) | 3878 | if (nsh->shorten_zone != NULL) |
3661 | { | 3879 | { |
3662 | /* backtrack authorities for names in priv zone */ | 3880 | /* backtrack authorities for names in priv zone */ |
3663 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | 3881 | rh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, |
3664 | nsh->shorten_zone, | 3882 | nsh->shorten_zone, |
3665 | &rh->authority_chain_head->zone, | 3883 | &rh->authority_chain_head->zone, |
3666 | &process_zone_to_name_shorten_shorten, | 3884 | &process_zone_to_name_shorten_shorten, |
@@ -3674,11 +3892,7 @@ process_zone_to_name_shorten_private (void *cls, | |||
3674 | */ | 3892 | */ |
3675 | if ((rh->authority_chain_head->next == NULL)) | 3893 | if ((rh->authority_chain_head->next == NULL)) |
3676 | { | 3894 | { |
3677 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 3895 | finish_shorten (rh, nsh); |
3678 | "Sending %s as shorten result\n", nsh->result); | ||
3679 | nsh->proc(nsh->proc_cls, nsh->result); | ||
3680 | GNUNET_free(nsh); | ||
3681 | free_resolver_handle(rh); | ||
3682 | return; | 3896 | return; |
3683 | } | 3897 | } |
3684 | next_authority = rh->authority_chain_head; | 3898 | next_authority = rh->authority_chain_head; |
@@ -3695,7 +3909,9 @@ process_zone_to_name_shorten_private (void *cls, | |||
3695 | rh->authority_chain_tail, | 3909 | rh->authority_chain_tail, |
3696 | next_authority); | 3910 | next_authority); |
3697 | 3911 | ||
3698 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | 3912 | GNUNET_free (next_authority); |
3913 | |||
3914 | rh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, | ||
3699 | &rh->authority_chain_tail->zone, | 3915 | &rh->authority_chain_tail->zone, |
3700 | &rh->authority_chain_head->zone, | 3916 | &rh->authority_chain_head->zone, |
3701 | &process_zone_to_name_shorten_root, | 3917 | &process_zone_to_name_shorten_root, |
@@ -3732,6 +3948,7 @@ process_zone_to_name_shorten_root (void *cls, | |||
3732 | char tmp_name[MAX_DNS_NAME_LENGTH]; | 3948 | char tmp_name[MAX_DNS_NAME_LENGTH]; |
3733 | size_t answer_len; | 3949 | size_t answer_len; |
3734 | 3950 | ||
3951 | rh->namestore_task = NULL; | ||
3735 | /* we found a match in our own root zone */ | 3952 | /* we found a match in our own root zone */ |
3736 | if (rd_len != 0) | 3953 | if (rd_len != 0) |
3737 | { | 3954 | { |
@@ -3773,7 +3990,7 @@ process_zone_to_name_shorten_root (void *cls, | |||
3773 | if (nsh->private_zone != NULL) | 3990 | if (nsh->private_zone != NULL) |
3774 | { | 3991 | { |
3775 | /* backtrack authorities for names in priv zone */ | 3992 | /* backtrack authorities for names in priv zone */ |
3776 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | 3993 | rh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, |
3777 | nsh->private_zone, | 3994 | nsh->private_zone, |
3778 | &rh->authority_chain_head->zone, | 3995 | &rh->authority_chain_head->zone, |
3779 | &process_zone_to_name_shorten_private, | 3996 | &process_zone_to_name_shorten_private, |
@@ -3787,11 +4004,7 @@ process_zone_to_name_shorten_root (void *cls, | |||
3787 | */ | 4004 | */ |
3788 | if ((rh->authority_chain_head->next == NULL)) | 4005 | if ((rh->authority_chain_head->next == NULL)) |
3789 | { | 4006 | { |
3790 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4007 | finish_shorten (rh, nsh); |
3791 | "Sending %s as shorten result\n", nsh->result); | ||
3792 | nsh->proc(nsh->proc_cls, nsh->result); | ||
3793 | GNUNET_free(nsh); | ||
3794 | free_resolver_handle(rh); | ||
3795 | return; | 4008 | return; |
3796 | } | 4009 | } |
3797 | next_authority = rh->authority_chain_head; | 4010 | next_authority = rh->authority_chain_head; |
@@ -3808,7 +4021,9 @@ process_zone_to_name_shorten_root (void *cls, | |||
3808 | rh->authority_chain_tail, | 4021 | rh->authority_chain_tail, |
3809 | next_authority); | 4022 | next_authority); |
3810 | 4023 | ||
3811 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | 4024 | GNUNET_free (next_authority); |
4025 | |||
4026 | rh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, | ||
3812 | &rh->authority_chain_tail->zone, | 4027 | &rh->authority_chain_tail->zone, |
3813 | &rh->authority_chain_head->zone, | 4028 | &rh->authority_chain_head->zone, |
3814 | &process_zone_to_name_shorten_root, | 4029 | &process_zone_to_name_shorten_root, |
@@ -3902,7 +4117,7 @@ handle_delegation_ns_shorten (void* cls, | |||
3902 | 4117 | ||
3903 | 4118 | ||
3904 | /* backtrack authorities for names */ | 4119 | /* backtrack authorities for names */ |
3905 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | 4120 | rh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, |
3906 | nsh->root_zone, | 4121 | nsh->root_zone, |
3907 | &rh->authority_chain_head->zone, | 4122 | &rh->authority_chain_head->zone, |
3908 | &process_zone_to_name_shorten_root, | 4123 | &process_zone_to_name_shorten_root, |
@@ -3960,9 +4175,7 @@ process_zone_to_name_zkey(void *cls, | |||
3960 | 4175 | ||
3961 | strcpy (nsh->result, new_name); | 4176 | strcpy (nsh->result, new_name); |
3962 | 4177 | ||
3963 | nsh->proc(nsh->proc_cls, new_name); | 4178 | finish_shorten (rh, nsh); |
3964 | GNUNET_free(nsh); | ||
3965 | free_resolver_handle(rh); | ||
3966 | return; | 4179 | return; |
3967 | } | 4180 | } |
3968 | 4181 | ||
@@ -3983,7 +4196,7 @@ process_zone_to_name_zkey(void *cls, | |||
3983 | 4196 | ||
3984 | 4197 | ||
3985 | /* Start delegation resolution in our namestore */ | 4198 | /* Start delegation resolution in our namestore */ |
3986 | resolve_delegation_ns(rh); | 4199 | resolve_delegation_ns (rh); |
3987 | } | 4200 | } |
3988 | 4201 | ||
3989 | 4202 | ||
@@ -4039,14 +4252,18 @@ gns_resolver_shorten_name (struct GNUNET_CRYPTO_ShortHashCode *zone, | |||
4039 | strcpy (nsh->shorten_zone_name, shorten_zone_name); | 4252 | strcpy (nsh->shorten_zone_name, shorten_zone_name); |
4040 | strcpy (nsh->result, name); | 4253 | strcpy (nsh->result, name); |
4041 | 4254 | ||
4255 | |||
4042 | rh = GNUNET_malloc (sizeof (struct ResolverHandle)); | 4256 | rh = GNUNET_malloc (sizeof (struct ResolverHandle)); |
4043 | rh->authority = *zone; | 4257 | rh->authority = *zone; |
4044 | rh->id = rid++; | 4258 | rh->id = rid++; |
4045 | rh->priv_key = NULL; | 4259 | rh->priv_key = NULL; |
4260 | rh->namestore_task = NULL; | ||
4046 | rh->proc = &handle_delegation_ns_shorten; | 4261 | rh->proc = &handle_delegation_ns_shorten; |
4047 | rh->proc_cls = nsh; | 4262 | rh->proc_cls = nsh; |
4048 | rh->id = rid++; | 4263 | rh->id = rid++; |
4049 | rh->private_local_zone = *zone; | 4264 | rh->private_local_zone = *zone; |
4265 | |||
4266 | GNUNET_CONTAINER_DLL_insert (nsh_head, nsh_tail, rh); | ||
4050 | 4267 | ||
4051 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 4268 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
4052 | "Checking for TLD...\n"); | 4269 | "Checking for TLD...\n"); |
@@ -4077,11 +4294,12 @@ gns_resolver_shorten_name (struct GNUNET_CRYPTO_ShortHashCode *zone, | |||
4077 | "Cannot convert ZKEY %s to hash!\n", nzkey); | 4294 | "Cannot convert ZKEY %s to hash!\n", nzkey); |
4078 | GNUNET_free (rh); | 4295 | GNUNET_free (rh); |
4079 | GNUNET_free (nsh); | 4296 | GNUNET_free (nsh); |
4297 | GNUNET_CONTAINER_DLL_remove (nsh_head, nsh_tail, rh); | ||
4080 | proc (proc_cls, name); | 4298 | proc (proc_cls, name); |
4081 | return; | 4299 | return; |
4082 | } | 4300 | } |
4083 | 4301 | ||
4084 | GNUNET_NAMESTORE_zone_to_name (namestore_handle, | 4302 | rh->namestore_task = GNUNET_NAMESTORE_zone_to_name (namestore_handle, |
4085 | zone, //ours | 4303 | zone, //ours |
4086 | &zkey, | 4304 | &zkey, |
4087 | &process_zone_to_name_zkey, | 4305 | &process_zone_to_name_zkey, |
@@ -4113,6 +4331,18 @@ gns_resolver_shorten_name (struct GNUNET_CRYPTO_ShortHashCode *zone, | |||
4113 | 4331 | ||
4114 | /*********** END NAME SHORTEN ********************/ | 4332 | /*********** END NAME SHORTEN ********************/ |
4115 | 4333 | ||
4334 | static void | ||
4335 | finish_get_auth (struct ResolverHandle *rh, | ||
4336 | struct GetNameAuthorityHandle *nah) | ||
4337 | { | ||
4338 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
4339 | "Got authority result %s\n", nah->result); | ||
4340 | |||
4341 | nah->proc(nah->proc_cls, nah->result); | ||
4342 | GNUNET_CONTAINER_DLL_remove (nah_head, nah_tail, rh); | ||
4343 | GNUNET_free(nah); | ||
4344 | free_resolver_handle(rh); | ||
4345 | } | ||
4116 | 4346 | ||
4117 | /** | 4347 | /** |
4118 | * Process result from namestore delegation lookup | 4348 | * Process result from namestore delegation lookup |
@@ -4130,7 +4360,6 @@ handle_delegation_result_ns_get_auth(void* cls, | |||
4130 | const struct GNUNET_NAMESTORE_RecordData *rd) | 4360 | const struct GNUNET_NAMESTORE_RecordData *rd) |
4131 | { | 4361 | { |
4132 | struct GetNameAuthorityHandle* nah; | 4362 | struct GetNameAuthorityHandle* nah; |
4133 | char result[MAX_DNS_NAME_LENGTH]; | ||
4134 | size_t answer_len; | 4363 | size_t answer_len; |
4135 | 4364 | ||
4136 | nah = (struct GetNameAuthorityHandle*) rh->proc_cls; | 4365 | nah = (struct GetNameAuthorityHandle*) rh->proc_cls; |
@@ -4164,23 +4393,17 @@ handle_delegation_result_ns_get_auth(void* cls, | |||
4164 | 4393 | ||
4165 | answer_len = strlen(nah->name) - strlen(rh->name) | 4394 | answer_len = strlen(nah->name) - strlen(rh->name) |
4166 | + strlen(GNUNET_GNS_TLD) + 1; | 4395 | + strlen(GNUNET_GNS_TLD) + 1; |
4167 | memset(result, 0, answer_len); | 4396 | memset(nah->result, 0, answer_len); |
4168 | strcpy(result, nah->name + strlen(rh->name) + 1); | 4397 | strcpy(nah->result, nah->name + strlen(rh->name) + 1); |
4169 | 4398 | ||
4170 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4399 | finish_get_auth (rh, nah); |
4171 | "Got authority result %s\n", result); | ||
4172 | |||
4173 | nah->proc(nah->proc_cls, result); | ||
4174 | GNUNET_free(nah); | ||
4175 | free_resolver_handle(rh); | ||
4176 | } | 4400 | } |
4177 | else | 4401 | else |
4178 | { | 4402 | { |
4179 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 4403 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
4180 | "Unable to resolve authority for remaining %s!\n", rh->name); | 4404 | "Unable to resolve authority for remaining %s!\n", rh->name); |
4181 | nah->proc(nah->proc_cls, ""); | 4405 | strcpy(nah->result, ""); |
4182 | GNUNET_free(nah); | 4406 | finish_get_auth (rh, nah); |
4183 | free_resolver_handle(rh); | ||
4184 | } | 4407 | } |
4185 | 4408 | ||
4186 | 4409 | ||
@@ -4215,6 +4438,9 @@ gns_resolver_get_authority(struct GNUNET_CRYPTO_ShortHashCode zone, | |||
4215 | rh->authority = zone; | 4438 | rh->authority = zone; |
4216 | rh->id = rid++; | 4439 | rh->id = rid++; |
4217 | rh->private_local_zone = pzone; | 4440 | rh->private_local_zone = pzone; |
4441 | rh->namestore_task = NULL; | ||
4442 | |||
4443 | GNUNET_CONTAINER_DLL_insert (nah_head, nah_tail, rh); | ||
4218 | 4444 | ||
4219 | if (strcmp(GNUNET_GNS_TLD, name) == 0) | 4445 | if (strcmp(GNUNET_GNS_TLD, name) == 0) |
4220 | { | 4446 | { |
@@ -4240,6 +4466,7 @@ gns_resolver_get_authority(struct GNUNET_CRYPTO_ShortHashCode zone, | |||
4240 | 4466 | ||
4241 | nah->proc = proc; | 4467 | nah->proc = proc; |
4242 | nah->proc_cls = proc_cls; | 4468 | nah->proc_cls = proc_cls; |
4469 | strcpy (nah->result, ""); | ||
4243 | 4470 | ||
4244 | /* Start delegation resolution in our namestore */ | 4471 | /* Start delegation resolution in our namestore */ |
4245 | resolve_delegation_ns(rh); | 4472 | resolve_delegation_ns(rh); |
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h index 5d9741beb..7f3d3799c 100644 --- a/src/gns/gnunet-service-gns_resolver.h +++ b/src/gns/gnunet-service-gns_resolver.h | |||
@@ -11,6 +11,7 @@ | |||
11 | #define DHT_GNS_REPLICATION_LEVEL 5 | 11 | #define DHT_GNS_REPLICATION_LEVEL 5 |
12 | 12 | ||
13 | #define GNUNET_GNS_MAX_PARALLEL_LOOKUPS 500 | 13 | #define GNUNET_GNS_MAX_PARALLEL_LOOKUPS 500 |
14 | #define GNUNET_GNS_MAX_NS_TASKS 500 | ||
14 | 15 | ||
15 | /* | 16 | /* |
16 | * DLL to hold the authority chain | 17 | * DLL to hold the authority chain |
@@ -118,6 +119,13 @@ enum ResolutionStatus | |||
118 | */ | 119 | */ |
119 | struct ResolverHandle | 120 | struct ResolverHandle |
120 | { | 121 | { |
122 | |||
123 | /* DLL */ | ||
124 | struct ResolverHandle *next; | ||
125 | |||
126 | /* DLL */ | ||
127 | struct ResolverHandle *prev; | ||
128 | |||
121 | /* The name to resolve */ | 129 | /* The name to resolve */ |
122 | char name[MAX_DNS_NAME_LENGTH]; | 130 | char name[MAX_DNS_NAME_LENGTH]; |
123 | 131 | ||
@@ -210,6 +218,11 @@ struct ResolverHandle | |||
210 | */ | 218 | */ |
211 | unsigned long long id; | 219 | unsigned long long id; |
212 | 220 | ||
221 | /** | ||
222 | * Pending Namestore task | ||
223 | */ | ||
224 | struct GNUNET_NAMESTORE_QueueEntry *namestore_task; | ||
225 | |||
213 | }; | 226 | }; |
214 | 227 | ||
215 | 228 | ||
@@ -271,6 +284,9 @@ struct GetNameAuthorityHandle | |||
271 | { | 284 | { |
272 | /* the name to look up authority for */ | 285 | /* the name to look up authority for */ |
273 | char name[MAX_DNS_NAME_LENGTH]; | 286 | char name[MAX_DNS_NAME_LENGTH]; |
287 | |||
288 | /* the result */ | ||
289 | char result[MAX_DNS_NAME_LENGTH]; | ||
274 | 290 | ||
275 | /* Method to call on result */ | 291 | /* Method to call on result */ |
276 | GetAuthorityResultProcessor proc; | 292 | GetAuthorityResultProcessor proc; |
@@ -310,6 +326,21 @@ struct GetPseuAuthorityHandle | |||
310 | 326 | ||
311 | /* Head of the authority list */ | 327 | /* Head of the authority list */ |
312 | struct AuthorityChain *ahead; | 328 | struct AuthorityChain *ahead; |
329 | |||
330 | /* handle to namestore request */ | ||
331 | struct GNUNET_NAMESTORE_QueueEntry* namestore_task; | ||
332 | }; | ||
333 | |||
334 | /** | ||
335 | * Namestore queue entries in background | ||
336 | */ | ||
337 | struct NamestoreBGTask | ||
338 | { | ||
339 | /* node in heap */ | ||
340 | struct GNUNET_CONTAINER_HeapNode *node; | ||
341 | |||
342 | /* queue entry */ | ||
343 | struct GNUNET_NAMESTORE_QueueEntry *qe; | ||
313 | }; | 344 | }; |
314 | 345 | ||
315 | /** | 346 | /** |
diff --git a/src/gns/test_gns_cname_lookup.c b/src/gns/test_gns_cname_lookup.c index a9eae329c..f1045fda7 100644 --- a/src/gns/test_gns_cname_lookup.c +++ b/src/gns/test_gns_cname_lookup.c | |||
@@ -275,6 +275,12 @@ on_lookup_result_plus (void *cls, uint32_t rd_count, | |||
275 | } | 275 | } |
276 | 276 | ||
277 | 277 | ||
278 | static void | ||
279 | disco_ns (void* cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
280 | { | ||
281 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
282 | } | ||
283 | |||
278 | /** | 284 | /** |
279 | * Function scheduled to be run on the successful start of services | 285 | * Function scheduled to be run on the successful start of services |
280 | * tries to look up the dns record for TEST_DOMAIN | 286 | * tries to look up the dns record for TEST_DOMAIN |
@@ -283,8 +289,7 @@ static void | |||
283 | commence_testing (void *cls, int32_t success, const char *emsg) | 289 | commence_testing (void *cls, int32_t success, const char *emsg) |
284 | { | 290 | { |
285 | 291 | ||
286 | 292 | GNUNET_SCHEDULER_add_now (disco_ns, NULL); | |
287 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
288 | 293 | ||
289 | gns_handle = GNUNET_GNS_connect(cfg); | 294 | gns_handle = GNUNET_GNS_connect(cfg); |
290 | 295 | ||
diff --git a/src/gns/test_gns_dht_delegated_lookup.c b/src/gns/test_gns_dht_delegated_lookup.c index 1d5f343aa..9875e2545 100644 --- a/src/gns/test_gns_dht_delegated_lookup.c +++ b/src/gns/test_gns_dht_delegated_lookup.c | |||
@@ -106,6 +106,9 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
106 | int i; | 106 | int i; |
107 | char* addr; | 107 | char* addr; |
108 | 108 | ||
109 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
110 | |||
111 | |||
109 | if (rd_count == 0) | 112 | if (rd_count == 0) |
110 | { | 113 | { |
111 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 114 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -152,8 +155,6 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
152 | static void | 155 | static void |
153 | commence_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 156 | commence_testing (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
154 | { | 157 | { |
155 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
156 | |||
157 | gns_handle = GNUNET_GNS_connect(cfg); | 158 | gns_handle = GNUNET_GNS_connect(cfg); |
158 | 159 | ||
159 | if (NULL == gns_handle) | 160 | if (NULL == gns_handle) |
diff --git a/src/gns/test_gns_dht_threepeer.c b/src/gns/test_gns_dht_threepeer.c index 0fc0f9104..9c0c99d77 100644 --- a/src/gns/test_gns_dht_threepeer.c +++ b/src/gns/test_gns_dht_threepeer.c | |||
@@ -179,7 +179,6 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
179 | string_val = GNUNET_NAMESTORE_value_to_string(rd[i].record_type, | 179 | string_val = GNUNET_NAMESTORE_value_to_string(rd[i].record_type, |
180 | rd[i].data, | 180 | rd[i].data, |
181 | rd[i].data_size); | 181 | rd[i].data_size); |
182 | printf("Got %s record: %s\n", typename, string_val); | ||
183 | if (0 == strcmp(string_val, TEST_IP)) | 182 | if (0 == strcmp(string_val, TEST_IP)) |
184 | { | 183 | { |
185 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 184 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
@@ -200,7 +199,6 @@ static void | |||
200 | commence_testing(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 199 | commence_testing(void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
201 | { | 200 | { |
202 | 201 | ||
203 | |||
204 | gh = GNUNET_GNS_connect(alice_cfg); | 202 | gh = GNUNET_GNS_connect(alice_cfg); |
205 | 203 | ||
206 | GNUNET_GNS_lookup(gh, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, | 204 | GNUNET_GNS_lookup(gh, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, |
@@ -281,10 +279,16 @@ all_connected(void *cls, const char *emsg) | |||
281 | GNUNET_SCHEDULER_add_delayed (ZONE_PUT_WAIT_TIME, &commence_testing, NULL); | 279 | GNUNET_SCHEDULER_add_delayed (ZONE_PUT_WAIT_TIME, &commence_testing, NULL); |
282 | } | 280 | } |
283 | 281 | ||
284 | void | 282 | static void |
285 | ns_create_cont(void *cls, int32_t s, const char *emsg) | 283 | disconnect_ns (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
284 | { | ||
285 | GNUNET_NAMESTORE_disconnect (cls); | ||
286 | } | ||
287 | |||
288 | static void | ||
289 | cont_ns (void* cls, int32_t s, const char* emsg) | ||
286 | { | 290 | { |
287 | GNUNET_NAMESTORE_disconnect ((struct GNUNET_NAMESTORE_Handle *)cls); | 291 | GNUNET_SCHEDULER_add_now (&disconnect_ns, cls); |
288 | } | 292 | } |
289 | 293 | ||
290 | static void | 294 | static void |
@@ -335,7 +339,7 @@ daemon_started (void *cls, const struct GNUNET_PeerIdentity *id, | |||
335 | rd.data = TEST_DAVE_PSEU; | 339 | rd.data = TEST_DAVE_PSEU; |
336 | rd.record_type = GNUNET_GNS_RECORD_PSEU; | 340 | rd.record_type = GNUNET_GNS_RECORD_PSEU; |
337 | 341 | ||
338 | GNUNET_NAMESTORE_record_create (ns, key, "+", &rd, ns_create_cont, ns); | 342 | GNUNET_NAMESTORE_record_create (ns, key, "+", &rd, &cont_ns, ns); |
339 | 343 | ||
340 | GNUNET_CRYPTO_rsa_key_free(key); | 344 | GNUNET_CRYPTO_rsa_key_free(key); |
341 | GNUNET_free(keyfile); | 345 | GNUNET_free(keyfile); |
@@ -370,7 +374,7 @@ daemon_started (void *cls, const struct GNUNET_PeerIdentity *id, | |||
370 | rd.record_type = GNUNET_GNS_RECORD_PKEY; | 374 | rd.record_type = GNUNET_GNS_RECORD_PKEY; |
371 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; | 375 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; |
372 | 376 | ||
373 | GNUNET_NAMESTORE_record_create (ns, key, "buddy", &rd, ns_create_cont, ns); | 377 | GNUNET_NAMESTORE_record_create (ns, key, "buddy", &rd, &cont_ns, ns); |
374 | 378 | ||
375 | GNUNET_CRYPTO_rsa_key_free(key); | 379 | GNUNET_CRYPTO_rsa_key_free(key); |
376 | GNUNET_free(keyfile); | 380 | GNUNET_free(keyfile); |
@@ -404,7 +408,7 @@ daemon_started (void *cls, const struct GNUNET_PeerIdentity *id, | |||
404 | rd.record_type = GNUNET_GNS_RECORD_PKEY; | 408 | rd.record_type = GNUNET_GNS_RECORD_PKEY; |
405 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; | 409 | rd.flags = GNUNET_NAMESTORE_RF_AUTHORITY; |
406 | 410 | ||
407 | GNUNET_NAMESTORE_record_create (ns, key, "bob", &rd, ns_create_cont, ns); | 411 | GNUNET_NAMESTORE_record_create (ns, key, "bob", &rd, &cont_ns, ns); |
408 | 412 | ||
409 | GNUNET_CRYPTO_rsa_key_free(key); | 413 | GNUNET_CRYPTO_rsa_key_free(key); |
410 | GNUNET_free(keyfile); | 414 | GNUNET_free(keyfile); |
diff --git a/src/gns/test_gns_max_queries.c b/src/gns/test_gns_max_queries.c index f26353a95..f759889aa 100644 --- a/src/gns/test_gns_max_queries.c +++ b/src/gns/test_gns_max_queries.c | |||
@@ -111,6 +111,7 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
111 | int i; | 111 | int i; |
112 | char* addr; | 112 | char* addr; |
113 | 113 | ||
114 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
114 | if (rd_count == 0) | 115 | if (rd_count == 0) |
115 | { | 116 | { |
116 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 117 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -160,7 +161,6 @@ commence_testing (void *cls, int32_t success, const char *emsg) | |||
160 | int i; | 161 | int i; |
161 | char lookup_name[MAX_DNS_NAME_LENGTH]; | 162 | char lookup_name[MAX_DNS_NAME_LENGTH]; |
162 | 163 | ||
163 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
164 | 164 | ||
165 | gns_handle = GNUNET_GNS_connect(cfg); | 165 | gns_handle = GNUNET_GNS_connect(cfg); |
166 | 166 | ||
diff --git a/src/gns/test_gns_ns_lookup.c b/src/gns/test_gns_ns_lookup.c index 890347bc6..7cb700c73 100644 --- a/src/gns/test_gns_ns_lookup.c +++ b/src/gns/test_gns_ns_lookup.c | |||
@@ -231,6 +231,7 @@ start_lookup (void) | |||
231 | { | 231 | { |
232 | 232 | ||
233 | 233 | ||
234 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
234 | gns_handle = GNUNET_GNS_connect (cfg); | 235 | gns_handle = GNUNET_GNS_connect (cfg); |
235 | 236 | ||
236 | if (NULL == gns_handle) | 237 | if (NULL == gns_handle) |
@@ -289,7 +290,6 @@ static void | |||
289 | commence_testing (void *cls, int32_t success, const char *emsg) | 290 | commence_testing (void *cls, int32_t success, const char *emsg) |
290 | { | 291 | { |
291 | 292 | ||
292 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
293 | resolver_working = GNUNET_NO; | 293 | resolver_working = GNUNET_NO; |
294 | 294 | ||
295 | GNUNET_RESOLVER_connect (cfg); | 295 | GNUNET_RESOLVER_connect (cfg); |
diff --git a/src/gns/test_gns_pseu_shorten.c b/src/gns/test_gns_pseu_shorten.c index f181f0cc7..cd40c0098 100644 --- a/src/gns/test_gns_pseu_shorten.c +++ b/src/gns/test_gns_pseu_shorten.c | |||
@@ -158,7 +158,7 @@ process_shorten_result(void* cls, const char* sname) | |||
158 | { | 158 | { |
159 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 159 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
160 | "shorten test failed! (wanted: %s got: %s\n", | 160 | "shorten test failed! (wanted: %s got: %s\n", |
161 | (char*)cls, sname); | 161 | TEST_EXPECTED_RESULT, sname); |
162 | ok = 1; | 162 | ok = 1; |
163 | } | 163 | } |
164 | 164 | ||
@@ -236,6 +236,7 @@ commence_testing (void *cls, int success) | |||
236 | GNUNET_CRYPTO_rsa_key_free(bob_key); | 236 | GNUNET_CRYPTO_rsa_key_free(bob_key); |
237 | GNUNET_CRYPTO_rsa_key_free(alice_key); | 237 | GNUNET_CRYPTO_rsa_key_free(alice_key); |
238 | 238 | ||
239 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
239 | gns_handle = GNUNET_GNS_connect(cfg); | 240 | gns_handle = GNUNET_GNS_connect(cfg); |
240 | 241 | ||
241 | if (NULL == gns_handle) | 242 | if (NULL == gns_handle) |
@@ -478,12 +479,6 @@ put_pkey_dht(void *cls, int32_t success, const char *emsg) | |||
478 | &rd, | 479 | &rd, |
479 | 1); | 480 | 1); |
480 | 481 | ||
481 | GNUNET_break (GNUNET_OK == GNUNET_NAMESTORE_verify_signature (&bob_pkey, | ||
482 | GNUNET_TIME_UNIT_FOREVER_ABS, | ||
483 | TEST_AUTHORITY_ALICE, | ||
484 | 1, | ||
485 | &rd, | ||
486 | sig)); | ||
487 | rd_payload_length = GNUNET_NAMESTORE_records_get_size (1, &rd); | 482 | rd_payload_length = GNUNET_NAMESTORE_records_get_size (1, &rd); |
488 | nrb = GNUNET_malloc(rd_payload_length + strlen(TEST_AUTHORITY_ALICE) + 1 | 483 | nrb = GNUNET_malloc(rd_payload_length + strlen(TEST_AUTHORITY_ALICE) + 1 |
489 | + sizeof(struct GNSNameRecordBlock)); | 484 | + sizeof(struct GNSNameRecordBlock)); |
@@ -533,7 +528,6 @@ put_pkey_dht(void *cls, int32_t success, const char *emsg) | |||
533 | DHT_OPERATION_TIMEOUT, | 528 | DHT_OPERATION_TIMEOUT, |
534 | &put_www_dht, | 529 | &put_www_dht, |
535 | NULL); | 530 | NULL); |
536 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
537 | GNUNET_free (nrb); | 531 | GNUNET_free (nrb); |
538 | } | 532 | } |
539 | 533 | ||
diff --git a/src/gns/test_gns_revocation.c b/src/gns/test_gns_revocation.c index 66969dc62..8f7451187 100644 --- a/src/gns/test_gns_revocation.c +++ b/src/gns/test_gns_revocation.c | |||
@@ -95,6 +95,7 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
95 | int i; | 95 | int i; |
96 | char* addr; | 96 | char* addr; |
97 | 97 | ||
98 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
98 | if (rd_count == 0) | 99 | if (rd_count == 0) |
99 | { | 100 | { |
100 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 101 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -139,7 +140,6 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
139 | static void | 140 | static void |
140 | commence_testing (void *cls, int32_t success, const char *emsg) | 141 | commence_testing (void *cls, int32_t success, const char *emsg) |
141 | { | 142 | { |
142 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
143 | 143 | ||
144 | gns_handle = GNUNET_GNS_connect(cfg); | 144 | gns_handle = GNUNET_GNS_connect(cfg); |
145 | 145 | ||
diff --git a/src/gns/test_gns_simple_delegated_lookup.c b/src/gns/test_gns_simple_delegated_lookup.c index fa3216948..5264c8b66 100644 --- a/src/gns/test_gns_simple_delegated_lookup.c +++ b/src/gns/test_gns_simple_delegated_lookup.c | |||
@@ -109,6 +109,7 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
109 | int i; | 109 | int i; |
110 | char* addr; | 110 | char* addr; |
111 | 111 | ||
112 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
112 | if (rd_count == 0) | 113 | if (rd_count == 0) |
113 | { | 114 | { |
114 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 115 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -153,7 +154,6 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
153 | static void | 154 | static void |
154 | commence_testing (void *cls, int32_t success, const char *emsg) | 155 | commence_testing (void *cls, int32_t success, const char *emsg) |
155 | { | 156 | { |
156 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
157 | 157 | ||
158 | gns_handle = GNUNET_GNS_connect(cfg); | 158 | gns_handle = GNUNET_GNS_connect(cfg); |
159 | 159 | ||
diff --git a/src/gns/test_gns_simple_get_authority.c b/src/gns/test_gns_simple_get_authority.c index c73780c5b..845ff5d13 100644 --- a/src/gns/test_gns_simple_get_authority.c +++ b/src/gns/test_gns_simple_get_authority.c | |||
@@ -99,6 +99,10 @@ process_auth_result(void* cls, const char* aname) | |||
99 | { | 99 | { |
100 | GNUNET_GNS_disconnect(gns_handle); | 100 | GNUNET_GNS_disconnect(gns_handle); |
101 | 101 | ||
102 | |||
103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
104 | "disconnecting from namestore\n"); | ||
105 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
102 | ok = 0; | 106 | ok = 0; |
103 | 107 | ||
104 | if (aname == NULL) | 108 | if (aname == NULL) |
@@ -136,10 +140,6 @@ commence_testing (void *cls, int32_t success, const char *emsg) | |||
136 | { | 140 | { |
137 | 141 | ||
138 | 142 | ||
139 | |||
140 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
141 | "disconnecting from namestore\n"); | ||
142 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
143 | 143 | ||
144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
145 | "connecting to gns\n"); | 145 | "connecting to gns\n"); |
diff --git a/src/gns/test_gns_simple_lookup.c b/src/gns/test_gns_simple_lookup.c index ec1b8f054..dfc657e61 100644 --- a/src/gns/test_gns_simple_lookup.c +++ b/src/gns/test_gns_simple_lookup.c | |||
@@ -91,6 +91,7 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
91 | int i; | 91 | int i; |
92 | char* addr; | 92 | char* addr; |
93 | 93 | ||
94 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
94 | if (rd_count == 0) | 95 | if (rd_count == 0) |
95 | { | 96 | { |
96 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 97 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -137,7 +138,6 @@ commence_testing (void *cls, int32_t success, const char *emsg) | |||
137 | { | 138 | { |
138 | 139 | ||
139 | 140 | ||
140 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
141 | 141 | ||
142 | gns_handle = GNUNET_GNS_connect(cfg); | 142 | gns_handle = GNUNET_GNS_connect(cfg); |
143 | 143 | ||
diff --git a/src/gns/test_gns_simple_mx_lookup.c b/src/gns/test_gns_simple_mx_lookup.c index 0d4949a95..8648d3f16 100644 --- a/src/gns/test_gns_simple_mx_lookup.c +++ b/src/gns/test_gns_simple_mx_lookup.c | |||
@@ -97,6 +97,7 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
97 | uint16_t mx_preference; | 97 | uint16_t mx_preference; |
98 | char* mx; | 98 | char* mx; |
99 | 99 | ||
100 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
100 | if (rd_count == 0) | 101 | if (rd_count == 0) |
101 | { | 102 | { |
102 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 103 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -140,7 +141,6 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
140 | static void | 141 | static void |
141 | commence_testing (void *cls, int32_t success, const char *emsg) | 142 | commence_testing (void *cls, int32_t success, const char *emsg) |
142 | { | 143 | { |
143 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
144 | 144 | ||
145 | gns_handle = GNUNET_GNS_connect(cfg); | 145 | gns_handle = GNUNET_GNS_connect(cfg); |
146 | 146 | ||
diff --git a/src/gns/test_gns_simple_shorten.c b/src/gns/test_gns_simple_shorten.c index c08c688d1..0f4da9b6c 100644 --- a/src/gns/test_gns_simple_shorten.c +++ b/src/gns/test_gns_simple_shorten.c | |||
@@ -99,6 +99,10 @@ process_shorten_result(void* cls, const char* sname) | |||
99 | { | 99 | { |
100 | GNUNET_GNS_disconnect(gns_handle); | 100 | GNUNET_GNS_disconnect(gns_handle); |
101 | 101 | ||
102 | |||
103 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
104 | "disconnecting from namestore\n"); | ||
105 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
102 | ok = 0; | 106 | ok = 0; |
103 | 107 | ||
104 | if (sname == NULL) | 108 | if (sname == NULL) |
@@ -136,10 +140,6 @@ commence_testing (void *cls, int32_t success, const char *emsg) | |||
136 | { | 140 | { |
137 | 141 | ||
138 | 142 | ||
139 | |||
140 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
141 | "disconnecting from namestore\n"); | ||
142 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
143 | 143 | ||
144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 144 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
145 | "connecting to gns\n"); | 145 | "connecting to gns\n"); |
diff --git a/src/gns/test_gns_simple_srv_lookup.c b/src/gns/test_gns_simple_srv_lookup.c index f09f3698d..5dabf416c 100644 --- a/src/gns/test_gns_simple_srv_lookup.c +++ b/src/gns/test_gns_simple_srv_lookup.c | |||
@@ -99,6 +99,7 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
99 | uint16_t *srv_data; | 99 | uint16_t *srv_data; |
100 | char* srv; | 100 | char* srv; |
101 | 101 | ||
102 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
102 | if (rd_count == 0) | 103 | if (rd_count == 0) |
103 | { | 104 | { |
104 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 105 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -143,7 +144,6 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
143 | static void | 144 | static void |
144 | commence_testing (void *cls, int32_t success, const char *emsg) | 145 | commence_testing (void *cls, int32_t success, const char *emsg) |
145 | { | 146 | { |
146 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
147 | 147 | ||
148 | gns_handle = GNUNET_GNS_connect(cfg); | 148 | gns_handle = GNUNET_GNS_connect(cfg); |
149 | 149 | ||
diff --git a/src/gns/test_gns_simple_zkey_lookup.c b/src/gns/test_gns_simple_zkey_lookup.c index 5ec690a14..6645be279 100644 --- a/src/gns/test_gns_simple_zkey_lookup.c +++ b/src/gns/test_gns_simple_zkey_lookup.c | |||
@@ -97,6 +97,7 @@ on_lookup_result(void *cls, uint32_t rd_count, | |||
97 | int i; | 97 | int i; |
98 | char* addr; | 98 | char* addr; |
99 | 99 | ||
100 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
100 | if (rd_count == 0) | 101 | if (rd_count == 0) |
101 | { | 102 | { |
102 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 103 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -145,7 +146,6 @@ commence_testing (void *cls, int32_t success, const char *emsg) | |||
145 | char* pos; | 146 | char* pos; |
146 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded hash_str; | 147 | struct GNUNET_CRYPTO_ShortHashAsciiEncoded hash_str; |
147 | 148 | ||
148 | GNUNET_NAMESTORE_disconnect (namestore_handle); | ||
149 | 149 | ||
150 | gns_handle = GNUNET_GNS_connect(cfg); | 150 | gns_handle = GNUNET_GNS_connect(cfg); |
151 | 151 | ||