aboutsummaryrefslogtreecommitdiff
path: root/src/hostlist
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2016-04-09 23:14:03 +0000
committerChristian Grothoff <christian@grothoff.org>2016-04-09 23:14:03 +0000
commit29e6158507a0758192075ac6ece7ba8e75ddc49a (patch)
treeb91ded48da322f8ba4c9bb0f5504228aa036c2d1 /src/hostlist
parent5dfcb058ab5db9ae0c4b147d8a99c64ca0980028 (diff)
small API change: do no longer pass rarely needed GNUNET_SCHEDULER_TaskContext to all scheduler tasks; instead, allow the relatively few tasks that need it to obtain the context via GNUNET_SCHEDULER_get_task_context()
Diffstat (limited to 'src/hostlist')
-rw-r--r--src/hostlist/gnunet-daemon-hostlist.c4
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_client.c32
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_server.c7
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist.c10
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_learning.c9
-rw-r--r--src/hostlist/test_gnunet_daemon_hostlist_reconnect.c10
6 files changed, 38 insertions, 34 deletions
diff --git a/src/hostlist/gnunet-daemon-hostlist.c b/src/hostlist/gnunet-daemon-hostlist.c
index 42b5959f26..6a4689af1b 100644
--- a/src/hostlist/gnunet-daemon-hostlist.c
+++ b/src/hostlist/gnunet-daemon-hostlist.c
@@ -212,11 +212,9 @@ disconnect_handler (void *cls,
* the other services.
*
* @param cls NULL
- * @param tc scheduler context
*/
static void
-cleaning_task (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+cleaning_task (void *cls)
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Hostlist daemon is shutting down\n");
diff --git a/src/hostlist/gnunet-daemon-hostlist_client.c b/src/hostlist/gnunet-daemon-hostlist_client.c
index e0a73f0f0a..dbf6eaedac 100644
--- a/src/hostlist/gnunet-daemon-hostlist_client.c
+++ b/src/hostlist/gnunet-daemon-hostlist_client.c
@@ -774,8 +774,7 @@ clean_up ()
* @param tc task context, unused
*/
static void
-task_download (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc);
+task_download (void *cls);
/**
@@ -841,17 +840,17 @@ download_prepare ()
* server.
*
* @param cls closure, unused
- * @param tc task context, unused
*/
static void
-task_download (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+task_download (void *cls)
{
int running;
struct CURLMsg *msg;
CURLMcode mret;
+ const struct GNUNET_SCHEDULER_TaskContext *tc;
ti_download = NULL;
+ tc = GNUNET_SCHEDULER_get_task_context ();
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
{
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
@@ -1046,10 +1045,12 @@ download_hostlist ()
static void
-task_download_dispatcher (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+task_download_dispatcher (void *cls)
{
+ const struct GNUNET_SCHEDULER_TaskContext *tc;
+
ti_download_dispatcher_task = NULL;
+ tc = GNUNET_SCHEDULER_get_task_context ();
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Download is initiated...\n");
@@ -1075,12 +1076,14 @@ task_download_dispatcher (void *cls,
* this task again for a later time.
*/
static void
-task_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+task_check (void *cls)
{
static int once;
struct GNUNET_TIME_Relative delay;
+ const struct GNUNET_SCHEDULER_TaskContext *tc;
ti_check_download = NULL;
+ tc = GNUNET_SCHEDULER_get_task_context ();
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
if (stats == NULL)
@@ -1125,13 +1128,14 @@ task_check (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
* This tasks sets hostlist testing to allowed after intervall between to testings is reached
*
* @param cls closure
- * @param tc TaskContext
*/
static void
-task_testing_intervall_reset (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+task_testing_intervall_reset (void *cls)
{
+ const struct GNUNET_SCHEDULER_TaskContext *tc;
+
ti_testing_intervall_task = NULL;
+ tc = GNUNET_SCHEDULER_get_task_context ();
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
stat_testing_allowed = GNUNET_OK;
@@ -1144,12 +1148,14 @@ task_testing_intervall_reset (void *cls,
* Task that writes hostlist entries to a file on a regular base
*
* @param cls closure
- * @param tc TaskContext
*/
static void
-task_hostlist_saving (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+task_hostlist_saving (void *cls)
{
+ const struct GNUNET_SCHEDULER_TaskContext *tc;
+
ti_saving_task = NULL;
+ tc = GNUNET_SCHEDULER_get_task_context ();
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
save_hostlist_file (GNUNET_NO);
diff --git a/src/hostlist/gnunet-daemon-hostlist_server.c b/src/hostlist/gnunet-daemon-hostlist_server.c
index 7c5b18605f..6e2cb7ee46 100644
--- a/src/hostlist/gnunet-daemon-hostlist_server.c
+++ b/src/hostlist/gnunet-daemon-hostlist_server.c
@@ -627,19 +627,18 @@ prepare_daemon (struct MHD_Daemon *daemon_handle);
* and schedule the next run.
*
* @param cls the `struct MHD_Daemon` of the HTTP server to run
- * @param tc scheduler context
*/
static void
-run_daemon (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+run_daemon (void *cls)
{
struct MHD_Daemon *daemon_handle = cls;
+ const struct GNUNET_SCHEDULER_TaskContext *tc;
if (daemon_handle == daemon_handle_v4)
hostlist_task_v4 = NULL;
else
hostlist_task_v6 = NULL;
-
+ tc = GNUNET_SCHEDULER_get_task_context ();
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
GNUNET_assert (MHD_YES == MHD_run (daemon_handle));
diff --git a/src/hostlist/test_gnunet_daemon_hostlist.c b/src/hostlist/test_gnunet_daemon_hostlist.c
index 05e05e24e6..2f99b887d0 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist.c
@@ -52,7 +52,7 @@ static struct PeerContext p2;
static void
-clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+clean_up (void *cls)
{
if (p1.th != NULL)
{
@@ -81,12 +81,12 @@ clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
* Timeout, give up.
*/
static void
-timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+timeout_error (void *cls)
{
timeout_task = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Timeout trying to connect peers, test failed.\n");
- clean_up (NULL, tc);
+ clean_up (NULL);
}
@@ -150,7 +150,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
static void
-waitpid_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+waitpid_task (void *cls)
{
struct PeerContext *p = cls;
@@ -179,7 +179,7 @@ stop_arm (struct PeerContext *p)
* Try again to connect to transport service.
*/
static void
-shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
{
stop_arm (&p1);
stop_arm (&p2);
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_learning.c b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
index d04c5c57ff..a71b8ecaee 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist_learning.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist_learning.c
@@ -166,7 +166,7 @@ shutdown_testcase ()
* Timeout, give up.
*/
static void
-timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+timeout_error (void *cls)
{
timeout_task = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
@@ -184,8 +184,7 @@ process_downloads_done (void *cls, int success)
static void
-do_shutdown (void *cls,
- const struct GNUNET_SCHEDULER_TaskContext *tc)
+do_shutdown (void *cls)
{
shutdown_testcase ();
}
@@ -265,11 +264,13 @@ process_adv_sent (void *cls, const char *subsystem, const char *name,
* Check the server statistics regularly
*/
static void
-check_statistics (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+check_statistics (void *cls)
{
char *stat;
+ const struct GNUNET_SCHEDULER_TaskContext *tc;
check_task = NULL;
+ tc = GNUNET_SCHEDULER_get_task_context ();
if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
return;
GNUNET_asprintf (&stat, gettext_noop ("# advertised URI `%s' downloaded"),
diff --git a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
index e7ac9b2bc3..0af16e0659 100644
--- a/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
+++ b/src/hostlist/test_gnunet_daemon_hostlist_reconnect.c
@@ -52,7 +52,7 @@ static struct PeerContext p2;
static void
-clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+clean_up (void *cls)
{
if (NULL != p1.ghh)
{
@@ -81,12 +81,12 @@ clean_up (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
* Timeout, give up.
*/
static void
-timeout_error (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+timeout_error (void *cls)
{
timeout_task = NULL;
GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
"Timeout trying to connect peers, test failed.\n");
- clean_up (NULL, tc);
+ clean_up (NULL);
}
@@ -150,7 +150,7 @@ setup_peer (struct PeerContext *p, const char *cfgname)
static void
-waitpid_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+waitpid_task (void *cls)
{
struct PeerContext *p = cls;
@@ -179,7 +179,7 @@ stop_arm (struct PeerContext *p)
* Try again to connect to transport service.
*/
static void
-shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc)
+shutdown_task (void *cls)
{
stop_arm (&p1);
stop_arm (&p2);