(no commit message)
authorMatthias Wachs <wachs@net.in.tum.de>
Fri, 23 Apr 2010 09:46:14 +0000 (09:46 +0000)
committerMatthias Wachs <wachs@net.in.tum.de>
Fri, 23 Apr 2010 09:46:14 +0000 (09:46 +0000)
src/hostlist/hostlist-client.c
src/hostlist/hostlist-client.h

index 141e904c4e93f30d6701d11699c8eed6fae44eb1..384c498091f7376b8a11de5116a8a283438fd499 100644 (file)
@@ -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 )
   {
index 45b04803096946f6705f1bdbbbf3cf2b60ae5133..4d0a505ab7830b354d3b00c0c9c01003ea731643 100644 (file)
@@ -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