gnunet-svn
[Top][All Lists]
Advanced

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

[GNUnet-SVN] r29837 - gnunet/src/namestore


From: gnunet
Subject: [GNUnet-SVN] r29837 - gnunet/src/namestore
Date: Fri, 4 Oct 2013 09:22:37 +0200

Author: grothoff
Date: 2013-10-04 09:22:37 +0200 (Fri, 04 Oct 2013)
New Revision: 29837

Modified:
   gnunet/src/namestore/gnunet-namestore.c
   gnunet/src/namestore/gnunet-service-namestore.c
   gnunet/src/namestore/namestore_api.c
   gnunet/src/namestore/namestore_api_common.c
Log:
-do set expiration time when storing records, works better that way...

Modified: gnunet/src/namestore/gnunet-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-namestore.c     2013-10-04 05:49:34 UTC (rev 
29836)
+++ gnunet/src/namestore/gnunet-namestore.c     2013-10-04 07:22:37 UTC (rev 
29837)
@@ -428,6 +428,15 @@
     rde->flags |= GNUNET_NAMESTORE_RF_SHADOW_RECORD;
   if (1 != public)
     rde->flags |= GNUNET_NAMESTORE_RF_PRIVATE;
+  if (GNUNET_YES == etime_is_rel)
+  {
+    rde->expiration_time = etime_rel.rel_value_us;
+    rde->flags |= GNUNET_NAMESTORE_RF_RELATIVE_EXPIRATION;
+  }
+  else if (GNUNET_NO == etime_is_rel)
+    rde->expiration_time = etime_abs.abs_value_us;
+  else    
+    rde->expiration_time = GNUNET_TIME_UNIT_FOREVER_ABS.abs_value_us;
   GNUNET_assert (NULL != name);
   add_qe = GNUNET_NAMESTORE_records_store (ns,
                                           &zone_pkey,

Modified: gnunet/src/namestore/gnunet-service-namestore.c
===================================================================
--- gnunet/src/namestore/gnunet-service-namestore.c     2013-10-04 05:49:34 UTC 
(rev 29836)
+++ gnunet/src/namestore/gnunet-service-namestore.c     2013-10-04 07:22:37 UTC 
(rev 29837)
@@ -372,8 +372,9 @@
   r->derived_key = block->derived_key;  
   memcpy (&r[1], &block[1], esize);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
-             "Sending `%s' message\n", 
-             "NAMESTORE_LOOKUP_BLOCK_RESPONSE");
+             "Sending `%s' message with expiration time %s\n", 
+             "NAMESTORE_LOOKUP_BLOCK_RESPONSE",
+              GNUNET_STRINGS_absolute_time_to_string 
(GNUNET_TIME_absolute_ntoh (r->expire)));
   GNUNET_SERVER_notification_context_unicast (snc, 
                                              lnc->nc->client, 
                                              &r->gns_header.header, 
@@ -458,9 +459,6 @@
   size_t esize;
   int res;
 
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
-             "Received `%s' message\n",
-             "NAMESTORE_BLOCK_CACHE");
   nc = client_lookup (client);
   if (ntohs (message->size) < sizeof (struct BlockCacheMessage))
   {
@@ -477,6 +475,10 @@
                               sizeof (struct GNUNET_TIME_AbsoluteNBO) +
                               esize);
   block->expiration_time = rp_msg->expire;
+  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 
+             "Received `%s' message with expiration time %s\n",
+             "NAMESTORE_BLOCK_CACHE",
+              GNUNET_STRINGS_absolute_time_to_string 
(GNUNET_TIME_absolute_ntoh (block->expiration_time)));
   memcpy (&block[1], &rp_msg[1], esize);
   res = GSN_database->cache_block (GSN_database->cls,
                                   block);

Modified: gnunet/src/namestore/namestore_api.c
===================================================================
--- gnunet/src/namestore/namestore_api.c        2013-10-04 05:49:34 UTC (rev 
29836)
+++ gnunet/src/namestore/namestore_api.c        2013-10-04 07:22:37 UTC (rev 
29837)
@@ -1056,9 +1056,10 @@
   msg->derived_key = block->derived_key;
   memcpy (&msg[1], &block[1], blen);
   LOG (GNUNET_ERROR_TYPE_DEBUG, 
-       "Sending `%s' message with size %u\n", 
+       "Sending `%s' message with size %u and expiration %s\n",
        "NAMESTORE_BLOCK_CACHE", 
-       (unsigned int) msg_size);
+       (unsigned int) msg_size,
+       GNUNET_STRINGS_absolute_time_to_string (GNUNET_TIME_absolute_ntoh 
(msg->expire)));
   GNUNET_CONTAINER_DLL_insert_tail (h->pending_head, h->pending_tail, pe);
   do_transmit (h);
   return qe;

Modified: gnunet/src/namestore/namestore_api_common.c
===================================================================
--- gnunet/src/namestore/namestore_api_common.c 2013-10-04 05:49:34 UTC (rev 
29836)
+++ gnunet/src/namestore/namestore_api_common.c 2013-10-04 07:22:37 UTC (rev 
29837)
@@ -36,7 +36,7 @@
 #include "namestore.h"
 
 
