aboutsummaryrefslogtreecommitdiff
path: root/src/gns
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2012-10-30 18:58:10 +0000
committerChristian Grothoff <christian@grothoff.org>2012-10-30 18:58:10 +0000
commit38c3c16ddf6b4f4f2ef43c766a0a013c8d70b608 (patch)
tree0209c651a775e778305f847519f88e18e6cbae71 /src/gns
parentce0102d7815d30cdfbc099108673ab568b7bec25 (diff)
downloadgnunet-38c3c16ddf6b4f4f2ef43c766a0a013c8d70b608.tar.gz
gnunet-38c3c16ddf6b4f4f2ef43c766a0a013c8d70b608.zip
-fixing gns test issues
Diffstat (limited to 'src/gns')
-rw-r--r--src/gns/gnunet-service-gns_resolver.c158
-rw-r--r--src/gns/test_gns_dht_default.conf2
-rw-r--r--src/gns/test_gns_simple_lookup.conf2
3 files changed, 85 insertions, 77 deletions
diff --git a/src/gns/gnunet-service-gns_resolver.c b/src/gns/gnunet-service-gns_resolver.c
index 641e042ba..72171a6d8 100644
--- a/src/gns/gnunet-service-gns_resolver.c
+++ b/src/gns/gnunet-service-gns_resolver.c
@@ -486,7 +486,7 @@ process_auth_discovery_ns_result (void* cls,
486 GNUNET_h2s (&lookup_key)); 486 GNUNET_h2s (&lookup_key));
487 487
488 gph->timeout = GNUNET_SCHEDULER_add_delayed (DHT_LOOKUP_TIMEOUT, 488 gph->timeout = GNUNET_SCHEDULER_add_delayed (DHT_LOOKUP_TIMEOUT,
489 &handle_auth_discovery_timeout, gph); 489 &handle_auth_discovery_timeout, gph);
490 490
491 xquery = htonl (GNUNET_GNS_RECORD_PSEU); 491 xquery = htonl (GNUNET_GNS_RECORD_PSEU);
492 492
@@ -914,7 +914,10 @@ static void
914handle_lookup_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) 914handle_lookup_timeout (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
915{ 915{
916 struct ResolverHandle *rh = cls; 916 struct ResolverHandle *rh = cls;
917 917
918 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
919 "Lookup timeout for request %llu triggered\n",
920 rh->id);
918 if (NULL != rh->timeout_cont) 921 if (NULL != rh->timeout_cont)
919 rh->timeout_cont (rh->timeout_cont_cls, tc); 922 rh->timeout_cont (rh->timeout_cont_cls, tc);
920} 923}
@@ -1157,7 +1160,9 @@ resolve_record_dht (struct ResolverHandle *rh)
1157 if (GNUNET_SCHEDULER_NO_TASK == rh->timeout_task) 1160 if (GNUNET_SCHEDULER_NO_TASK == rh->timeout_task)
1158 { 1161 {
1159 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 1162 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1160 "GNS_PHASE_REC-%llu: Adjusting timeout\n", rh->id); 1163 "GNS_PHASE_REC-%llu: Adjusting timeout to %s/2\n",
1164 rh->id,
1165 GNUNET_STRINGS_relative_time_to_string (rh->timeout, GNUNET_YES));
1161 /* 1166 /*
1162 * Set timeout for authority lookup phase to 1/2 1167 * Set timeout for authority lookup phase to 1/2
1163 */ 1168 */
@@ -1970,54 +1975,54 @@ resolve_record_ns(struct ResolverHandle *rh)
1970 * @param tc the task context 1975 * @param tc the task context
1971 */ 1976 */
1972static void 1977static void
1973dht_authority_lookup_timeout(void *cls, 1978dht_authority_lookup_timeout (void *cls,
1974 const struct GNUNET_SCHEDULER_TaskContext *tc) 1979 const struct GNUNET_SCHEDULER_TaskContext *tc)
1975{ 1980{
1976 struct ResolverHandle *rh = cls; 1981 struct ResolverHandle *rh = cls;
1977 struct RecordLookupHandle *rlh = rh->proc_cls; 1982 struct RecordLookupHandle *rlh = rh->proc_cls;
1978 char new_name[MAX_DNS_NAME_LENGTH]; 1983 char new_name[MAX_DNS_NAME_LENGTH];
1979 1984
1980 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1985 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1981 "GNS_PHASE_DELEGATE_DHT-%llu: dht lookup for query %s (%llus)timed out.\n", 1986 "GNS_PHASE_DELEGATE_DHT-%llu: dht lookup for query %s (%llus) timed out.\n",
1982 rh->id, rh->authority_name, rh->timeout.rel_value); 1987 rh->id, rh->authority_name,
1988 rh->timeout.rel_value);
1983 1989
1984 rh->status |= RSL_TIMED_OUT; 1990 rh->status |= RSL_TIMED_OUT;
1985 rh->timeout_task = GNUNET_SCHEDULER_NO_TASK; 1991 rh->timeout_task = GNUNET_SCHEDULER_NO_TASK;
1986 if (NULL != rh->get_handle) 1992 if (NULL != rh->get_handle)
1993 {
1987 GNUNET_DHT_get_stop (rh->get_handle); 1994 GNUNET_DHT_get_stop (rh->get_handle);
1988 1995 rh->get_handle = NULL;
1989 rh->get_handle = NULL; 1996 }
1990 if (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN) 1997 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
1991 { 1998 {
1992 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 1999 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
1993 "GNS_PHASE_DELEGATE_DHT-%llu: Got shutdown\n", 2000 "GNS_PHASE_DELEGATE_DHT-%llu: Got shutdown\n",
1994 rh->id); 2001 rh->id);
1995 rh->proc(rh->proc_cls, rh, 0, NULL); 2002 rh->proc (rh->proc_cls, rh, 0, NULL);
1996 return; 2003 return;
1997 } 2004 }
1998 2005 if (0 == strcmp (rh->name, ""))
1999 if (0 == strcmp(rh->name, ""))
2000 { 2006 {
2001 /* 2007 /*
2002 * promote authority back to name and try to resolve record 2008 * promote authority back to name and try to resolve record
2003 */ 2009 */
2004 strcpy(rh->name, rh->authority_name); 2010 strcpy (rh->name, rh->authority_name);
2005 rh->proc(rh->proc_cls, rh, 0, NULL); 2011 rh->proc (rh->proc_cls, rh, 0, NULL);
2006 return; 2012 return;
2007 } 2013 }
2008 2014
2009 /** 2015 /**
2010 * Start resolution in bg 2016 * Start resolution in bg
2011 */ 2017 */
2012 GNUNET_assert (0 < GNUNET_snprintf(new_name, MAX_DNS_NAME_LENGTH, 2018 GNUNET_snprintf (new_name, MAX_DNS_NAME_LENGTH,
2013 "%s.%s.%s", rh->name, rh->authority_name, GNUNET_GNS_TLD)); 2019 "%s.%s.%s",
2014 2020 rh->name, rh->authority_name, GNUNET_GNS_TLD);
2015 strcpy(rh->name, new_name); 2021 strcpy (rh->name, new_name);
2016 2022 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2017 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2023 "GNS_PHASE_DELEGATE_DHT-%llu: Starting background query for %s type %d\n",
2018 "GNS_PHASE_DELEGATE_DHT-%llu: Starting background query for %s type %d\n", 2024 rh->id, rh->name,
2019 rh->id, rh->name, rlh->record_type); 2025 rlh->record_type);
2020
2021 gns_resolver_lookup_record (rh->authority, 2026 gns_resolver_lookup_record (rh->authority,
2022 rh->private_local_zone, 2027 rh->private_local_zone,
2023 rlh->record_type, 2028 rlh->record_type,
@@ -2027,7 +2032,7 @@ dht_authority_lookup_timeout(void *cls,
2027 GNUNET_NO, 2032 GNUNET_NO,
2028 &background_lookup_result_processor, 2033 &background_lookup_result_processor,
2029 NULL); 2034 NULL);
2030 rh->proc(rh->proc_cls, rh, 0, NULL); 2035 rh->proc (rh->proc_cls, rh, 0, NULL);
2031} 2036}
2032 2037
2033 2038
@@ -2205,17 +2210,17 @@ process_delegation_result_dht (void* cls,
2205 size_t size, const void *data) 2210 size_t size, const void *data)
2206{ 2211{
2207 struct ResolverHandle *rh = cls; 2212 struct ResolverHandle *rh = cls;
2208 struct GNSNameRecordBlock *nrb; 2213 const struct GNSNameRecordBlock *nrb = data;
2214 const char* rd_data;
2209 uint32_t num_records; 2215 uint32_t num_records;
2210 char* name = NULL; 2216 const char* name;
2211 char* rd_data = (char*) data;
2212 uint32_t i; 2217 uint32_t i;
2213 int rd_size; 2218 int rd_size;
2214 struct GNUNET_CRYPTO_ShortHashCode zone; 2219 struct GNUNET_CRYPTO_ShortHashCode zone;
2215 2220
2216 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2221 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2217 "GNS_PHASE_DELEGATE_DHT-%llu: Got DHT result\n", rh->id); 2222 "GNS_PHASE_DELEGATE_DHT-%llu: Got DHT result\n",
2218 2223 rh->id);
2219 if (data == NULL) 2224 if (data == NULL)
2220 return; 2225 return;
2221 2226
@@ -2231,14 +2236,14 @@ process_delegation_result_dht (void* cls,
2231 } 2236 }
2232 2237
2233 num_records = ntohl(nrb->rd_count); 2238 num_records = ntohl(nrb->rd_count);
2234 name = (char*)&nrb[1]; 2239 name = (const char*) &nrb[1];
2235 { 2240 {
2236 struct GNUNET_NAMESTORE_RecordData rd[num_records]; 2241 struct GNUNET_NAMESTORE_RecordData rd[num_records];
2237 struct NamestoreBGTask *ns_heap_root; 2242 struct NamestoreBGTask *ns_heap_root;
2238 struct NamestoreBGTask *namestore_bg_task; 2243 struct NamestoreBGTask *namestore_bg_task;
2239 2244
2240 rd_data += strlen(name) + 1 + sizeof(struct GNSNameRecordBlock); 2245 rd_data = name + strlen(name) + 1;
2241 rd_size = size - strlen(name) - 1 - sizeof(struct GNSNameRecordBlock); 2246 rd_size = size - strlen(name) - 1 - sizeof (struct GNSNameRecordBlock);
2242 if (GNUNET_SYSERR == GNUNET_NAMESTORE_records_deserialize (rd_size, 2247 if (GNUNET_SYSERR == GNUNET_NAMESTORE_records_deserialize (rd_size,
2243 rd_data, 2248 rd_data,
2244 num_records, 2249 num_records,
@@ -2255,10 +2260,9 @@ process_delegation_result_dht (void* cls,
2255 rh->id, name, rh->authority_name); 2260 rh->id, name, rh->authority_name);
2256 for (i=0; i<num_records; i++) 2261 for (i=0; i<num_records; i++)
2257 { 2262 {
2258 2263 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2259 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2264 "GNS_PHASE_DELEGATE_DHT-%llu: Got name: %s (wanted %s)\n",
2260 "GNS_PHASE_DELEGATE_DHT-%llu: Got name: %s (wanted %s)\n", 2265 rh->id, name, rh->authority_name);
2261 rh->id, name, rh->authority_name);
2262 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2266 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG,
2263 "GNS_PHASE_DELEGATE_DHT-%llu: Got type: %d (wanted %d)\n", 2267 "GNS_PHASE_DELEGATE_DHT-%llu: Got type: %d (wanted %d)\n",
2264 rh->id, rd[i].record_type, GNUNET_GNS_RECORD_PKEY); 2268 rh->id, rd[i].record_type, GNUNET_GNS_RECORD_PKEY);
@@ -2828,18 +2832,17 @@ handle_delegation_dht(void* cls, struct ResolverHandle *rh,
2828 * @param rh the pending gns query 2832 * @param rh the pending gns query
2829 */ 2833 */
2830static void 2834static void
2831resolve_delegation_dht(struct ResolverHandle *rh) 2835resolve_delegation_dht (struct ResolverHandle *rh)
2832{ 2836{
2833 uint32_t xquery; 2837 uint32_t xquery;
2834 struct GNUNET_HashCode lookup_key; 2838 struct GNUNET_HashCode lookup_key;
2835 struct ResolverHandle *rh_heap_root; 2839 struct ResolverHandle *rh_heap_root;
2836 2840
2837 pop_tld(rh->name, rh->authority_name); 2841 pop_tld (rh->name, rh->authority_name);
2838 2842 GNUNET_GNS_get_key_for_record (rh->authority_name,
2839 GNUNET_GNS_get_key_for_record (rh->authority_name, &rh->authority, &lookup_key); 2843 &rh->authority,
2840 2844 &lookup_key);
2841 rh->dht_heap_node = NULL; 2845 rh->dht_heap_node = NULL;
2842
2843 if (rh->timeout.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value) 2846 if (rh->timeout.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value)
2844 { 2847 {
2845 rh->timeout_cont = &dht_authority_lookup_timeout; 2848 rh->timeout_cont = &dht_authority_lookup_timeout;
@@ -2855,32 +2858,35 @@ resolve_delegation_dht(struct ResolverHandle *rh)
2855 GNUNET_DHT_get_stop (rh_heap_root->get_handle); 2858 GNUNET_DHT_get_stop (rh_heap_root->get_handle);
2856 rh_heap_root->get_handle = NULL; 2859 rh_heap_root->get_handle = NULL;
2857 rh_heap_root->dht_heap_node = NULL; 2860 rh_heap_root->dht_heap_node = NULL;
2858 2861 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2859 GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, 2862 "GNS_PHASE_DELEGATE_DHT-%llu: Replacing oldest background query for %s\n",
2860 "GNS_PHASE_DELEGATE_DHT-%llu: Replacing oldest background query for %s\n", 2863 rh->id,
2861 rh->id, rh_heap_root->authority_name); 2864 rh_heap_root->authority_name);
2862 2865 rh_heap_root->proc (rh_heap_root->proc_cls,
2863 rh_heap_root->proc(rh_heap_root->proc_cls, 2866 rh_heap_root,
2864 rh_heap_root, 2867 0,
2865 0, 2868 NULL);
2866 NULL);
2867 } 2869 }
2868 rh->dht_heap_node = GNUNET_CONTAINER_heap_insert (dht_lookup_heap, 2870 rh->dht_heap_node = GNUNET_CONTAINER_heap_insert (dht_lookup_heap,
2869 rh, 2871 rh,
2870 GNUNET_TIME_absolute_get().abs_value); 2872 GNUNET_TIME_absolute_get().abs_value);
2871 } 2873 }
2872 2874 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
2873 xquery = htonl(GNUNET_GNS_RECORD_PKEY); 2875 "Beginning DHT lookup for %s in zone %s for request %llu\n",
2874 GNUNET_assert(rh->get_handle == NULL); 2876 rh->authority_name,
2875 rh->get_handle = GNUNET_DHT_get_start(dht_handle, 2877 GNUNET_short_h2s (&rh->authority),
2876 GNUNET_BLOCK_TYPE_GNS_NAMERECORD, 2878 rh->id);
2877 &lookup_key, 2879 xquery = htonl (GNUNET_GNS_RECORD_PKEY);
2878 DHT_GNS_REPLICATION_LEVEL, 2880 GNUNET_assert (rh->get_handle == NULL);
2879 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE, 2881 rh->get_handle = GNUNET_DHT_get_start (dht_handle,
2880 &xquery, 2882 GNUNET_BLOCK_TYPE_GNS_NAMERECORD,
2881 sizeof(xquery), 2883 &lookup_key,
2882 &process_delegation_result_dht, 2884 DHT_GNS_REPLICATION_LEVEL,
2883 rh); 2885 GNUNET_DHT_RO_DEMULTIPLEX_EVERYWHERE,
2886 &xquery,
2887 sizeof(xquery),
2888 &process_delegation_result_dht,
2889 rh);
2884} 2890}
2885 2891
2886 2892
@@ -3404,8 +3410,9 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone,
3404 char* nzkey_ptr = nzkey; 3410 char* nzkey_ptr = nzkey;
3405 3411
3406 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3412 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3407 "Starting resolution for %s (type=%d)!\n", 3413 "Starting resolution for %s (type=%d) with timeout %s!\n",
3408 name, record_type); 3414 name, record_type,
3415 GNUNET_STRINGS_relative_time_to_string (timeout, GNUNET_YES));
3409 3416
3410 if ((is_canonical ((char*)name) == GNUNET_YES) && 3417 if ((is_canonical ((char*)name) == GNUNET_YES) &&
3411 (strcmp(GNUNET_GNS_TLD, name) != 0)) 3418 (strcmp(GNUNET_GNS_TLD, name) != 0))
@@ -3438,8 +3445,9 @@ gns_resolver_lookup_record (struct GNUNET_CRYPTO_ShortHashCode zone,
3438 * Set timeout for authority lookup phase to 1/2 3445 * Set timeout for authority lookup phase to 1/2
3439 */ 3446 */
3440 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 3447 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
3441 "Timeout for lookup set to %ds\n", rh->timeout.rel_value); 3448 "Timeout for lookup set to %s/2\n",
3442 rh->timeout_task = GNUNET_SCHEDULER_add_delayed( 3449 GNUNET_STRINGS_relative_time_to_string (rh->timeout, GNUNET_YES));
3450 rh->timeout_task = GNUNET_SCHEDULER_add_delayed (
3443 GNUNET_TIME_relative_divide(timeout, 2), 3451 GNUNET_TIME_relative_divide(timeout, 2),
3444 &handle_lookup_timeout, 3452 &handle_lookup_timeout,
3445 rh); 3453 rh);
diff --git a/src/gns/test_gns_dht_default.conf b/src/gns/test_gns_dht_default.conf
index cca3b4338..b22f002fb 100644
--- a/src/gns/test_gns_dht_default.conf
+++ b/src/gns/test_gns_dht_default.conf
@@ -68,7 +68,7 @@ UNIXPATH = /tmp/gnunet-service-gns-default.sock
68HOME = $SERVICEHOME 68HOME = $SERVICEHOME
69AUTO_IMPORT_PKEY = NO 69AUTO_IMPORT_PKEY = NO
70MAX_PARALLEL_BACKGROUND_QUERIES = 10 70MAX_PARALLEL_BACKGROUND_QUERIES = 10
71DEFAULT_LOOKUP_TIMEOUT = 10 71DEFAULT_LOOKUP_TIMEOUT = 10 s
72RECORD_PUT_INTERVAL = 2 s 72RECORD_PUT_INTERVAL = 2 s
73 73
74[namestore] 74[namestore]
diff --git a/src/gns/test_gns_simple_lookup.conf b/src/gns/test_gns_simple_lookup.conf
index 8143eddca..ca1699c2f 100644
--- a/src/gns/test_gns_simple_lookup.conf
+++ b/src/gns/test_gns_simple_lookup.conf
@@ -85,7 +85,7 @@ UNIXPATH = /tmp/gnunet-service-gns.sock
85HOME = $SERVICEHOME 85HOME = $SERVICEHOME
86AUTO_IMPORT_PKEY = YES 86AUTO_IMPORT_PKEY = YES
87MAX_PARALLEL_BACKGROUND_QUERIES = 10 87MAX_PARALLEL_BACKGROUND_QUERIES = 10
88DEFAULT_LOOKUP_TIMEOUT = 15 88DEFAULT_LOOKUP_TIMEOUT = 15 s
89RECORD_PUT_INTERVAL = 1 h 89RECORD_PUT_INTERVAL = 1 h
90 90
91[nse] 91[nse]