fixes
authorChristian Grothoff <christian@grothoff.org>
Tue, 16 Mar 2010 09:55:26 +0000 (09:55 +0000)
committerChristian Grothoff <christian@grothoff.org>
Tue, 16 Mar 2010 09:55:26 +0000 (09:55 +0000)
src/hostlist/gnunet-daemon-hostlist.c
src/hostlist/hostlist-client.c
src/hostlist/hostlist-server.c

index f5db86c91f9f5fda177646f4331265ae63742de5..133308edf90af1b5a13eb66eaf4daa8764690100 100644 (file)
@@ -174,10 +174,6 @@ run (void *cls,
       return;
     }
   stats = GNUNET_STATISTICS_create (sched, "hostlist", cfg);
-  if (learning)
-    {
-      /* FIXME (register handler with core for hostlist ads) */
-    }
   if (bootstrapping)
     {
       GNUNET_HOSTLIST_client_start (cfg, sched, stats,
@@ -187,6 +183,10 @@ run (void *cls,
     {      
       GNUNET_HOSTLIST_server_start (cfg, sched, stats);
     }
+  if (learning)
+    {
+      /* FIXME (register handler with core for hostlist ads) */
+    }
   core = GNUNET_CORE_connect (sched, cfg,
                              GNUNET_TIME_UNIT_FOREVER_REL,
                              NULL,
index 99b43f0082c8dd8e2701d521dc29f29fee8045dd..90d67ee75d82498ae48636444dd32171e9c79fef 100644 (file)
@@ -148,7 +148,8 @@ download_hostlist_processor (void *ptr,
                            (int64_t) total, 
                            GNUNET_NO);  
   left = total;
-  while (left > 0)
+  while ( (left > 0) ||
+         (download_pos > 0) )
     {
       cpy = GNUNET_MIN (total, GNUNET_SERVER_MAX_MESSAGE_SIZE - download_pos);
       GNUNET_assert (cpy > 0);
index 9583d6a4f66127f3b6b7b0a1793855a3ba23a768..8422f4bcb60b73d13fc1b08f25fa4671f92cc757 100644 (file)
@@ -149,6 +149,37 @@ finish_response (struct HostSet *results)
 }
 
 
+/**
+ * Set 'cls' to GNUNET_YES (we have an address!).
+ *
+ * @param cls closure, an 'int*'
+ * @param tname name of the transport (ignored)
+ * @param expiration expiration time (call is ignored if this is in the past)
+ * @param addr the address (ignored)
+ * @param addrlen length of the address (ignored)
+ * @return  GNUNET_SYSERR to stop iterating (unless expiration has occured)
+ */
+static int
+check_has_addr (void *cls,
+               const char *tname,
+               struct GNUNET_TIME_Absolute expiration,
+               const void *addr, size_t addrlen)
+{
+  int *arg = cls;
+
+  if (GNUNET_TIME_absolute_get_remaining (expiration).value == 0)
+    {
+      GNUNET_STATISTICS_update (stats,
+                               gettext_noop("expired addresses encountered"),
+                               1,
+                               GNUNET_YES);
+      return GNUNET_YES; /* ignore this address */
+    }
+  *arg = GNUNET_YES;
+  return GNUNET_SYSERR;
+}
+
+
 /**
  * Callback that processes each of the known HELLOs for the
  * hostlist response construction.
@@ -162,6 +193,7 @@ host_processor (void *cls,
   struct HostSet *results = cls;
   size_t old;
   size_t s;
+  int has_addr;
   
   if (peer == NULL)
     {
@@ -169,6 +201,22 @@ host_processor (void *cls,
       finish_response (results);
       return;
     }
+  has_addr = GNUNET_NO;
+  GNUNET_HELLO_iterate_addresses (hello,
+                                 GNUNET_NO,
+                                 &check_has_addr,
+                                 &has_addr);
+  if (GNUNET_NO == has_addr)
+    {
+      GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+                 "HELLO for peer `%4s' has no address, not suitable for hostlist!\n",
+                 GNUNET_i2s (peer));
+      GNUNET_STATISTICS_update (stats,
+                               gettext_noop("HELLOs without addresses encountered (ignored)"),
+                               1,
+                               GNUNET_YES);
+      return; 
+    }
   old = results->size;
   s = GNUNET_HELLO_size(hello);
 #if DEBUG_HOSTLIST_SERVER