From ba5736672201f5c3a97c7e8b46f716077b416d6c Mon Sep 17 00:00:00 2001 From: Martin Schanzenbach Date: Wed, 28 Mar 2012 11:12:19 +0000 Subject: [PATCH] -fixes, cleanup --- src/gns/gns_api.c | 6 ++-- src/gns/gnunet-service-gns_resolver.c | 22 +++++++-------- src/gns/gnunet-service-gns_resolver.h | 39 ++++++++++++-------------- src/gns/test_gns_max_queries.c | 7 +++-- src/gns/testdb/sqlite-alice.db | Bin 17408 -> 17408 bytes src/gns/testdb/sqlite-bob.db | Bin 14336 -> 14336 bytes src/gns/testdb/sqlite-dave.db | Bin 17408 -> 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, memcpy(&lookup_msg[1], name, strlen(name)); - GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, + GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail, pending); process_pending_messages (handle); @@ -743,7 +743,7 @@ GNUNET_GNS_shorten (struct GNUNET_GNS_Handle *handle, memcpy(&shorten_msg[1], name, strlen(name)); - GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, + GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail, pending); process_pending_messages (handle); @@ -800,7 +800,7 @@ GNUNET_GNS_get_authority (struct GNUNET_GNS_Handle *handle, memcpy(&get_auth_msg[1], name, strlen(name)); - GNUNET_CONTAINER_DLL_insert (handle->pending_head, handle->pending_tail, + GNUNET_CONTAINER_DLL_insert_tail (handle->pending_head, handle->pending_tail, pending); 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, ResolverCleanupContinuation cont = cls; GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, - "GNS_CLEANUP-%d: Terminating background lookup for %s\n", + "GNS_CLEANUP-%llu: Terminating background lookup for %s\n", rh->id, rh->name); GNUNET_DHT_get_stop(rh->get_handle); rh->get_handle = NULL; @@ -914,12 +914,12 @@ process_record_result_ns(void* cls, if (name != NULL) { - rh->status |= EXISTS; + rh->status |= RSL_RECORD_EXISTS; } if (remaining_time.rel_value == 0) { - rh->status |= EXPIRED; + rh->status |= RSL_RECORD_EXPIRED; } if (rd_count == 0) @@ -1049,7 +1049,7 @@ dht_authority_lookup_timeout(void *cls, "GNS_PHASE_DELEGATE_DHT-%llu: dht lookup for query %s (%ds)timed out.\n", rh->id, rh->authority_name, rh->timeout.rel_value); - rh->status |= TIMED_OUT; + rh->status |= RSL_TIMED_OUT; rh->timeout_task = GNUNET_SCHEDULER_NO_TASK; @@ -1495,7 +1495,7 @@ handle_record_ns(void* cls, struct ResolverHandle *rh, /** * There are 4 conditions that have to met for us to consult the DHT: - * 1. The entry in the DHT is EXPIRED AND + * 1. The entry in the DHT is RSL_RECORD_EXPIRED AND * 2. No entry in the NS existed AND * 3. The zone queried is not the local resolver's zone AND * 4. The name that was looked up is '+' @@ -1503,7 +1503,7 @@ handle_record_ns(void* cls, struct ResolverHandle *rh, * the DHT for the authority in the authority lookup phase (and thus * would already have an entry in the NS for the record) */ - if (rh->status & (EXPIRED | !EXISTS) && + if (rh->status & (RSL_RECORD_EXPIRED | !RSL_RECORD_EXISTS) && GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, &local_zone) && (strcmp(rh->name, "+") == 0)) @@ -1792,9 +1792,9 @@ handle_delegation_ns(void* cls, struct ResolverHandle *rh, * and exists * or we are authority **/ - if ((rh->status & (EXISTS | !EXPIRED)) || - !GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, - &rh->authority_chain_tail->zone)) + if (((rh->status & RSL_RECORD_EXISTS) && (rh->status & !RSL_RECORD_EXPIRED)) + || !GNUNET_CRYPTO_short_hash_cmp(&rh->authority_chain_head->zone, + &local_zone)) { if (is_canonical(rh->name)) { @@ -1869,12 +1869,12 @@ process_delegation_result_ns(void* cls, if (name != NULL) { - rh->status |= EXISTS; + rh->status |= RSL_RECORD_EXISTS; } if (remaining_time.rel_value == 0) { - rh->status |= EXPIRED; + rh->status |= RSL_RECORD_EXPIRED; } /** 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; typedef void (*ResolverCleanupContinuation) (void); /** - * processor for a resultion result + * processor for a record lookup result * * @param cls the closure * @param rd_count number of results - * @param rd resukt data + * @param rd result data */ typedef void (*RecordLookupProcessor) (void *cls, uint32_t rd_count, @@ -70,7 +70,7 @@ typedef void (*ShortenResultProcessor) (void *cls, const char* name); typedef void (*GetAuthorityResultProcessor) (void *cls, const char* name); /** - * processor for a resultion result + * processor for a resolution result * * @param cls the closure * @param rh the resolution handle @@ -84,19 +84,27 @@ typedef void (*ResolutionResultProcessor) (void *cls, /** - * Resoltion status indicator - * EXISTS: the name to lookup exists - * EXPIRED: the name in the record expired + * Resolution status indicator + * RSL_RECORD_EXISTS: the name to lookup exists + * RSL_RECORD_EXPIRED: the name in the record expired + * RSL_TIMED_OUT: resolution timed out */ enum ResolutionStatus { - EXISTS = 1, - EXPIRED = 2, - TIMED_OUT = 4 + RSL_RECORD_EXISTS = 1, + RSL_RECORD_EXPIRED = 2, + RSL_TIMED_OUT = 4 }; /** * Handle to a currenty pending resolution + * a ResolverHandle is passed to, for example + * resolve_record_ns to resolve a record in the namestore. + * On result (positive or negative) the ResolutionResultProcessor + * is called. + * If a timeout is set timeout_cont will be called. + * If no timeout is set (ie timeout forever) then background resolutions + * might be triggered. */ struct ResolverHandle { @@ -112,12 +120,6 @@ struct ResolverHandle /* the name of the authoritative zone to query */ char authority_name[MAX_DNS_LABEL_LENGTH]; - /** - * we have an authority in namestore that - * may be able to resolve - */ - int authority_found; - /* a handle for dht lookups. should be NULL if no lookups are in progress */ struct GNUNET_DHT_GetHandle *get_handle; @@ -193,14 +195,11 @@ struct RecordLookupHandle */ struct NameShortenHandle { - - /* Method to call on shorten result */ ShortenResultProcessor proc; /* closure to pass to proc */ void* proc_cls; - }; /** @@ -208,7 +207,6 @@ struct NameShortenHandle */ struct GetNameAuthorityHandle { - /* the name to look up authority for */ char name[MAX_DNS_NAME_LENGTH]; @@ -217,7 +215,6 @@ struct GetNameAuthorityHandle /* closure to pass to proc */ void* proc_cls; - }; /** @@ -276,7 +273,7 @@ gns_resolver_cleanup(ResolverCleanupContinuation cont); /** * Lookup of a record in a specific zone - * calls lookup result processor on result + * calls RecordLookupProcessor on result or timeout * * @param zone the root zone * @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) ok = 2; } - GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A, - &on_lookup_result, TEST_DOMAIN); /* Now lookup some non existing records */ for (i=0; i>b}6sB7WyWA&MQP)vFA96mM{ zMvlq)!m5*PgcLTv5Yl4dge#i7UrcqggE%`##Xl*P%{kJ`n2}_qmLAIo)<569>#x0MUmzKmY&$ delta 157 zcmZqZU~K4MoFL7}J5k1&k#}Q4H#Z~O<~Q7pOgvY(+xb_B^U1UMvHDCtD5ku54j&r} zBim$sVb#etLJFH-2x+l!!WB*4FQ&TLL7W|=;-8et<{ar|%t*4*@*h|?GoNLCzF9zF eIg-TY1Ilg^o7oH!7=hNNJ5FTcfSI_+h6MoaaxHBD diff --git a/src/gns/testdb/sqlite-bob.db b/src/gns/testdb/sqlite-bob.db index c7c10534ea2707d9342ee3340b009f0f6aa7ae6c..293cbf2283cf44c96779e9edde3b29bbe51f58ca 100644 GIT binary patch delta 17 YcmZoDXegK<&1g1J#+lJ