-#define LOG(kind,...) GNUNET_log_from (kind, "gns-api",__VA_ARGS__)
+#define LOG(kind,...) GNUNET_log_from (kind, "namestore-api",__VA_ARGS__)
 
 GNUNET_NETWORK_STRUCT_BEGIN
 
@@ -162,6 +162,11 @@
   off = 0;
   for (i=0;i<rd_count;i++)
   {
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Serializing record %u with flags %d and expiration time %llu\n",
+         i,
+         rd[i].flags,
+         (unsigned long long) rd[i].expiration_time);
     rec.expiration_time = GNUNET_htonll (rd[i].expiration_time);
     rec.data_size = htonl ((uint32_t) rd[i].data_size);
     rec.record_type = htonl (rd[i].record_type);
@@ -192,44 +197,48 @@
 GNUNET_NAMESTORE_records_cmp (const struct GNUNET_NAMESTORE_RecordData *a,
                               const struct GNUNET_NAMESTORE_RecordData *b)
 {
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-      "Comparing records\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Comparing records\n");
   if (a->record_type != b->record_type)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-        "Record type %lu != %lu\n", a->record_type, b->record_type);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Record type %lu != %lu\n", a->record_type, b->record_type);
     return GNUNET_NO;
   }
   if ((a->expiration_time != b->expiration_time) &&
       ((a->expiration_time != 0) && (b->expiration_time != 0)))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-        "Expiration time %llu != %llu\n", a->expiration_time, 
b->expiration_time);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Expiration time %llu != %llu\n",
+         a->expiration_time, 
+         b->expiration_time);
     return GNUNET_NO;
   }
   if ((a->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS) 
        != (b->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-        "Flags %lu (%lu) != %lu (%lu)\n", a->flags,
-        a->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS, b->flags,
-        b->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Flags %lu (%lu) != %lu (%lu)\n", a->flags,
+         a->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS, b->flags,
+         b->flags & GNUNET_NAMESTORE_RF_RCMP_FLAGS);
     return GNUNET_NO;
   }
   if (a->data_size != b->data_size)
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-        "Data size %lu != %lu\n", a->data_size, b->data_size);
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Data size %lu != %lu\n", 
+         a->data_size, 
+         b->data_size);
     return GNUNET_NO;
   }
   if (0 != memcmp (a->data, b->data, a->data_size))
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-        "Data contents do not match\n");
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Data contents do not match\n");
     return GNUNET_NO;
   }
-  GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
-      "Records are equal\n");
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Records are equal\n");
   return GNUNET_YES;
 }
 
@@ -264,11 +273,15 @@
     dest[i].record_type = ntohl (rec.record_type);
     dest[i].flags = ntohl (rec.flags);
     off += sizeof (rec);
-
     if (off + dest[i].data_size > len)
       return GNUNET_SYSERR;
     dest[i].data = &src[off];
     off += dest[i].data_size;
+    LOG (GNUNET_ERROR_TYPE_DEBUG,
+         "Deserialized record %u with flags %d and expiration time %llu\n",
+         i,
+         dest[i].flags,
+         (unsigned long long) dest[i].expiration_time);
   }
   return GNUNET_OK; 
 }
@@ -308,6 +321,10 @@
     }
     expire = GNUNET_TIME_absolute_min (at, expire);  
   }
+  LOG (GNUNET_ERROR_TYPE_DEBUG,
+       "Determined expiration time for block with %u records to be %s\n",
+       rd_count,
+       GNUNET_STRINGS_absolute_time_to_string (expire));
   return expire;
 }
 
@@ -763,16 +780,16 @@
   switch (type)
   {
   case 0:
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-               _("Unsupported record type %d\n"),
-               (int) type);
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         _("Unsupported record type %d\n"),
+         (int) type);
     return GNUNET_SYSERR;
   case GNUNET_DNSPARSER_TYPE_A:
     if (1 != inet_pton (AF_INET, s, &value_a))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  _("Unable to parse IPv4 address `%s'\n"),
-                 s);
+      LOG (GNUNET_ERROR_TYPE_ERROR,
+           _("Unable to parse IPv4 address `%s'\n"),
+           s);
       return GNUNET_SYSERR;
     }
     *data = GNUNET_malloc (sizeof (struct in_addr));
@@ -791,9 +808,9 @@
                                             &off,
                                             s))
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   _("Failed to serialize NS record with value `%s'\n"),
-                   s);
+       LOG (GNUNET_ERROR_TYPE_ERROR,
+             _("Failed to serialize NS record with value `%s'\n"),
+             s);
        return GNUNET_SYSERR;
       }
       *data_size = off;
@@ -813,9 +830,9 @@
                                             &off,
                                             s))
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   _("Failed to serialize CNAME record with value `%s'\n"),
-                   s);
+       LOG (GNUNET_ERROR_TYPE_ERROR,
+             _("Failed to serialize CNAME record with value `%s'\n"),
+             s);
        return GNUNET_SYSERR;
       }
       *data_size = off;
