fix
authorChristian Grothoff <christian@grothoff.org>
Fri, 22 Jan 2010 16:55:16 +0000 (16:55 +0000)
committerChristian Grothoff <christian@grothoff.org>
Fri, 22 Jan 2010 16:55:16 +0000 (16:55 +0000)
src/peerinfo/gnunet-service-peerinfo.c
src/peerinfo/peerinfo_api.c
src/peerinfo/test_peerinfo_api.c

index 9ac38ea9fb315dff16a6a602536bcd6b75ae8c0f..c67d35e38b5439f1023aa6c755f846ead1e1304d 100644 (file)
@@ -486,8 +486,6 @@ send_to_each_host (const struct GNUNET_PeerIdentity *only,
           change_host_trust (&pos->identity, trust_change);
           hs = 0;
           im = (struct InfoMessage *) buf;
-         im->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
-         im->header.size = htons (sizeof (struct InfoMessage) + hs);
           if (pos->hello != NULL)
             {
               hs = GNUNET_HELLO_size (pos->hello);
@@ -496,6 +494,8 @@ send_to_each_host (const struct GNUNET_PeerIdentity *only,
                              sizeof (struct InfoMessage));
               memcpy (&im[1], pos->hello, hs);
             }
+         im->header.type = htons (GNUNET_MESSAGE_TYPE_PEERINFO_INFO);
+         im->header.size = htons (sizeof (struct InfoMessage) + hs);
           im->trust = htonl (pos->trust);
           im->peer = pos->identity;
           GNUNET_SERVER_transmit_context_append_message (tc,
index 0f95a421a2e50986bcc9322a126048204d6bc4d0..5531ede977d8425fa3e8f000ef7b10c8d8ee0d7e 100644 (file)
@@ -223,7 +223,7 @@ info_handler (void *cls, const struct GNUNET_MessageHeader *msg)
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
              "Size of `%s' is %u bytes\n",
              "HELLO",
-             (unsigned int) GNUNET_HELLO_size (hello));
+             (hello == NULL) ? 0 : (unsigned int) GNUNET_HELLO_size (hello));
 #endif  
   ic->callback (ic->callback_cls, &im->peer, hello, ntohl (im->trust));
   GNUNET_CLIENT_receive (ic->client,
index 0b5230eb6c5421b9a45c55c633e5150b960dd816..0bea99b01358c3186c96e6840c3a7666ae346969 100644 (file)
@@ -40,6 +40,8 @@ static struct GNUNET_SCHEDULER_Handle *sched;
 
 static const struct GNUNET_CONFIGURATION_Handle *cfg;
 
+static struct GNUNET_PEERINFO_IteratorContext *ic;
+
 static unsigned int retries;
 
 static int
@@ -105,19 +107,20 @@ process (void *cls,
 
   if (peer == NULL)
     {
+      ic = NULL;
       if ( (3 == *ok) &&
-          (retries < 5) )
+          (retries < 50) )
        {
          /* try again */
          retries++;      
          add_peer ();
-         GNUNET_PEERINFO_iterate (cfg,
-                                  sched,
-                                  NULL,
-                                  0,
-                                  GNUNET_TIME_relative_multiply
-                                  (GNUNET_TIME_UNIT_SECONDS, 15), 
-                                  &process, cls);
+         ic = GNUNET_PEERINFO_iterate (cfg,
+                                       sched,
+                                       NULL,
+                                       0,
+                                       GNUNET_TIME_relative_multiply
+                                       (GNUNET_TIME_UNIT_SECONDS, 15), 
+                                       &process, cls);
          return;
        }
       GNUNET_assert (peer == NULL);
@@ -126,7 +129,6 @@ process (void *cls,
       *ok = 0;
       return;
     }
-
   if (hello != NULL)
     {
       GNUNET_assert (3 == *ok);
@@ -148,12 +150,12 @@ run (void *cls,
   sched = s;
   cfg = c;
   add_peer ();
-  GNUNET_PEERINFO_iterate (cfg,
-                           sched,
-                           NULL,
-                           0,
-                           GNUNET_TIME_relative_multiply
-                           (GNUNET_TIME_UNIT_SECONDS, 15), &process, cls);
+  ic = GNUNET_PEERINFO_iterate (cfg,
+                               sched,
+                               NULL,
+                               0,
+                               GNUNET_TIME_relative_multiply
+                               (GNUNET_TIME_UNIT_SECONDS, 15), &process, cls);
 }