- changes
authorMatthias Wachs <wachs@net.in.tum.de>
Wed, 29 Feb 2012 09:59:50 +0000 (09:59 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Wed, 29 Feb 2012 09:59:50 +0000 (09:59 +0000)
src/namestore/namestore_common.c
src/namestore/test_namestore_api_lookup.c

index 7112303513ff2a359dd3701bd28f242b10c359a0..44c8110bbf110e66f03d22ab789a14812aa38517 100644 (file)
@@ -128,6 +128,12 @@ GNUNET_NAMESTORE_records_deserialize ( struct GNUNET_NAMESTORE_RecordData **dest
   uint32_t data_size;
   int c;
 
+  if (len == 0)
+  {
+    (*dest) = NULL;
+    return 0;
+  }
+
   offset = 0;
   elements = 0;
   while (offset < len)
@@ -141,6 +147,13 @@ GNUNET_NAMESTORE_records_deserialize ( struct GNUNET_NAMESTORE_RecordData **dest
     elements ++;
   }
 
+  if (elements == 0)
+  {
+    (*dest) = NULL;
+    return 0;
+  }
+
+
   GNUNET_assert (len == offset);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Deserializing %i records with total length of %u\n", elements, len);
 
index 2ec589a20e35e887ed0e88e1481f5a95df1aacf8..0841fb2165494a109416c5f8342c4eaebd0b22ab 100644 (file)
@@ -122,17 +122,26 @@ end (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
 void name_lookup_proc (void *cls,
                             const struct GNUNET_CRYPTO_RsaPublicKeyBinaryEncoded *zone_key,
                             struct GNUNET_TIME_Absolute expire,
-                            const char *name,
+                            const char *n,
                             unsigned int rd_count,
                             const struct GNUNET_NAMESTORE_RecordData *rd,
                             const struct GNUNET_CRYPTO_RsaSignature *signature)
 {
-  if (name != NULL)
+  static int found = GNUNET_NO;
+
+  if (n != NULL)
+  {
+    found = GNUNET_YES;
     res = 0;
+  }
   else
   {
-    GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Failed to lookup records for name `%s'\n", zone_key, name, rd_count, rd, signature);
-    res = 1;
+    if (found != GNUNET_YES)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to lookup records for name `%s'\n", name);
+      res = 1;
+    }
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Lookup done for name %s'\n", name);
   }
 
   GNUNET_SCHEDULER_add_now(&end, NULL);
@@ -152,6 +161,7 @@ put_cont (void *cls, int32_t success, const char *emsg)
   else
   {
     res = 1;
+    GNUNET_log (GNUNET_ERROR_TYPE_ERROR, "Failed to put records for name `%s'\n", name);
     GNUNET_SCHEDULER_add_now(&end, NULL);
   }
 }