aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2012-03-28 11:12:19 +0000
committerMartin Schanzenbach <mschanzenbach@posteo.de>2012-03-28 11:12:19 +0000
commitba5736672201f5c3a97c7e8b46f716077b416d6c (patch)
treeef89bb093c40efc3d69c7cfcb2f6d1c0d1d17010 /src/gns
parente7526f97264417497e9d7d89d53a7dac4d832083 (diff)
downloadgnunet-ba5736672201f5c3a97c7e8b46f716077b416d6c.tar.gz
gnunet-ba5736672201f5c3a97c7e8b46f716077b416d6c.zip
-fixes, cleanup
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gns_api.c6
-rw-r--r--src/gns/gnunet-service-gns_resolver.c22
-rw-r--r--src/gns/gnunet-service-gns_resolver.h39
-rw-r--r--src/gns/test_gns_max_queries.c7
-rw-r--r--src/gns/testdb/sqlite-alice.dbbin17408 -> 17408 bytes
-rw-r--r--src/gns/testdb/sqlite-bob.dbbin14336 -> 14336 bytes
-rw-r--r--src/gns/testdb/sqlite-dave.dbbin17408 -> 17408 bytes
7 files changed, 36 insertions, 38 deletions
diff --git a/src/gns/gns_api.c b/src/gns/gns_api.c
index 09e5426f9..4b7d6b9f8 100644
--- a/src/gns/gns_api.c
+++ b/src/gns/gns_api.c
@@ -686,7 +686,7 @@ GNUNET_GNS_lookup (struct GNUNET_GNS_Handle *handle,
686 686
687 memcpy(&lookup_msg[1], name, strlen(name)); 687 memcpy(&lookup_msg[1], name, strlen(name));
688 688
689 GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, 689 GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail,
690 pending); 690 pending);
691 691
692 process_pending_messages (handle); 692 process_pending_messages (handle);
@@ -743,7 +743,7 @@ GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle,
743 743
744 memcpy(&shorten_msg[1], name, strlen(name)); 744 memcpy(&shorten_msg[1], name, strlen(name));
745 745
746 GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, 746 GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail,
747 pending); 747 pending);
748 748
749 process_pending_messages (handle); 749 process_pending_messages (handle);
@@ -800,7 +800,7 @@ GNUNET_GNS_get_authority (struct GNUNET_GNS_Handle *handle,
800 800
801 memcpy(&get_auth_msg[1], name, strlen(name)); 801 memcpy(&get_auth_msg[1], name, strlen(name));
802 802
803 GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, 803 GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail,
804 pending); 804 pending);
805 805
806 process_pending_messages (handle); 806 process_pending_messages (handle);
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 591aed031..964afb4f4 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -489,7 +489,7 @@ cleanup_pending_background_queries(void* cls,
489 ResolverCleanupContinuation cont = cls; 489 ResolverCleanupContinuation cont = cls;
490 490
491 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 491 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
492 "GNS_CLEANUP-%d: Terminating background lookup for %s\n", 492 "GNS_CLEANUP-%llu: Terminating background lookup for %s\n",
493 rh->id, rh->name); 493 rh->id, rh->name);
494 GNUNET_DHT_get_stop(rh->get_handle); 494 GNUNET_DHT_get_stop(rh->get_handle);
495 rh->get_handle = NULL; 495 rh->get_handle = NULL;
@@ -914,12 +914,12 @@ process_record_result_ns(void* cls,
914 914
915 if (name != NULL) 915 if (name != NULL)
916 { 916 {
917 rh->status |= EXISTS; 917 rh->status |= RSL_RECORD_EXISTS;
918 } 918 }
919 919
920 if (remaining_time.rel_value == 0) 920 if (remaining_time.rel_value == 0)
921 { 921 {
922 rh->status |= EXPIRED; 922 rh->status |= RSL_RECORD_EXPIRED;
923 } 923 }
924 924
925 if (rd_count == 0) 925 if (rd_count == 0)
@@ -1049,7 +1049,7 @@ dht_authority_lookup_timeout(void *cls,
1049 "GNS_PHASE_DELEGATE_DHT-%llu: dht lookup for query %s (%ds)timed out.\n", 1049 "GNS_PHASE_DELEGATE_DHT-%llu: dht lookup for query %s (%ds)timed out.\n",
1050 rh->id, rh->authority_name, rh->timeout.rel_value); 1050 rh->id, rh->authority_name, rh->timeout.rel_value);
1051 1051
1052 rh->status |= TIMED_OUT; 1052 rh->status |= RSL_TIMED_OUT;
1053 1053
1054 rh->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1054 rh->timeout_task = GNUNET_SCHEDULER_NO_TASK;
1055 1055
@@ -1495,7 +1495,7 @@ handle_record_ns(void* cls, struct ResolverHandle *rh,
1495 1495
1496 /** 1496 /**
1497 * There are 4 conditions that have to met for us to consult the DHT: 1497 * There are 4 conditions that have to met for us to consult the DHT:
1498 * 1. The entry in the DHT is EXPIRED AND 1498 * 1. The entry in the DHT is RSL_RECORD_EXPIRED AND
1499 * 2. No entry in the NS existed AND 1499 * 2. No entry in the NS existed AND
1500 * 3. The zone queried is not the local resolver's zone AND 1500 * 3. The zone queried is not the local resolver's zone AND
1501 * 4. The name that was looked up is '+' 1501 * 4. The name that was looked up is '+'
@@ -1503,7 +1503,7 @@ handle_record_ns(void* cls, struct ResolverHandle *rh,
1503 * the DHT for the authority in the authority lookup phase (and thus 1503 * the DHT for the authority in the authority lookup phase (and thus
1504 * would already have an entry in the NS for the record) 1504 * would already have an entry in the NS for the record)
1505 */ 1505 */
1506 if (rh->status & (EXPIRED | !EXISTS) && 1506 if (rh->status & (RSL_RECORD_EXPIRED | !RSL_RECORD_EXISTS) &&
1507 GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, 1507 GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone,
1508 &local_zone) && 1508 &local_zone) &&
1509 (strcmp(rh->name, "+") == 0)) 1509 (strcmp(rh->name, "+") == 0))
@@ -1792,9 +1792,9 @@ handle_delegation_ns(void* cls, struct ResolverHandle *rh,
1792 * and exists 1792 * and exists
1793 * or we are authority 1793 * or we are authority
1794 **/ 1794 **/
1795 if ((rh->status & (EXISTS | !EXPIRED)) || 1795 if (((rh->status & RSL_RECORD_EXISTS) && (rh->status & !RSL_RECORD_EXPIRED))
1796 !GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, 1796 || !GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone,
1797 &rh->authority_chain_tail->zone)) 1797 &local_zone))
1798 { 1798 {
1799 if (is_canonical(rh->name)) 1799 if (is_canonical(rh->name))
1800 { 1800 {
@@ -1869,12 +1869,12 @@ process_delegation_result_ns(void* cls,
1869 1869
1870 if (name != NULL) 1870 if (name != NULL)
1871 { 1871 {
1872 rh->status |= EXISTS; 1872 rh->status |= RSL_RECORD_EXISTS;
1873 } 1873 }
1874 1874
1875 if (remaining_time.rel_value == 0) 1875 if (remaining_time.rel_value == 0)
1876 { 1876 {
1877 rh->status |= EXPIRED; 1877 rh->status |= RSL_RECORD_EXPIRED;
1878 } 1878 }
1879 1879
1880 /** 1880 /**
diff --git a/src/gns/gnunet-service-gns_resolver.h b/src/gns/gnunet-service-gns_resolver.h
index f8c662bc2..17d0a7221 100644
--- a/src/gns/gnunet-service-gns_resolver.h
+++ b/src/gns/gnunet-service-gns_resolver.h
@@ -41,11 +41,11 @@ struct ResolverHandle;
41typedef void (*ResolverCleanupContinuation) (void); 41typedef void (*ResolverCleanupContinuation) (void);
42 42
43/** 43/**
44 * processor for a resultion result 44 * processor for a record lookup result
45 * 45 *
46 * @param cls the closure 46 * @param cls the closure
47 * @param rd_count number of results 47 * @param rd_count number of results
48 * @param rd resukt data 48 * @param rd result data
49 */ 49 */
50typedef void (*RecordLookupProcessor) (void *cls, 50typedef void (*RecordLookupProcessor) (void *cls,
51 uint32_t rd_count, 51 uint32_t rd_count,
@@ -70,7 +70,7 @@ typedef void (*ShortenResultProcessor) (void *cls, const char* name);
70typedef void (*GetAuthorityResultProcessor) (void *cls, const char* name); 70typedef void (*GetAuthorityResultProcessor) (void *cls, const char* name);
71 71
72/** 72/**
73 * processor for a resultion result 73 * processor for a resolution result
74 * 74 *
75 * @param cls the closure 75 * @param cls the closure
76 * @param rh the resolution handle 76 * @param rh the resolution handle
@@ -84,19 +84,27 @@ typedef void (*ResolutionResultProcessor) (void *cls,
84 84
85 85
86/** 86/**
87 * Resoltion status indicator 87 * Resolution status indicator
88 * EXISTS: the name to lookup exists 88 * RSL_RECORD_EXISTS: the name to lookup exists
89 * EXPIRED: the name in the record expired 89 * RSL_RECORD_EXPIRED: the name in the record expired
90 * RSL_TIMED_OUT: resolution timed out
90 */ 91 */
91enum ResolutionStatus 92enum ResolutionStatus
92{ 93{
93 EXISTS = 1, 94 RSL_RECORD_EXISTS = 1,
94 EXPIRED = 2, 95 RSL_RECORD_EXPIRED = 2,
95 TIMED_OUT = 4 96 RSL_TIMED_OUT = 4
96}; 97};
97 98
98/** 99/**
99 * Handle to a currenty pending resolution 100 * Handle to a currenty pending resolution
101 * a ResolverHandle is passed to, for example
102 * resolve_record_ns to resolve a record in the namestore.
103 * On result (positive or negative) the ResolutionResultProcessor
104 * is called.
105 * If a timeout is set timeout_cont will be called.
106 * If no timeout is set (ie timeout forever) then background resolutions
107 * might be triggered.
100 */ 108 */
101struct ResolverHandle 109struct ResolverHandle
102{ 110{
@@ -112,12 +120,6 @@ struct ResolverHandle
112 /* the name of the authoritative zone to query */ 120 /* the name of the authoritative zone to query */
113 char authority_name[MAX_DNS_LABEL_LENGTH]; 121 char authority_name[MAX_DNS_LABEL_LENGTH];
114 122
115 /**
116 * we have an authority in namestore that
117 * may be able to resolve
118 */
119 int authority_found;
120
121 /* a handle for dht lookups. should be NULL if no lookups are in progress */ 123 /* a handle for dht lookups. should be NULL if no lookups are in progress */
122 struct GNUNET_DHT_GetHandle *get_handle; 124 struct GNUNET_DHT_GetHandle *get_handle;
123 125
@@ -193,14 +195,11 @@ struct RecordLookupHandle
193 */ 195 */
194struct NameShortenHandle 196struct NameShortenHandle
195{ 197{
196
197
198 /* Method to call on shorten result */ 198 /* Method to call on shorten result */
199 ShortenResultProcessor proc; 199 ShortenResultProcessor proc;
200 200
201 /* closure to pass to proc */ 201 /* closure to pass to proc */
202 void* proc_cls; 202 void* proc_cls;
203
204}; 203};
205 204
206/** 205/**
@@ -208,7 +207,6 @@ struct NameShortenHandle
208 */ 207 */
209struct GetNameAuthorityHandle 208struct GetNameAuthorityHandle
210{ 209{
211
212 /* the name to look up authority for */ 210 /* the name to look up authority for */
213 char name[MAX_DNS_NAME_LENGTH]; 211 char name[MAX_DNS_NAME_LENGTH];
214 212
@@ -217,7 +215,6 @@ struct GetNameAuthorityHandle
217 215
218 /* closure to pass to proc */ 216 /* closure to pass to proc */
219 void* proc_cls; 217 void* proc_cls;
220
221}; 218};
222 219
223/** 220/**
@@ -276,7 +273,7 @@ gns_resolver_cleanup(ResolverCleanupContinuation cont);
276 273
277/** 274/**
278 * Lookup of a record in a specific zone 275 * Lookup of a record in a specific zone
279 * calls lookup result processor on result 276 * calls RecordLookupProcessor on result or timeout
280 * 277 *
281 * @param zone the root zone 278 * @param zone the root zone
282 * @param record_type the record type to look up 279 * @param record_type the record type to look up
diff --git a/src/gns/test_gns_max_queries.c b/src/gns/test_gns_max_queries.c
index 9b9126054..b95bff8c7 100644
--- a/src/gns/test_gns_max_queries.c
+++ b/src/gns/test_gns_max_queries.c
@@ -169,18 +169,19 @@ commence_testing (void *cls, int32_t success, const char *emsg)
169 ok = 2; 169 ok = 2;
170 } 170 }
171 171
172 GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A,
173 &on_lookup_result, TEST_DOMAIN);
174 172
175 /* Now lookup some non existing records */ 173 /* Now lookup some non existing records */
176 for (i=0; i<max_parallel_lookups+TEST_ADDITIONAL_LOOKUPS; i++) 174 for (i=0; i<max_parallel_lookups+TEST_ADDITIONAL_LOOKUPS; i++)
177 { 175 {
178 GNUNET_snprintf(lookup_name, 176 GNUNET_snprintf(lookup_name,
179 MAX_DNS_NAME_LENGTH, 177 MAX_DNS_NAME_LENGTH,
180 "doesnotexist-%d.bob.gnunet", i); 178 "www.doesnotexist-%d.bob.gnunet", i);
181 GNUNET_GNS_lookup(gns_handle, lookup_name, GNUNET_GNS_RECORD_TYPE_A, 179 GNUNET_GNS_lookup(gns_handle, lookup_name, GNUNET_GNS_RECORD_TYPE_A,
182 &on_lookup_result_dummy, NULL); 180 &on_lookup_result_dummy, NULL);
183 } 181 }
182
183 GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A,
184 &on_lookup_result, TEST_DOMAIN);
184} 185}
185 186
186 187
diff --git a/src/gns/testdb/sqlite-alice.db b/src/gns/testdb/sqlite-alice.db
index b3379dedb..88b2d5c27 100644
--- a/src/gns/testdb/sqlite-alice.db
+++ b/src/gns/testdb/sqlite-alice.db
Binary files differ
diff --git a/src/gns/testdb/sqlite-bob.db b/src/gns/testdb/sqlite-bob.db
index c7c10534e..293cbf228 100644
--- a/src/gns/testdb/sqlite-bob.db
+++ b/src/gns/testdb/sqlite-bob.db
Binary files differ
diff --git a/src/gns/testdb/sqlite-dave.db b/src/gns/testdb/sqlite-dave.db
index bc164987b..4d105d535 100644
--- a/src/gns/testdb/sqlite-dave.db
+++ b/src/gns/testdb/sqlite-dave.db
Binary files differ