-fixes, cleanup
authorMartin Schanzenbach <mschanzenbach@posteo.de>
Wed, 28 Mar 2012 11:12:19 +0000 (11:12 +0000)
committerMartin Schanzenbach <mschanzenbach@posteo.de>
Wed, 28 Mar 2012 11:12:19 +0000 (11:12 +0000)
src/gns/gns_api.c
src/gns/gnunet-service-gns_resolver.c
src/gns/gnunet-service-gns_resolver.h
src/gns/test_gns_max_queries.c
src/gns/testdb/sqlite-alice.db
src/gns/testdb/sqlite-bob.db
src/gns/testdb/sqlite-dave.db

index 09e5426f9d494fde7418bfc4480235ed51da0f8b..4b7d6b9f8a7e6cd742f541da1070e6ece3f5aafe 100644 (file)
@@ -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);
index 591aed031dfd9e7c66efb6d3baff9a04c836b576..964afb4f41c401c7f163ca98ce30467a811dd9d7 100644 (file)
@@ -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;
   }
   
   /**
index f8c662bc22a4f78b5943d0493ac03cc4c78820b1..17d0a7221477feddade87d5c12ede8e8339cab71 100644 (file)
@@ -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
index 9b91260546e314c810284913319ec2a653e15fb8..b95bff8c797cbbf8a5ac5d6c5e0d6fa5acd32e9c 100644 (file)
@@ -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<max_parallel_lookups+TEST_ADDITIONAL_LOOKUPS; i++)
   {
     GNUNET_snprintf(lookup_name,
                     MAX_DNS_NAME_LENGTH,
-                    "doesnotexist-%d.bob.gnunet", i);
+                    "www.doesnotexist-%d.bob.gnunet", i);
     GNUNET_GNS_lookup(gns_handle, lookup_name, GNUNET_GNS_RECORD_TYPE_A,
                       &on_lookup_result_dummy, NULL);
   }
+
+  GNUNET_GNS_lookup(gns_handle, TEST_DOMAIN, GNUNET_GNS_RECORD_TYPE_A,
+                    &on_lookup_result, TEST_DOMAIN);
 }
 
 
index b3379dedb7b94785a6a3b60636e6f28c13e3b6aa..88b2d5c27b839def5ea17074018b76afceba339b 100644 (file)
Binary files a/src/gns/testdb/sqlite-alice.db and b/src/gns/testdb/sqlite-alice.db differ
index c7c10534ea2707d9342ee3340b009f0f6aa7ae6c..293cbf2283cf44c96779e9edde3b29bbe51f58ca 100644 (file)
Binary files a/src/gns/testdb/sqlite-bob.db and b/src/gns/testdb/sqlite-bob.db differ
index bc164987b6503b3892f9c069417d76a8c5a127ac..4d105d5355f86af3e32ecc7442db618f8bec5c18 100644 (file)
Binary files a/src/gns/testdb/sqlite-dave.db and b/src/gns/testdb/sqlite-dave.db differ