diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-04-30 08:17:37 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-04-30 08:17:37 +0000 |
commit | 95f9076a2139f5fb042b944a0658b6cda2fa35db (patch) | |
tree | b0826a2a1dcf812e6b4450fe6b05d47cd53ae49d /src/statistics | |
parent | 7746f68db77b9ca3c4aaca24ab2ce5253461240b (diff) | |
download | gnunet-95f9076a2139f5fb042b944a0658b6cda2fa35db.tar.gz gnunet-95f9076a2139f5fb042b944a0658b6cda2fa35db.zip |
implementing new scheduler shutdown semantics
Diffstat (limited to 'src/statistics')
-rw-r--r-- | src/statistics/gnunet-service-statistics.c | 5 | ||||
-rw-r--r-- | src/statistics/gnunet-statistics.c | 10 | ||||
-rw-r--r-- | src/statistics/statistics_api.c | 3 | ||||
-rw-r--r-- | src/statistics/test_statistics_api_watch.c | 17 |
4 files changed, 22 insertions, 13 deletions
diff --git a/src/statistics/gnunet-service-statistics.c b/src/statistics/gnunet-service-statistics.c index 0126f149b..adec5a96d 100644 --- a/src/statistics/gnunet-service-statistics.c +++ b/src/statistics/gnunet-service-statistics.c | |||
@@ -1053,9 +1053,8 @@ run (void *cls, | |||
1053 | &handle_client_disconnect, | 1053 | &handle_client_disconnect, |
1054 | NULL); | 1054 | NULL); |
1055 | load (server); | 1055 | load (server); |
1056 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 1056 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, |
1057 | &shutdown_task, | 1057 | NULL); |
1058 | NULL); | ||
1059 | } | 1058 | } |
1060 | 1059 | ||
1061 | 1060 | ||
diff --git a/src/statistics/gnunet-statistics.c b/src/statistics/gnunet-statistics.c index 2bf5959e3..f21da6059 100644 --- a/src/statistics/gnunet-statistics.c +++ b/src/statistics/gnunet-statistics.c | |||
@@ -180,7 +180,6 @@ shutdown_task (void *cls) | |||
180 | * Main task that does the actual work. | 180 | * Main task that does the actual work. |
181 | * | 181 | * |
182 | * @param cls closure with our configuration | 182 | * @param cls closure with our configuration |
183 | * @param tc schedueler context | ||
184 | */ | 183 | */ |
185 | static void | 184 | static void |
186 | main_task (void *cls) | 185 | main_task (void *cls) |
@@ -221,7 +220,8 @@ main_task (void *cls) | |||
221 | if (GNUNET_NO == watch) | 220 | if (GNUNET_NO == watch) |
222 | { | 221 | { |
223 | if (NULL == | 222 | if (NULL == |
224 | GNUNET_STATISTICS_get (h, subsystem, name, GET_TIMEOUT, &cleanup, | 223 | GNUNET_STATISTICS_get (h, subsystem, name, GET_TIMEOUT, |
224 | &cleanup, | ||
225 | &printer, h)) | 225 | &printer, h)) |
226 | cleanup (h, GNUNET_SYSERR); | 226 | cleanup (h, GNUNET_SYSERR); |
227 | } | 227 | } |
@@ -235,15 +235,15 @@ main_task (void *cls) | |||
235 | ret = 1; | 235 | ret = 1; |
236 | return; | 236 | return; |
237 | } | 237 | } |
238 | if (GNUNET_OK != GNUNET_STATISTICS_watch (h, subsystem, name, &printer, h)) | 238 | if (GNUNET_OK != GNUNET_STATISTICS_watch (h, subsystem, name, |
239 | &printer, h)) | ||
239 | { | 240 | { |
240 | fprintf (stderr, _("Failed to initialize watch routine\n")); | 241 | fprintf (stderr, _("Failed to initialize watch routine\n")); |
241 | GNUNET_SCHEDULER_add_now (&shutdown_task, h); | 242 | GNUNET_SCHEDULER_add_now (&shutdown_task, h); |
242 | return; | 243 | return; |
243 | } | 244 | } |
244 | } | 245 | } |
245 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 246 | GNUNET_SCHEDULER_add_shutdown (&shutdown_task, h); |
246 | &shutdown_task, h); | ||
247 | } | 247 | } |
248 | 248 | ||
249 | 249 | ||
diff --git a/src/statistics/statistics_api.c b/src/statistics/statistics_api.c index 2b491df72..32b973eec 100644 --- a/src/statistics/statistics_api.c +++ b/src/statistics/statistics_api.c | |||
@@ -1217,7 +1217,8 @@ GNUNET_STATISTICS_get (struct GNUNET_STATISTICS_Handle *handle, | |||
1217 | ai->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, | 1217 | ai->timeout_task = GNUNET_SCHEDULER_add_delayed (timeout, |
1218 | &run_get_timeout, | 1218 | &run_get_timeout, |
1219 | ai); | 1219 | ai); |
1220 | GNUNET_CONTAINER_DLL_insert_tail (handle->action_head, handle->action_tail, | 1220 | GNUNET_CONTAINER_DLL_insert_tail (handle->action_head, |
1221 | handle->action_tail, | ||
1221 | ai); | 1222 | ai); |
1222 | schedule_action (handle); | 1223 | schedule_action (handle); |
1223 | return ai; | 1224 | return ai; |
diff --git a/src/statistics/test_statistics_api_watch.c b/src/statistics/test_statistics_api_watch.c index c7fe54b1f..9b004d1d5 100644 --- a/src/statistics/test_statistics_api_watch.c +++ b/src/statistics/test_statistics_api_watch.c | |||
@@ -55,7 +55,10 @@ normal_shutdown (void *cls) | |||
55 | 55 | ||
56 | 56 | ||
57 | static int | 57 | static int |
58 | watch_1 (void *cls, const char *subsystem, const char *name, uint64_t value, | 58 | watch_1 (void *cls, |
59 | const char *subsystem, | ||
60 | const char *name, | ||
61 | uint64_t value, | ||
59 | int is_persistent) | 62 | int is_persistent) |
60 | { | 63 | { |
61 | GNUNET_assert (value == 42); | 64 | GNUNET_assert (value == 42); |
@@ -71,7 +74,10 @@ watch_1 (void *cls, const char *subsystem, const char *name, uint64_t value, | |||
71 | 74 | ||
72 | 75 | ||
73 | static int | 76 | static int |
74 | watch_2 (void *cls, const char *subsystem, const char *name, uint64_t value, | 77 | watch_2 (void *cls, |
78 | const char *subsystem, | ||
79 | const char *name, | ||
80 | uint64_t value, | ||
75 | int is_persistent) | 81 | int is_persistent) |
76 | { | 82 | { |
77 | GNUNET_assert (value == 43); | 83 | GNUNET_assert (value == 43); |
@@ -87,7 +93,9 @@ watch_2 (void *cls, const char *subsystem, const char *name, uint64_t value, | |||
87 | 93 | ||
88 | 94 | ||
89 | static void | 95 | static void |
90 | run (void *cls, char *const *args, const char *cfgfile, | 96 | run (void *cls, |
97 | char *const *args, | ||
98 | const char *cfgfile, | ||
91 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 99 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
92 | { | 100 | { |
93 | h = GNUNET_STATISTICS_create ("dummy", cfg); | 101 | h = GNUNET_STATISTICS_create ("dummy", cfg); |
@@ -101,7 +109,8 @@ run (void *cls, char *const *args, const char *cfgfile, | |||
101 | GNUNET_STATISTICS_set (h2, "test-1", 42, GNUNET_NO); | 109 | GNUNET_STATISTICS_set (h2, "test-1", 42, GNUNET_NO); |
102 | GNUNET_STATISTICS_set (h2, "test-2", 43, GNUNET_NO); | 110 | GNUNET_STATISTICS_set (h2, "test-2", 43, GNUNET_NO); |
103 | shutdown_task = | 111 | shutdown_task = |
104 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, &force_shutdown, | 112 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_MINUTES, |
113 | &force_shutdown, | ||
105 | NULL); | 114 | NULL); |
106 | } | 115 | } |
107 | 116 | ||