[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r11056 - gnunet/src/hostlist
From: |
gnunet |
Subject: |
[GNUnet-SVN] r11056 - gnunet/src/hostlist |
Date: |
Fri, 23 Apr 2010 13:04:42 +0200 |
Author: wachs
Date: 2010-04-23 13:04:42 +0200 (Fri, 23 Apr 2010)
New Revision: 11056
Modified:
gnunet/src/hostlist/hostlist-client.c
gnunet/src/hostlist/hostlist-client.h
Log:
Modified: gnunet/src/hostlist/hostlist-client.c
===================================================================
--- gnunet/src/hostlist/hostlist-client.c 2010-04-23 09:46:25 UTC (rev
11055)
+++ gnunet/src/hostlist/hostlist-client.c 2010-04-23 11:04:42 UTC (rev
11056)
@@ -212,6 +212,8 @@
static int testing_allowed;
+static int download_in_progress;
+
/**
* Value saying if preconfigured is used
*/
@@ -689,7 +691,7 @@
GNUNET_free_non_null (current_url);
current_url = NULL;
- schedule_hostlist_task ();
+ download_in_progress = GNUNET_NO;
}
/**
@@ -894,6 +896,8 @@
CURLcode ret;
CURLMcode mret;
+ download_in_progress = GNUNET_YES;
+
current_url = get_list_url ();
if (current_url == NULL)
return;
@@ -999,6 +1003,29 @@
}
+static void
+download_dispatcher (void *cls,
+ const struct GNUNET_SCHEDULER_TaskContext *tc)
+{
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Download is initiated...\n");
+ if ( GNUNET_NO == download_in_progress )
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Download can start immediately...\n");
+ download_hostlist();
+ }
+ else
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
+ "Download in progess, have to wait...\n");
+ GNUNET_SCHEDULER_add_delayed (sched,
+ WAITING_INTERVALL,
+ &download_dispatcher,
+ NULL);
+ }
+}
+
/**
* Task that checks if we should try to download a hostlist.
* If so, we initiate the download, otherwise we schedule
@@ -1011,8 +1038,15 @@
current_task = GNUNET_SCHEDULER_NO_TASK;
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
+ /*if ( GNUNET_YES == testing_hostlist )
+ download_hostlist();*/
if (connection_count < MIN_CONNECTIONS)
- download_hostlist ();
+ {
+ GNUNET_SCHEDULER_add_now (sched,
+ &download_dispatcher,
+ NULL);
+ schedule_hostlist_task ();
+ }
else
schedule_hostlist_task ();
}
@@ -1142,7 +1176,6 @@
GNUNET_NO);
}
-
/**
* Method called whenever an advertisement message arrives.
*
@@ -1194,7 +1227,7 @@
return GNUNET_OK;
}
- if ( GNUNET_YES == testing_hostlist )
+ if ( (GNUNET_YES == testing_hostlist) || ( GNUNET_NO == testing_allowed) )
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Currently not accepting adverts\n");
@@ -1215,9 +1248,16 @@
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);
+
+ /* initiate download */
+ testing_intervall_task = GNUNET_SCHEDULER_add_now (sched,
+ &download_dispatcher,
+ NULL);
+
return GNUNET_OK;
}
Modified: gnunet/src/hostlist/hostlist-client.h
===================================================================
--- gnunet/src/hostlist/hostlist-client.h 2010-04-23 09:46:25 UTC (rev
11055)
+++ gnunet/src/hostlist/hostlist-client.h 2010-04-23 11:04:42 UTC (rev
11056)
@@ -36,6 +36,7 @@
#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)
+#define WAITING_INTERVALL GNUNET_TIME_relative_multiply
(GNUNET_TIME_UNIT_SECONDS, 1)
/*
* Defines concerning the hostlist quality metric
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r11056 - gnunet/src/hostlist,
gnunet <=