fix tests and do not assert since this will break make check
[oweals/gnunet.git] / src / namestore / gnunet-service-namestore.c
index 3332ffcc6297824762e90759e61a218e67299c20..f793c50d7fda8c8f521f4f21b84d4c6027cbbe85 100644 (file)
@@ -623,7 +623,6 @@ handle_record_lookup (void *cls,
   uint32_t name_len;
   size_t src_size;
   size_t res_size;
-  int offset;
   int res;
 
   if (ntohs (message->size) < sizeof (struct LabelLookupMessage))
@@ -657,6 +656,12 @@ handle_record_lookup (void *cls,
               "Received `%s' message for name `%s'\n",
               "NAMESTORE_RECORD_LOOKUP", name_tmp);
 
+  if (NULL == (client_lookup (client)))
+  {
+    GNUNET_break (0);
+    GNUNET_SERVER_receive_done (client, GNUNET_SYSERR);
+    return;
+  }
 
   rlc.label = name_tmp;
   rlc.found = GNUNET_NO;
@@ -664,15 +669,8 @@ handle_record_lookup (void *cls,
   rlc.rd_ser_len = 0;
   rlc.res_rd = NULL;
 
-  offset = 0;
-  do
-  {
-    /* changee this call */
-    res = GSN_database->iterate_records (GSN_database->cls,
-        &ll_msg->zone, offset, &lookup_it, &rlc);
-    offset++;
-  }
-  while ((GNUNET_NO == rlc.found) && (GNUNET_OK == res));
+  res = GSN_database->lookup_records (GSN_database->cls,
+        &ll_msg->zone, name_tmp, &lookup_it, &rlc);
 
   res_size = sizeof (struct LabelLookupResponseMessage) + name_len + rlc.rd_ser_len;
   llr_msg = GNUNET_malloc (res_size);
@@ -684,6 +682,10 @@ handle_record_lookup (void *cls,
   llr_msg->rd_count = htons (rlc.res_rd_count);
   llr_msg->rd_len = htons (rlc.rd_ser_len);
   res_name = (char *) &llr_msg[1];
+  if  ((GNUNET_YES == rlc.found) && (GNUNET_OK == res))
+    llr_msg->found = ntohs (GNUNET_YES);
+  else
+    llr_msg->found = ntohs (GNUNET_NO);
   memcpy (&llr_msg[1], name_tmp, name_len);
   memcpy (&res_name[name_len], rlc.res_rd, rlc.rd_ser_len);
 
@@ -1022,7 +1024,7 @@ enum ZoneIterationResult
 
 /**
  * Context for record remove operations passed from
- * #run_zone_iteration_round to #zone_iteraterate_proc as closure
+ * #run_zone_iteration_round to #zone_iterate_proc as closure
  */
 struct ZoneIterationProcResult
 {