gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[GNUnet-SVN] r32499 - in gnunet/src: gns include


From: gnunet
Subject: [GNUnet-SVN] r32499 - in gnunet/src: gns include
Date: Tue, 4 Mar 2014 12:26:26 +0100

Author: grothoff
Date: 2014-03-04 12:26:26 +0100 (Tue, 04 Mar 2014)
New Revision: 32499

Modified:
   gnunet/src/gns/gns.h
   gnunet/src/gns/gns_api.c
   gnunet/src/gns/gnunet-gns.c
   gnunet/src/gns/gnunet-service-gns.c
   gnunet/src/gns/gnunet-service-gns_resolver.c
   gnunet/src/gns/gnunet-service-gns_resolver.h
   gnunet/src/include/gnunet_gns_service.h
Log:
-presumably better fix for instantly resolving names in master zone

Modified: gnunet/src/gns/gns.h
===================================================================
--- gnunet/src/gns/gns.h        2014-03-04 11:25:27 UTC (rev 32498)
+++ gnunet/src/gns/gns.h        2014-03-04 11:26:26 UTC (rev 32499)
@@ -66,9 +66,10 @@
   struct GNUNET_CRYPTO_EcdsaPublicKey zone;
 
   /**
-   * Only check cached results
+   * Local options for where to look for results
+   * (an `enum GNUNET_GNS_LocalOptions` in NBO).
    */
-  int16_t only_cached GNUNET_PACKED;
+  int16_t options GNUNET_PACKED;
 
   /**
    * Is a shorten key attached?

Modified: gnunet/src/gns/gns_api.c
===================================================================
--- gnunet/src/gns/gns_api.c    2014-03-04 11:25:27 UTC (rev 32498)
+++ gnunet/src/gns/gns_api.c    2014-03-04 11:26:26 UTC (rev 32499)
@@ -523,7 +523,7 @@
  * @param name the name to look up
  * @param zone the zone to start the resolution in
  * @param type the record type to look up
- * @param only_cached #GNUNET_YES to only check locally (not in the DHT)
+ * @param options local options for the lookup
  * @param shorten_zone_key the private key of the shorten zone (can be NULL)
  * @param proc processor to call on result
  * @param proc_cls closure for @a proc
@@ -534,7 +534,7 @@
                   const char *name,
                   const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
                   uint32_t type,
-                  int only_cached,
+                  enum GNUNET_GNS_LocalOptions options,
                   const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone_key,
                   GNUNET_GNS_LookupResultProcessor proc,
                   void *proc_cls)
@@ -576,7 +576,7 @@
   lookup_msg->header.type = htons (GNUNET_MESSAGE_TYPE_GNS_LOOKUP);
   lookup_msg->header.size = htons (msize);
   lookup_msg->id = htonl (lr->r_id);
-  lookup_msg->only_cached = htons (only_cached);
+  lookup_msg->options = htons ((uint16_t) options);
   lookup_msg->zone = *zone;
   lookup_msg->type = htonl (type);
   if (NULL != shorten_zone_key)

Modified: gnunet/src/gns/gnunet-gns.c
===================================================================
--- gnunet/src/gns/gnunet-gns.c 2014-03-04 11:25:27 UTC (rev 32498)
+++ gnunet/src/gns/gnunet-gns.c 2014-03-04 11:26:26 UTC (rev 32499)
@@ -66,9 +66,9 @@
 static char *public_key;
 
 /**
- * Set to #GNUNET_YES if we must not use the DHT (only local lookup).
+ * Set to GNUNET_GNS_LO_LOCAL_MASTER if we are looking up in the master zone.
  */