@@ -841,9 +858,9 @@
                       soa_rname, soa_mname,
                       &soa_serial, &soa_refresh, &soa_retry, &soa_expire, 
&soa_min))
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   _("Unable to parse SOA record `%s'\n"),
-                   s);
+       LOG (GNUNET_ERROR_TYPE_ERROR,
+             _("Unable to parse SOA record `%s'\n"),
+             s);
        return GNUNET_SYSERR;
       }
       soa.mname = soa_mname;
@@ -860,10 +877,10 @@
                                            &off,
                                            &soa))
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   _("Failed to serialize SOA record with mname `%s' and rname 
`%s'\n"),
-                   soa_mname,
-                   soa_rname);
+       LOG (GNUNET_ERROR_TYPE_ERROR,
+             _("Failed to serialize SOA record with mname `%s' and rname 
`%s'\n"),
+             soa_mname,
+             soa_rname);
        return GNUNET_SYSERR;
       }
       *data_size = off;
@@ -883,9 +900,9 @@
                                             &off,
                                             s))
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   _("Failed to serialize PTR record with value `%s'\n"),
-                   s);
+       LOG (GNUNET_ERROR_TYPE_ERROR,
+             _("Failed to serialize PTR record with value `%s'\n"),
+             s);
        return GNUNET_SYSERR;
       }
       *data_size = off;
@@ -903,9 +920,9 @@
 
       if (2 != SSCANF(s, "%hu,%253s", &mx_pref, mxhost))
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   _("Unable to parse MX record `%s'\n"),
-                   s);
+       LOG (GNUNET_ERROR_TYPE_ERROR,
+             _("Unable to parse MX record `%s'\n"),
+             s);
       return GNUNET_SYSERR;
       }
       mx.preference = mx_pref;
@@ -918,9 +935,9 @@
                                           &off,
                                           &mx))
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   _("Failed to serialize MX record with hostname `%s'\n"),
-                   mxhost);
+       LOG (GNUNET_ERROR_TYPE_ERROR,
+             _("Failed to serialize MX record with hostname `%s'\n"),
+             mxhost);
        return GNUNET_SYSERR;
       }
       *data_size = off;
@@ -935,9 +952,9 @@
   case GNUNET_DNSPARSER_TYPE_AAAA:
     if (1 != inet_pton (AF_INET6, s, &value_aaaa))    
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  _("Unable to parse IPv6 address `%s'\n"),
-                 s);
+      LOG (GNUNET_ERROR_TYPE_ERROR,
+           _("Unable to parse IPv6 address `%s'\n"),
+           s);
       return GNUNET_SYSERR;
     }
     *data = GNUNET_malloc (sizeof (struct in6_addr));
@@ -948,9 +965,9 @@
     if (GNUNET_OK !=
        GNUNET_CRYPTO_ecc_public_sign_key_from_string (s, strlen (s), &pkey))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  _("Unable to parse PKEY record `%s'\n"),
-                 s);
+      LOG (GNUNET_ERROR_TYPE_ERROR,
+           _("Unable to parse PKEY record `%s'\n"),
+           s);
       return GNUNET_SYSERR;
     }
     *data = GNUNET_new (struct GNUNET_CRYPTO_EccPublicSignKey);
@@ -969,9 +986,9 @@
     if (3 != SSCANF (s,"%u %103s %253s",
                     &proto, s_peer, s_serv))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  _("Unable to parse VPN record string `%s'\n"),
-                 s);
+      LOG (GNUNET_ERROR_TYPE_ERROR,
+           _("Unable to parse VPN record string `%s'\n"),
+           s);
       return GNUNET_SYSERR;
     }
     *data_size = sizeof (struct GNUNET_TUN_GnsVpnRecord) + strlen (s_serv) + 1;
@@ -999,9 +1016,9 @@
                                             &off,
                                             s))
       {
-       GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                   _("Failed to serialize GNS2DNS record with value `%s'\n"),
-                   s);
+       LOG (GNUNET_ERROR_TYPE_ERROR,
+             _("Failed to serialize GNS2DNS record with value `%s'\n"),
+             s);
        return GNUNET_SYSERR;
       }
       *data_size = off;
@@ -1018,18 +1035,18 @@
                     &tlsa->matching_type,
                     (char*)&tlsa[1]))
     {
-      GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-                  _("Unable to parse TLSA record string `%s'\n"), 
-                 s);
+      LOG (GNUNET_ERROR_TYPE_ERROR,
+           _("Unable to parse TLSA record string `%s'\n"), 
+           s);
       *data_size = 0;
       GNUNET_free (tlsa);
       return GNUNET_SYSERR;
     }
     return GNUNET_OK;
   default:
-    GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
-               _("Unsupported record type %d\n"),
-               (int) type);
+    LOG (GNUNET_ERROR_TYPE_ERROR,
+         _("Unsupported record type %d\n"),
+         (int) type);
     return GNUNET_SYSERR;
   }
 }




reply via email to

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