Fixed failing test and discrepancy between documentation and implemented functionality:
authorMatthias Wachs <wachs@net.in.tum.de>
Mon, 3 Jan 2011 10:28:17 +0000 (10:28 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Mon, 3 Jan 2011 10:28:17 +0000 (10:28 +0000)
GNUNET_PEERINFO_iterate never returns NULL, but always an iterator context
GNUNET_PEERINFO_iterate calls callback with Peer==NULL and HELLO==NULL when timeout occurs

src/peerinfo-tool/gnunet-peerinfo.c
src/peerinfo/peerinfo_api.c

index 7a08779950d43a8d8be5c4a491bd3c1c66ae18ae..42adcaad8a0e7f70df45285cb1ea1b40c24d4bbd 100644 (file)
@@ -142,7 +142,7 @@ print_address (void *cls,
                                   addrlen,
                                   no_resolve,
                                   tname,
-                                  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 20),
+                                  GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10),
                                   &process_resolved_address,
                                   pc);
   return GNUNET_OK;
@@ -164,6 +164,7 @@ print_peer_info (void *cls,
 
   if (peer == NULL)    
     {
+      fprintf (stderr,_("Error in communication with PEERINFO service\n"));
       GNUNET_PEERINFO_disconnect (peerinfo);
       return;    
     }
@@ -222,13 +223,11 @@ run (void *cls,
                   _("Could not access PEERINFO service.  Exiting.\n"));
          return;
        }
-      if (NULL == GNUNET_PEERINFO_iterate (peerinfo,
+      GNUNET_PEERINFO_iterate (peerinfo,
                                      NULL,
                                      GNUNET_TIME_relative_multiply
-                                     (GNUNET_TIME_UNIT_SECONDS, 20),
-                                     &print_peer_info, NULL))
-      fprintf (stderr,
-              _("Error in communication with PEERINFO service\n"));
+                                     (GNUNET_TIME_UNIT_SECONDS, 5),
+                                     &print_peer_info, NULL);
     }
   else
     {
index a72435ffb5abce090fc6c01254767f45e8cda5c6..a0cb5c5c4a94323aba029ffcdb1d79393d0e6006 100644 (file)
@@ -273,11 +273,11 @@ trigger_transmit (struct GNUNET_PEERINFO_Handle *h)
   struct TransmissionQueueEntry *tqe;
 
   if (NULL == (tqe = h->tq_head))
-    return;
+    return NULL;
   if (h->th != NULL)
-    return;
+    return NULL;
   if (h->in_receive == GNUNET_YES)
-    return;
+    return NULL;
   h->th = GNUNET_CLIENT_notify_transmit_ready (h->client,
                                               tqe->size,
                                               GNUNET_TIME_absolute_get_remaining (tqe->timeout),
@@ -551,8 +551,7 @@ signal_timeout (void *cls,
  * @param timeout how long to wait until timing out
  * @param callback the method to call for each peer
  * @param callback_cls closure for callback
- * @return NULL on error (in this case, 'callback' is never called!), 
- *         otherwise an iterator context
+ * @return iterator context
  */
 struct GNUNET_PEERINFO_IteratorContext *
 GNUNET_PEERINFO_iterate (struct GNUNET_PEERINFO_Handle *h,