- start test only after warmup
[oweals/gnunet.git] / src / mesh / gnunet-service-mesh_dht.c
index 40aceab3f9f47a5e9cf1a34dac5d6d4c5ba78d9c..466aa9c72a6ce881388d967d14bd8f76f0975a14 100644 (file)
@@ -222,16 +222,21 @@ dht_get_id_handler (void *cls, struct GNUNET_TIME_Absolute exp,
   struct GMD_search_handle *h = cls;
   struct GNUNET_HELLO_Message *hello;
   struct MeshPeerPath *p;
+  struct MeshPeer *peer;
+  char *s;
 
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Got results!\n");
   p = path_build_from_dht (get_path, get_path_length,
                            put_path, put_path_length);
+  s = path_2s (p);
+  LOG (GNUNET_ERROR_TYPE_INFO, "Got path from DHT: %s\n", s);
+  GNUNET_free_non_null (s);
+  peer = GMP_get_short (p->peers[p->length - 1]);
+  LOG (GNUNET_ERROR_TYPE_DEBUG, "Got HELLO for %s\n", GMP_2s (peer));
   h->callback (h->cls, p);
   path_destroy (p);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Got type %u!\n", type);
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "Got size %u!\n", size);
   hello = (struct GNUNET_HELLO_Message *) data;
-  LOG (GNUNET_ERROR_TYPE_DEBUG, "HELLO size %u!\n", GNUNET_HELLO_size (hello));
+  GMP_set_hello (peer, hello);
+  GMP_try_connect (peer);
   return;
 }
 
@@ -248,6 +253,8 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
   struct GNUNET_HashCode phash;
   const struct GNUNET_HELLO_Message *hello;
   size_t size;
+  struct GNUNET_TIME_Absolute expiration;
+  struct GNUNET_TIME_Absolute retry_time;
 
   if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
   {
@@ -269,6 +276,8 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
     LOG (GNUNET_ERROR_TYPE_DEBUG, "  no hello, waiting!\n");
     return;
   }
+  expiration = GNUNET_HELLO_get_last_expiration (hello);
+  retry_time = GNUNET_TIME_absolute_get_remaining (expiration);
 
   LOG (GNUNET_ERROR_TYPE_DEBUG, "Hello %p size: %u\n", hello, size);
   memset (&phash, 0, sizeof (phash));
@@ -281,8 +290,8 @@ announce_id (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
                   GNUNET_BLOCK_TYPE_DHT_HELLO,       /* Block type */
                   size,  /* Size of the data */
                   (const char *) hello, /* Data itself */
-                  GNUNET_TIME_UNIT_FOREVER_ABS,  /* Data expiration */
-                  GNUNET_TIME_UNIT_FOREVER_REL, /* Retry time */
+                  expiration,  /* Data expiration */
+                  retry_time, /* Retry time */
                   NULL,         /* Continuation */
                   NULL);        /* Continuation closure */
   announce_id_task =