-static int only_cached;
+static enum GNUNET_GNS_LocalOptions local_options;
 
 /**
  * raw output
@@ -216,7 +216,7 @@
                                        lookup_name,
                                        pkey,
                                        rtype,
-                                       only_cached,
+                                       local_options,
                                        shorten_key,
                                        &process_lookup_result,
                                        lookup_name);
@@ -349,13 +349,16 @@
     return;
   }
   GNUNET_IDENTITY_ego_get_public_key (ego, &pkey);
+  /* main name is our own master zone, do no look for that in the DHT */
+  local_options = GNUNET_GNS_LO_LOCAL_MASTER;
+
   /* if the name is of the form 'label.gnu', never go to the DHT */
   dot = NULL;
   if (NULL != lookup_name)
     dot = strchr (lookup_name, '.');
   if ( (NULL != dot) &&
        (0 == strcasecmp (dot, ".gnu")) )
-    only_cached = GNUNET_YES;
+    local_options = GNUNET_GNS_LO_NO_DHT;
   lookup_with_public_key (&pkey);
 }
 

Modified: gnunet/src/gns/gnunet-service-gns.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns.c 2014-03-04 11:25:27 UTC (rev 32498)
+++ gnunet/src/gns/gnunet-service-gns.c 2014-03-04 11:26:26 UTC (rev 32499)
@@ -788,7 +788,7 @@
                                     ntohl (sh_msg->type),
                                     name,
                                     key,
