From: Christian Grothoff Date: Tue, 16 Mar 2010 09:55:26 +0000 (+0000) Subject: fixes X-Git-Tag: initial-import-from-subversion-38251~22452 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=87a3f6f5afa582a53a86353896d129c40404c7fb;p=oweals%2Fgnunet.git fixes --- diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c index f5db86c91..133308edf 100644 --- a/src/hostlist/gnunet-daemon-hostlist.c +++ b/src/hostlist/gnunet-daemon-hostlist.c @@ -174,10 +174,6 @@ run (void *cls, return; } stats = GNUNET_STATISTICS_create (sched, "hostlist", cfg); - if (learning) - { - /* FIXME (register handler with core for hostlist ads) */ - } if (bootstrapping) { GNUNET_HOSTLIST_client_start (cfg, sched, stats, @@ -187,6 +183,10 @@ run (void *cls, { GNUNET_HOSTLIST_server_start (cfg, sched, stats); } + if (learning) + { + /* FIXME (register handler with core for hostlist ads) */ + } core = GNUNET_CORE_connect (sched, cfg, GNUNET_TIME_UNIT_FOREVER_REL, NULL, diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 99b43f008..90d67ee75 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c @@ -148,7 +148,8 @@ download_hostlist_processor (void *ptr, (int64_t) total, GNUNET_NO); left = total; - while (left > 0) + while ( (left > 0) || + (download_pos > 0) ) { cpy = GNUNET_MIN (total, GNUNET_SERVER_MAX_MESSAGE_SIZE - download_pos); GNUNET_assert (cpy > 0); diff --git a/src/hostlist/hostlist-server.c b/src/hostlist/hostlist-server.c index 9583d6a4f..8422f4bcb 100644 --- a/src/hostlist/hostlist-server.c +++ b/src/hostlist/hostlist-server.c @@ -149,6 +149,37 @@ finish_response (struct HostSet *results) } +/** + * Set 'cls' to GNUNET_YES (we have an address!). + * + * @param cls closure, an 'int*' + * @param tname name of the transport (ignored) + * @param expiration expiration time (call is ignored if this is in the past) + * @param addr the address (ignored) + * @param addrlen length of the address (ignored) + * @return GNUNET_SYSERR to stop iterating (unless expiration has occured) + */ +static int +check_has_addr (void *cls, + const char *tname, + struct GNUNET_TIME_Absolute expiration, + const void *addr, size_t addrlen) +{ + int *arg = cls; + + if (GNUNET_TIME_absolute_get_remaining (expiration).value == 0) + { + GNUNET_STATISTICS_update (stats, + gettext_noop("expired addresses encountered"), + 1, + GNUNET_YES); + return GNUNET_YES; /* ignore this address */ + } + *arg = GNUNET_YES; + return GNUNET_SYSERR; +} + + /** * Callback that processes each of the known HELLOs for the * hostlist response construction. @@ -162,6 +193,7 @@ host_processor (void *cls, struct HostSet *results = cls; size_t old; size_t s; + int has_addr; if (peer == NULL) { @@ -169,6 +201,22 @@ host_processor (void *cls, finish_response (results); return; } + has_addr = GNUNET_NO; + GNUNET_HELLO_iterate_addresses (hello, + GNUNET_NO, + &check_has_addr, + &has_addr); + if (GNUNET_NO == has_addr) + { + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "HELLO for peer `%4s' has no address, not suitable for hostlist!\n", + GNUNET_i2s (peer)); + GNUNET_STATISTICS_update (stats, + gettext_noop("HELLOs without addresses encountered (ignored)"), + 1, + GNUNET_YES); + return; + } old = results->size; s = GNUNET_HELLO_size(hello); #if DEBUG_HOSTLIST_SERVER