From: Matthias Wachs Date: Fri, 23 Apr 2010 09:46:14 +0000 (+0000) Subject: (no commit message) X-Git-Tag: initial-import-from-subversion-38251~22019 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=597e676a39da448348164042bb0e0b1f9b957c40;p=oweals%2Fgnunet.git --- diff --git a/src/hostlist/hostlist-client.c b/src/hostlist/hostlist-client.c index 141e904c4..384c49809 100644 --- a/src/hostlist/hostlist-client.c +++ b/src/hostlist/hostlist-client.c @@ -158,6 +158,11 @@ static GNUNET_SCHEDULER_TaskIdentifier current_task; */ static GNUNET_SCHEDULER_TaskIdentifier saving_task; +/** + * ID of the task checking the intervall between to hostlist tests + */ +static GNUNET_SCHEDULER_TaskIdentifier testing_intervall_task; + /** * Amount of time we wait between hostlist downloads. */ @@ -205,6 +210,8 @@ static struct Hostlist * hostlist_to_test; static int testing_hostlist; +static int testing_allowed; + /** * Value saying if preconfigured is used */ @@ -1054,6 +1061,21 @@ schedule_hostlist_task () NULL); } +/** + * This tasks sets hostlist testing to allowed after intervall between to testings is reached + * cls closure + * tc TaskContext + */ +static void +testing_intervall_reset (void *cls, + const struct GNUNET_SCHEDULER_TaskContext *tc) +{ + testing_allowed = GNUNET_OK; + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Testing new hostlist advertisements is allowed again\n"); +} + + /** * Task that writes hostlist entries to a file on a regular base * cls closure @@ -1188,6 +1210,14 @@ advertisement_handler (void *cls, hostlist_to_test = hostlist; testing_hostlist = GNUNET_YES; + testing_allowed = GNUNET_NO; + testing_intervall_task = GNUNET_SCHEDULER_add_delayed (sched, + TESTING_INTERVALL, + &testing_intervall_reset, + NULL); + GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, + "Testing new hostlist advertisements is locked for the next %u seconds\n", + TESTING_INTERVALL); return GNUNET_OK; } @@ -1452,6 +1482,7 @@ GNUNET_HOSTLIST_client_start (const struct GNUNET_CONFIGURATION_Handle *c, linked_list_tail = NULL; use_preconfigured_list = GNUNET_YES; testing_hostlist = GNUNET_NO; + testing_allowed = GNUNET_YES; if ( GNUNET_YES == learning ) { diff --git a/src/hostlist/hostlist-client.h b/src/hostlist/hostlist-client.h index 45b048030..4d0a505ab 100644 --- a/src/hostlist/hostlist-client.h +++ b/src/hostlist/hostlist-client.h @@ -35,6 +35,7 @@ #define MAX_NUMBER_HOSTLISTS 30 #define MAX_HELLO_PER_HOSTLISTS 0 #define SAVING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MINUTES, 30) +#define TESTING_INTERVALL GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 3) /* * Defines concerning the hostlist quality metric