-                                    ntohs (sh_msg->only_cached),
+                                    (enum GNUNET_GNS_LocalOptions) ntohs 
(sh_msg->options),
                                     &send_lookup_response, clh);
   GNUNET_STATISTICS_update (statistics,
                             "Lookup attempts",

Modified: gnunet/src/gns/gnunet-service-gns_resolver.c
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.c        2014-03-04 11:25:27 UTC 
(rev 32498)
+++ gnunet/src/gns/gnunet-service-gns_resolver.c        2014-03-04 11:26:26 UTC 
(rev 32499)
@@ -365,7 +365,7 @@
   /**
    * Use only cache
    */
-  int only_cached;
+  enum GNUNET_GNS_LocalOptions options;
 
   /**
    * Desired type for the resolution.
@@ -1779,7 +1779,7 @@
         g2dc->rh->proc = &handle_gns2dns_result;
         g2dc->rh->proc_cls = rh;
         g2dc->rh->record_type = GNUNET_GNSRECORD_TYPE_ANY;
-        g2dc->rh->only_cached = GNUNET_NO;
+        g2dc->rh->options = GNUNET_GNS_LO_DEFAULT;
         g2dc->rh->loop_limiter = rh->loop_limiter + 1;
         rh->g2dc = g2dc;
         start_resolver_lookup (g2dc->rh);
@@ -2011,7 +2011,9 @@
 
   GNUNET_assert (NULL != rh->namecache_qe);
   rh->namecache_qe = NULL;
-  if ( (GNUNET_NO == rh->only_cached) &&
+  if ( ( (GNUNET_GNS_LO_DEFAULT == rh->options) ||
+        ( (GNUNET_GNS_LO_LOCAL_MASTER == rh->options) &&
+          (ac != rh->ac_head) ) ) &&
        ( (NULL == block) ||
         (0 == GNUNET_TIME_absolute_get_remaining (GNUNET_TIME_absolute_ntoh 
(block->expiration_time)).rel_value_us) ) )
   {
@@ -2303,7 +2305,7 @@
  * @param record_type the record type to look up
  * @param name the name to look up
  * @param shorten_key a private key for use with PSEU import (can be NULL)
- * @param only_cached #GNUNET_NO to only check locally not DHT for performance
+ * @param options local options to control local lookup
  * @param proc the processor to call on result
  * @param proc_cls the closure to pass to @a proc
  * @return handle to cancel operation
@@ -2313,7 +2315,7 @@
                     uint32_t record_type,
                     const char *name,
                     const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key,
-                    int only_cached,
+                    enum GNUNET_GNS_LocalOptions options,
                     GNS_ResultProcessor proc, void *proc_cls)
 {
   struct GNS_ResolverHandle *rh;
@@ -2330,7 +2332,7 @@
   rh->authority_zone = *zone;
   rh->proc = proc;
   rh->proc_cls = proc_cls;
-  rh->only_cached = only_cached;
+  rh->options = options;
   rh->record_type = record_type;
   rh->name = GNUNET_strdup (name);
   rh->name_resolution_pos = strlen (name);

Modified: gnunet/src/gns/gnunet-service-gns_resolver.h
===================================================================
--- gnunet/src/gns/gnunet-service-gns_resolver.h        2014-03-04 11:25:27 UTC 
(rev 32498)
+++ gnunet/src/gns/gnunet-service-gns_resolver.h        2014-03-04 11:26:26 UTC 
(rev 32499)
@@ -26,6 +26,7 @@
 #define GNS_RESOLVER_H
 #include "gns.h"
 #include "gnunet_dht_service.h"
+#include "gnunet_gns_service.h"
 #include "gnunet_namecache_service.h"
 
 /**
@@ -77,7 +78,7 @@
  * @param record_type the record type to look up
  * @param name the name to look up
  * @param shorten_key optional private key for authority caching, can be NULL
- * @param only_cached GNUNET_NO to only check locally not DHT for performance
+ * @param options options set to control local lookup
  * @param proc the processor to call
  * @param proc_cls the closure to pass to @a proc
  * @return handle to cancel operation
@@ -87,7 +88,7 @@
                     uint32_t record_type,
                     const char *name,
                     const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_key,
-                    int only_cached,
+                    enum GNUNET_GNS_LocalOptions options,
                     GNS_ResultProcessor proc,
                     void *proc_cls);
 

Modified: gnunet/src/include/gnunet_gns_service.h
===================================================================
--- gnunet/src/include/gnunet_gns_service.h     2014-03-04 11:25:27 UTC (rev 
32498)
+++ gnunet/src/include/gnunet_gns_service.h     2014-03-04 11:26:26 UTC (rev 
32499)
@@ -1,6 +1,6 @@
 /*
       This file is part of GNUnet
-      (C) 2012-2013 Christian Grothoff (and other contributing authors)
+      (C) 2012-2014 Christian Grothoff (and other contributing authors)
 
       GNUnet is free software; you can redistribute it and/or modify
       it under the terms of the GNU General Public License as published
@@ -88,13 +88,37 @@
 
 
 /**
+ * Options for the GNS lookup.
+ */
+enum GNUNET_GNS_LocalOptions
+{
+  /**
+   * Defaults, look in cache, then in DHT.
+   */
+  GNUNET_GNS_LO_DEFAULT = 0,
+
+  /**
+   * Never look in the DHT, keep request to local cache.
+   */
+  GNUNET_GNS_LO_NO_DHT = 1,
+  
+  /**
+   * For the rightmost label, only look in the cache (it
+   * is our master zone), for the others, the DHT is OK.
+   */
+  GNUNET_GNS_LO_LOCAL_MASTER = 2
+
+};
+
+
+/**
  * Perform an asynchronous lookup operation on the GNS.
  *
  * @param handle handle to the GNS service
  * @param name the name to look up
  * @param zone zone to look in
  * @param type the GNS record type to look for
- * @param only_cached #GNUNET_YES to only check locally (not in the DHT)
+ * @param options local options for the lookup
  * @param shorten_zone_key the private key of the shorten zone (can be NULL);
  *                    specify to enable automatic shortening (given a PSEU
  *                    record, if a given pseudonym is not yet used in the
@@ -109,7 +133,7 @@
                   const char *name,
                   const struct GNUNET_CRYPTO_EcdsaPublicKey *zone,
                   uint32_t type,
-                  int only_cached,
+                  enum GNUNET_GNS_LocalOptions options,
                   const struct GNUNET_CRYPTO_EcdsaPrivateKey *shorten_zone_key,
                   GNUNET_GNS_LookupResultProcessor proc,
                   void *proc_cls);




reply via email to

[Prev in Thread] Current Thread [Next in Thread]