From 98ea57dd2236542414e52792672d8563c8ca4294 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 22 Jan 2010 16:55:16 +0000 Subject: fix --- src/peerinfo/gnunet-service-peerinfo.c | 4 ++-- src/peerinfo/peerinfo_api.c | 2 +- src/peerinfo/test_peerinfo_api.c | 32 +++++++++++++++++--------------- 3 files changed, 20 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/peerinfo/gnunet-service-peerinfo.c b/src/peerinfo/gnunet-service-peerinfo.c index 9ac38ea9f..c67d35e38 100644 --- a/src/peerinfo/gnunet-service-peerinfo.c +++ b/src/peerinfo/gnunet-service-peerinfo.c @@ -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, diff --git a/src/peerinfo/peerinfo_api.c b/src/peerinfo/peerinfo_api.c index 0f95a421a..5531ede97 100644 --- a/src/peerinfo/peerinfo_api.c +++ b/src/peerinfo/peerinfo_api.c @@ -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, diff --git a/src/peerinfo/test_peerinfo_api.c b/src/peerinfo/test_peerinfo_api.c index 0b5230eb6..0bea99b01 100644 --- a/src/peerinfo/test_peerinfo_api.c +++ b/src/peerinfo/test_peerinfo_api.c @@ -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); } -- cgit v1.2.3