From 320c2d50b722eeffc50cd6db0c5361886ee750b0 Mon Sep 17 00:00:00 2001 From: Matthias Wachs Date: Mon, 3 Jan 2011 10:28:17 +0000 Subject: [PATCH] Fixed failing test and discrepancy between documentation and implemented functionality: 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 | 11 +++++------ src/peerinfo/peerinfo_api.c | 9 ++++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/peerinfo-tool/gnunet-peerinfo.c b/src/peerinfo-tool/gnunet-peerinfo.c index 7a0877995..42adcaad8 100644 --- a/src/peerinfo-tool/gnunet-peerinfo.c +++ b/src/peerinfo-tool/gnunet-peerinfo.c @@ -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 { diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c index a72435ffb..a0cb5c5c4 100644 --- a/src/peerinfo/peerinfo_api.c +++ b/src/peerinfo/peerinfo_api.c @@ -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, -- 2.25.1