diff options
author | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2010-11-05 18:21:50 +0000 |
commit | 75a33a1499cf60ea4364c9aa673816629a6c1413 (patch) | |
tree | 0620da4312bb04de4d7b65074fdd3b0c3dd6cc0e /src/statistics | |
parent | 7217c601ad30760872823193d62307e7a335d226 (diff) | |
download | gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.tar.gz gnunet-75a33a1499cf60ea4364c9aa673816629a6c1413.zip |
big scheduler refactoring, expect some issues
Diffstat (limited to 'src/statistics')
-rw-r--r-- | src/statistics/gnunet-service-statistics.c | 5 | ||||
-rw-r--r-- | src/statistics/gnunet-statistics.c | 6 | ||||
-rw-r--r-- | src/statistics/statistics_api.c | 19 | ||||
-rw-r--r-- | src/statistics/test_statistics_api.c | 6 | ||||
-rw-r--r-- | src/statistics/test_statistics_api_loop.c | 3 |
5 files changed, 10 insertions, 29 deletions
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index 92f79cc91..c506dee7b 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c | |||
@@ -730,13 +730,11 @@ handle_client_disconnect (void *cls, | |||
730 | * Process statistics requests. | 730 | * Process statistics requests. |
731 | * | 731 | * |
732 | * @param cls closure | 732 | * @param cls closure |
733 | * @param sched scheduler to use | ||
734 | * @param server the initialized server | 733 | * @param server the initialized server |
735 | * @param c configuration to use | 734 | * @param c configuration to use |
736 | */ | 735 | */ |
737 | static void | 736 | static void |
738 | run (void *cls, | 737 | run (void *cls, |
739 | struct GNUNET_SCHEDULER_Handle *sched, | ||
740 | struct GNUNET_SERVER_Handle *server, | 738 | struct GNUNET_SERVER_Handle *server, |
741 | const struct GNUNET_CONFIGURATION_Handle *c) | 739 | const struct GNUNET_CONFIGURATION_Handle *c) |
742 | { | 740 | { |
@@ -753,8 +751,7 @@ run (void *cls, | |||
753 | &handle_client_disconnect, | 751 | &handle_client_disconnect, |
754 | NULL); | 752 | NULL); |
755 | load (server); | 753 | load (server); |
756 | GNUNET_SCHEDULER_add_delayed (sched, | 754 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
757 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
758 | &shutdown_task, | 755 | &shutdown_task, |
759 | NULL); | 756 | NULL); |
760 | } | 757 | } |
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c index 3742a496d..0cbafa68f 100644 --- a/src/statistics/gnunet-statistics.c +++ b/src/statistics/gnunet-statistics.c | |||
@@ -104,14 +104,12 @@ cleanup (void *cls, int success) | |||
104 | * Main function that will be run by the scheduler. | 104 | * Main function that will be run by the scheduler. |
105 | * | 105 | * |
106 | * @param cls closure | 106 | * @param cls closure |
107 | * @param sched the scheduler to use | ||
108 | * @param args remaining command-line arguments | 107 | * @param args remaining command-line arguments |
109 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | 108 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) |
110 | * @param cfg configuration | 109 | * @param cfg configuration |
111 | */ | 110 | */ |
112 | static void | 111 | static void |
113 | run (void *cls, | 112 | run (void *cls, |
114 | struct GNUNET_SCHEDULER_Handle *sched, | ||
115 | char *const *args, | 113 | char *const *args, |
116 | const char *cfgfile, | 114 | const char *cfgfile, |
117 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 115 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -128,7 +126,7 @@ run (void *cls, | |||
128 | ret = 1; | 126 | ret = 1; |
129 | return; | 127 | return; |
130 | } | 128 | } |
131 | h = GNUNET_STATISTICS_create (sched, subsystem, cfg); | 129 | h = GNUNET_STATISTICS_create (subsystem, cfg); |
132 | if (h == NULL) | 130 | if (h == NULL) |
133 | { | 131 | { |
134 | ret = 1; | 132 | ret = 1; |
@@ -138,7 +136,7 @@ run (void *cls, | |||
138 | GNUNET_STATISTICS_destroy (h, GNUNET_YES); | 136 | GNUNET_STATISTICS_destroy (h, GNUNET_YES); |
139 | return; | 137 | return; |
140 | } | 138 | } |
141 | h = GNUNET_STATISTICS_create (sched, "gnunet-statistics", cfg); | 139 | h = GNUNET_STATISTICS_create ("gnunet-statistics", cfg); |
142 | if (h == NULL) | 140 | if (h == NULL) |
143 | { | 141 | { |
144 | ret = 1; | 142 | ret = 1; |
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index ef9865e02..5bca6c786 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c | |||
@@ -167,11 +167,6 @@ struct GNUNET_STATISTICS_GetHandle | |||
167 | struct GNUNET_STATISTICS_Handle | 167 | struct GNUNET_STATISTICS_Handle |
168 | { | 168 | { |
169 | /** | 169 | /** |
170 | * Our scheduler. | ||
171 | */ | ||
172 | struct GNUNET_SCHEDULER_Handle *sched; | ||
173 | |||
174 | /** | ||
175 | * Name of our subsystem. | 170 | * Name of our subsystem. |
176 | */ | 171 | */ |
177 | char *subsystem; | 172 | char *subsystem; |
@@ -318,7 +313,7 @@ try_connect (struct GNUNET_STATISTICS_Handle *ret) | |||
318 | unsigned int i; | 313 | unsigned int i; |
319 | if (ret->client != NULL) | 314 | if (ret->client != NULL) |
320 | return GNUNET_YES; | 315 | return GNUNET_YES; |
321 | ret->client = GNUNET_CLIENT_connect (ret->sched, "statistics", ret->cfg); | 316 | ret->client = GNUNET_CLIENT_connect ("statistics", ret->cfg); |
322 | if (ret->client != NULL) | 317 | if (ret->client != NULL) |
323 | { | 318 | { |
324 | for (i=0;i<ret->watches_size;i++) | 319 | for (i=0;i<ret->watches_size;i++) |
@@ -727,23 +722,19 @@ transmit_action (void *cls, size_t size, void *buf) | |||
727 | /** | 722 | /** |
728 | * Get handle for the statistics service. | 723 | * Get handle for the statistics service. |
729 | * | 724 | * |
730 | * @param sched scheduler to use | ||
731 | * @param subsystem name of subsystem using the service | 725 | * @param subsystem name of subsystem using the service |
732 | * @param cfg services configuration in use | 726 | * @param cfg services configuration in use |
733 | * @return handle to use | 727 | * @return handle to use |
734 | */ | 728 | */ |
735 | struct GNUNET_STATISTICS_Handle * | 729 | struct GNUNET_STATISTICS_Handle * |
736 | GNUNET_STATISTICS_create (struct GNUNET_SCHEDULER_Handle *sched, | 730 | GNUNET_STATISTICS_create (const char *subsystem, |
737 | const char *subsystem, | ||
738 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 731 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
739 | { | 732 | { |
740 | struct GNUNET_STATISTICS_Handle *ret; | 733 | struct GNUNET_STATISTICS_Handle *ret; |
741 | 734 | ||
742 | GNUNET_assert (subsystem != NULL); | 735 | GNUNET_assert (subsystem != NULL); |
743 | GNUNET_assert (sched != NULL); | ||
744 | GNUNET_assert (cfg != NULL); | 736 | GNUNET_assert (cfg != NULL); |
745 | ret = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_Handle)); | 737 | ret = GNUNET_malloc (sizeof (struct GNUNET_STATISTICS_Handle)); |
746 | ret->sched = sched; | ||
747 | ret->cfg = cfg; | 738 | ret->cfg = cfg; |
748 | ret->subsystem = GNUNET_strdup (subsystem); | 739 | ret->subsystem = GNUNET_strdup (subsystem); |
749 | ret->backoff = GNUNET_TIME_UNIT_MILLISECONDS; | 740 | ret->backoff = GNUNET_TIME_UNIT_MILLISECONDS; |
@@ -771,8 +762,7 @@ GNUNET_STATISTICS_destroy (struct GNUNET_STATISTICS_Handle *h, | |||
771 | int i; | 762 | int i; |
772 | 763 | ||
773 | if (GNUNET_SCHEDULER_NO_TASK != h->backoff_task) | 764 | if (GNUNET_SCHEDULER_NO_TASK != h->backoff_task) |
774 | GNUNET_SCHEDULER_cancel (h->sched, | 765 | GNUNET_SCHEDULER_cancel (h->backoff_task); |
775 | h->backoff_task); | ||
776 | if (sync_first) | 766 | if (sync_first) |
777 | { | 767 | { |
778 | if (h->current != NULL) | 768 | if (h->current != NULL) |
@@ -884,8 +874,7 @@ schedule_action (struct GNUNET_STATISTICS_Handle *h) | |||
884 | return; /* action already pending */ | 874 | return; /* action already pending */ |
885 | if (GNUNET_YES != try_connect (h)) | 875 | if (GNUNET_YES != try_connect (h)) |
886 | { | 876 | { |
887 | h->backoff_task = GNUNET_SCHEDULER_add_delayed (h->sched, | 877 | h->backoff_task = GNUNET_SCHEDULER_add_delayed (h->backoff, |
888 | h->backoff, | ||
889 | &finish_task, | 878 | &finish_task, |
890 | h); | 879 | h); |
891 | h->backoff = GNUNET_TIME_relative_multiply (h->backoff, 2); | 880 | 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 cce90146c..7b01ff00f 100644 --- a/src/statistics/test_statistics_api.c +++ b/src/statistics/test_statistics_api.c | |||
@@ -109,12 +109,11 @@ next (void *cls, int success) | |||
109 | 109 | ||
110 | static void | 110 | static void |
111 | run (void *cls, | 111 | run (void *cls, |
112 | struct GNUNET_SCHEDULER_Handle *sched, | ||
113 | char *const *args, | 112 | char *const *args, |
114 | const char *cfgfile, | 113 | const char *cfgfile, |
115 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 114 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
116 | { | 115 | { |
117 | h = GNUNET_STATISTICS_create (sched, "test-statistics-api", cfg); | 116 | h = GNUNET_STATISTICS_create ("test-statistics-api", cfg); |
118 | GNUNET_STATISTICS_set (h, "test-1", 1, GNUNET_NO); | 117 | GNUNET_STATISTICS_set (h, "test-1", 1, GNUNET_NO); |
119 | GNUNET_STATISTICS_set (h, "test-2", 2, GNUNET_NO); | 118 | GNUNET_STATISTICS_set (h, "test-2", 2, GNUNET_NO); |
120 | GNUNET_STATISTICS_set (h, "test-3", 2, GNUNET_NO); | 119 | GNUNET_STATISTICS_set (h, "test-3", 2, GNUNET_NO); |
@@ -128,12 +127,11 @@ run (void *cls, | |||
128 | 127 | ||
129 | static void | 128 | static void |
130 | run_more (void *cls, | 129 | run_more (void *cls, |
131 | struct GNUNET_SCHEDULER_Handle *sched, | ||
132 | char *const *args, | 130 | char *const *args, |
133 | const char *cfgfile, | 131 | const char *cfgfile, |
134 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 132 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
135 | { | 133 | { |
136 | h = GNUNET_STATISTICS_create (sched, "test-statistics-api", cfg); | 134 | h = GNUNET_STATISTICS_create ("test-statistics-api", cfg); |
137 | GNUNET_break (NULL != | 135 | GNUNET_break (NULL != |
138 | GNUNET_STATISTICS_get (h, NULL, "test-3", | 136 | GNUNET_STATISTICS_get (h, NULL, "test-3", |
139 | GNUNET_TIME_UNIT_SECONDS, &next_fin, &check_3, cls)); | 137 | 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 7eaa9d27b..02f4aca44 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) | |||
60 | 60 | ||
61 | static void | 61 | static void |
62 | run (void *cls, | 62 | run (void *cls, |
63 | struct GNUNET_SCHEDULER_Handle *sched, | ||
64 | char *const *args, | 63 | char *const *args, |
65 | const char *cfgfile, | 64 | const char *cfgfile, |
66 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 65 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -68,7 +67,7 @@ run (void *cls, | |||
68 | int i; | 67 | int i; |
69 | char name[128]; | 68 | char name[128]; |
70 | 69 | ||
71 | h = GNUNET_STATISTICS_create (sched, "test-statistics-api-loop", cfg); | 70 | h = GNUNET_STATISTICS_create ("test-statistics-api-loop", cfg); |
72 | for (i=0;i<ROUNDS;i++) | 71 | for (i=0;i<ROUNDS;i++) |
73 | { | 72 | { |
74 | GNUNET_snprintf (name, sizeof (name), "test-%d", i % 256); | 73 | GNUNET_snprintf (name, sizeof (name), "test-%d", i % 256); |