From bd6f6e2e957f41f82790971a0e65b4b1cf7f547d Mon Sep 17 00:00:00 2001 From: nevans Date: Fri, 5 Nov 2010 18:21:50 +0000 Subject: big scheduler refactoring, expect some issues git-svn-id: https://gnunet.org/svn/gnunet@13565 140774ce-b5e7-0310-ab8b-a85725594a96 --- src/statistics/gnunet-service-statistics.c | 5 +---- src/statistics/gnunet-statistics.c | 6 ++---- src/statistics/statistics_api.c | 19 ++++--------------- src/statistics/test_statistics_api.c | 6 ++---- src/statistics/test_statistics_api_loop.c | 3 +-- 5 files changed, 10 insertions(+), 29 deletions(-) (limited to 'src/statistics') diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index 92f79cc914..c506dee7b9 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c @@ -730,13 +730,11 @@ handle_client_disconnect (void *cls, * Process statistics requests. * * @param cls closure - * @param sched scheduler to use * @param server the initialized server * @param c configuration to use */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, struct GNUNET_SERVER_Handle *server, const struct GNUNET_CONFIGURATION_Handle *c) { @@ -753,8 +751,7 @@ run (void *cls, &handle_client_disconnect, NULL); load (server); - GNUNET_SCHEDULER_add_delayed (sched, - GNUNET_TIME_UNIT_FOREVER_REL, + GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, NULL); } diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c index 3742a496d5..0cbafa68fa 100644 --- a/src/statistics/gnunet-statistics.c +++ b/src/statistics/gnunet-statistics.c @@ -104,14 +104,12 @@ cleanup (void *cls, int success) * Main function that will be run by the scheduler. * * @param cls closure - * @param sched the scheduler to use * @param args remaining command-line arguments * @param cfgfile name of the configuration file used (for saving, can be NULL!) * @param cfg configuration */ static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -128,7 +126,7 @@ run (void *cls, ret = 1; return; } - h = GNUNET_STATISTICS_create (sched, subsystem, cfg); + h = GNUNET_STATISTICS_create (subsystem, cfg); if (h == NULL) { ret = 1; @@ -138,7 +136,7 @@ run (void *cls, GNUNET_STATISTICS_destroy (h, GNUNET_YES); return; } - h = GNUNET_STATISTICS_create (sched, "gnunet-statistics", cfg); + h = GNUNET_STATISTICS_create ("gnunet-statistics", cfg); if (h == NULL) { ret = 1; diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index ef9865e024..5bca6c786b 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c @@ -166,11 +166,6 @@ struct GNUNET_STATISTICS_GetHandle */ struct GNUNET_STATISTICS_Handle { - /** - * Our scheduler. - */ - struct GNUNET_SCHEDULER_Handle *sched; - /** * Name of our subsystem. */ @@ -318,7 +313,7 @@ try_connect (struct GNUNET_STATISTICS_Handle *ret) unsigned int i; if (ret->client != NULL) return GNUNET_YES; - ret->client = GNUNET_CLIENT_connect (ret->sched, "statistics", ret->cfg); + ret->client = GNUNET_CLIENT_connect ("statistics", ret->cfg); if (ret->client != NULL) { for (i=0;iwatches_size;i++) @@ -727,23 +722,19 @@ transmit_action (void *cls, size_t size, void *buf) /** * Get handle for the statistics service. * - * @param sched scheduler to use * @param subsystem name of subsystem using the service * @param cfg services configuration in use * @return handle to use */ struct GNUNET_STATISTICS_Handle * -GNUNET_STATISTICS_create (struct GNUNET_SCHEDULER_Handle *sched, - const char *subsystem, +GNUNET_STATISTICS_create (const char *subsystem, const struct GNUNET_CONFIGURATION_Handle *cfg) { struct GNUNET_STATISTICS_Handle *ret; GNUNET_assert (subsystem != NULL); - GNUNET_assert (sched != NULL); GNUNET_assert (cfg != NULL); ret = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_Handle)); - ret->sched = sched; ret->cfg = cfg; ret->subsystem = GNUNET_strdup (subsystem); ret->backoff = GNUNET_TIME_UNIT_MILLISECONDS; @@ -771,8 +762,7 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, int i; if (GNUNET_SCHEDULER_NO_TASK != h->backoff_task) - GNUNET_SCHEDULER_cancel (h->sched, - h->backoff_task); + GNUNET_SCHEDULER_cancel (h->backoff_task); if (sync_first) { if (h->current != NULL) @@ -884,8 +874,7 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h) return; /* action already pending */ if (GNUNET_YES != try_connect (h)) { - h->backoff_task = GNUNET_SCHEDULER_add_delayed (h->sched, - h->backoff, + h->backoff_task = GNUNET_SCHEDULER_add_delayed (h->backoff, &finish_task, h); h->backoff = GNUNET_TIME_relative_multiply (h->backoff, 2); diff --git a/src/statistics/test_statistics_api.c b/src/statistics/test_statistics_api.c index cce90146c0..7b01ff00f0 100644 --- a/src/statistics/test_statistics_api.c +++ b/src/statistics/test_statistics_api.c @@ -109,12 +109,11 @@ next (void *cls, int success) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - h = GNUNET_STATISTICS_create (sched, "test-statistics-api", cfg); + h = GNUNET_STATISTICS_create ("test-statistics-api", cfg); GNUNET_STATISTICS_set (h, "test-1", 1, GNUNET_NO); GNUNET_STATISTICS_set (h, "test-2", 2, GNUNET_NO); GNUNET_STATISTICS_set (h, "test-3", 2, GNUNET_NO); @@ -128,12 +127,11 @@ run (void *cls, static void run_more (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) { - h = GNUNET_STATISTICS_create (sched, "test-statistics-api", cfg); + h = GNUNET_STATISTICS_create ("test-statistics-api", cfg); GNUNET_break (NULL != GNUNET_STATISTICS_get (h, NULL, "test-3", GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_3, cls)); diff --git a/src/statistics/test_statistics_api_loop.c b/src/statistics/test_statistics_api_loop.c index 7eaa9d27b7..02f4aca440 100644 --- a/src/statistics/test_statistics_api_loop.c +++ b/src/statistics/test_statistics_api_loop.c @@ -60,7 +60,6 @@ next (void *cls, int success) static void run (void *cls, - struct GNUNET_SCHEDULER_Handle *sched, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *cfg) @@ -68,7 +67,7 @@ run (void *cls, int i; char name[128]; - h = GNUNET_STATISTICS_create (sched, "test-statistics-api-loop", cfg); + h = GNUNET_STATISTICS_create ("test-statistics-api-loop", cfg); for (i=0;i