diff options
Diffstat (limited to 'src/arm')
-rw-r--r-- | src/arm/arm_api.c | 61 | ||||
-rw-r--r-- | src/arm/gnunet-arm.c | 25 | ||||
-rw-r--r-- | src/arm/gnunet-service-arm.c | 36 | ||||
-rw-r--r-- | src/arm/gnunet-service-arm.h | 3 | ||||
-rw-r--r-- | src/arm/gnunet-service-arm_interceptor.c | 75 | ||||
-rw-r--r-- | src/arm/mockup-service.c | 6 | ||||
-rw-r--r-- | src/arm/test_arm_api.c | 9 | ||||
-rw-r--r-- | src/arm/test_exponential_backoff.c | 37 | ||||
-rw-r--r-- | src/arm/test_gnunet_service_manager.c | 10 |
9 files changed, 84 insertions, 178 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index e404f8d27..f935c590f 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c | |||
@@ -49,11 +49,6 @@ struct GNUNET_ARM_Handle | |||
49 | */ | 49 | */ |
50 | struct GNUNET_CONFIGURATION_Handle *cfg; | 50 | struct GNUNET_CONFIGURATION_Handle *cfg; |
51 | 51 | ||
52 | /** | ||
53 | * Scheduler to use. | ||
54 | */ | ||
55 | struct GNUNET_SCHEDULER_Handle *sched; | ||
56 | |||
57 | }; | 52 | }; |
58 | 53 | ||
59 | 54 | ||
@@ -63,11 +58,6 @@ struct GNUNET_ARM_Handle | |||
63 | struct ShutdownContext | 58 | struct ShutdownContext |
64 | { | 59 | { |
65 | /** | 60 | /** |
66 | * Scheduler to be used to call continuation | ||
67 | */ | ||
68 | struct GNUNET_SCHEDULER_Handle *sched; | ||
69 | |||
70 | /** | ||
71 | * Connection to the service that is being shutdown. | 61 | * Connection to the service that is being shutdown. |
72 | */ | 62 | */ |
73 | struct GNUNET_CLIENT_Connection *sock; | 63 | struct GNUNET_CLIENT_Connection *sock; |
@@ -80,7 +70,7 @@ struct ShutdownContext | |||
80 | /** | 70 | /** |
81 | * Task set up to cancel the shutdown request on timeout. | 71 | * Task set up to cancel the shutdown request on timeout. |
82 | */ | 72 | */ |
83 | GNUNET_SCHEDULER_TaskIdentifier timeout_task; | 73 | GNUNET_SCHEDULER_TaskIdentifier cancel_task; |
84 | 74 | ||
85 | /** | 75 | /** |
86 | * Task to call once shutdown complete | 76 | * Task to call once shutdown complete |
@@ -99,7 +89,6 @@ struct ShutdownContext | |||
99 | 89 | ||
100 | }; | 90 | }; |
101 | 91 | ||
102 | |||
103 | /** | 92 | /** |
104 | * Handler receiving response to service shutdown requests. | 93 | * Handler receiving response to service shutdown requests. |
105 | * First call with NULL: service misbehaving, or something. | 94 | * First call with NULL: service misbehaving, or something. |
@@ -112,8 +101,7 @@ struct ShutdownContext | |||
112 | * @param msg NULL, indicating socket closure. | 101 | * @param msg NULL, indicating socket closure. |
113 | */ | 102 | */ |
114 | static void | 103 | static void |
115 | service_shutdown_handler (void *cls, | 104 | service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) |
116 | const struct GNUNET_MessageHeader *msg) | ||
117 | { | 105 | { |
118 | struct ShutdownContext *shutdown_ctx = cls; | 106 | struct ShutdownContext *shutdown_ctx = cls; |
119 | 107 | ||
@@ -124,7 +112,7 @@ service_shutdown_handler (void *cls, | |||
124 | "Service handle shutdown before ACK!\n"); | 112 | "Service handle shutdown before ACK!\n"); |
125 | if (shutdown_ctx->cont != NULL) | 113 | if (shutdown_ctx->cont != NULL) |
126 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); | 114 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); |
127 | GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->timeout_task); | 115 | GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task); |
128 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); | 116 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); |
129 | GNUNET_free(shutdown_ctx); | 117 | GNUNET_free(shutdown_ctx); |
130 | } | 118 | } |
@@ -137,7 +125,7 @@ service_shutdown_handler (void *cls, | |||
137 | if (shutdown_ctx->cont != NULL) | 125 | if (shutdown_ctx->cont != NULL) |
138 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO); | 126 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO); |
139 | 127 | ||
140 | GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->timeout_task); | 128 | GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task); |
141 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); | 129 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); |
142 | GNUNET_free(shutdown_ctx); | 130 | GNUNET_free(shutdown_ctx); |
143 | } | 131 | } |
@@ -165,7 +153,7 @@ service_shutdown_handler (void *cls, | |||
165 | if (shutdown_ctx->cont != NULL) | 153 | if (shutdown_ctx->cont != NULL) |
166 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES); | 154 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES); |
167 | 155 | ||
168 | GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->timeout_task); | 156 | GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task); |
169 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); | 157 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); |
170 | GNUNET_free(shutdown_ctx); | 158 | GNUNET_free(shutdown_ctx); |
171 | break; | 159 | break; |
@@ -173,21 +161,17 @@ service_shutdown_handler (void *cls, | |||
173 | } | 161 | } |
174 | } | 162 | } |
175 | 163 | ||
176 | |||
177 | /** | 164 | /** |
178 | * Shutting down took too long, cancel receive and return error. | 165 | * Shutting down took too long, cancel receive and return error. |
179 | * | 166 | * |
180 | * @param cls closure | 167 | * @param cls closure |
181 | * @param tc context information (why was this task triggered now) | 168 | * @param tc context information (why was this task triggered now) |
182 | */ | 169 | */ |
183 | static void | 170 | void service_shutdown_cancel (void *cls, |
184 | service_shutdown_timeout (void *cls, | 171 | const struct GNUNET_SCHEDULER_TaskContext * tc) |
185 | const struct GNUNET_SCHEDULER_TaskContext * tc) | ||
186 | { | 172 | { |
187 | struct ShutdownContext *shutdown_ctx = cls; | 173 | struct ShutdownContext *shutdown_ctx = cls; |
188 | 174 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "service_shutdown_cancel called!\n"); | |
189 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | ||
190 | _("Timeout during attempt to shutdown service. Hoping it is simply down already.\n")); | ||
191 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); | 175 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); |
192 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); | 176 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); |
193 | GNUNET_free(shutdown_ctx); | 177 | GNUNET_free(shutdown_ctx); |
@@ -222,10 +206,9 @@ write_shutdown (void *cls, size_t size, void *buf) | |||
222 | GNUNET_CLIENT_receive (shutdown_ctx->sock, | 206 | GNUNET_CLIENT_receive (shutdown_ctx->sock, |
223 | &service_shutdown_handler, shutdown_ctx, | 207 | &service_shutdown_handler, shutdown_ctx, |
224 | GNUNET_TIME_UNIT_FOREVER_REL); | 208 | GNUNET_TIME_UNIT_FOREVER_REL); |
225 | shutdown_ctx->timeout_task = GNUNET_SCHEDULER_add_delayed (shutdown_ctx->sched, | 209 | shutdown_ctx->cancel_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout), |
226 | GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout), | 210 | &service_shutdown_cancel, |
227 | &service_shutdown_timeout, | 211 | shutdown_ctx); |
228 | shutdown_ctx); | ||
229 | msg = (struct GNUNET_MessageHeader *) buf; | 212 | msg = (struct GNUNET_MessageHeader *) buf; |
230 | msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN); | 213 | msg->type = htons (GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN); |
231 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); | 214 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); |
@@ -240,7 +223,6 @@ write_shutdown (void *cls, size_t size, void *buf) | |||
240 | * be used by the caller after this call | 223 | * be used by the caller after this call |
241 | * (calling this function frees "sock" after a while). | 224 | * (calling this function frees "sock" after a while). |
242 | * | 225 | * |
243 | * @param sched the scheduler to use for calling shutdown continuation | ||
244 | * @param sock the socket connected to the service | 226 | * @param sock the socket connected to the service |
245 | * @param timeout how long to wait before giving up on transmission | 227 | * @param timeout how long to wait before giving up on transmission |
246 | * @param cont continuation to call once the service is really down | 228 | * @param cont continuation to call once the service is really down |
@@ -248,16 +230,13 @@ write_shutdown (void *cls, size_t size, void *buf) | |||
248 | * | 230 | * |
249 | */ | 231 | */ |
250 | static void | 232 | static void |
251 | arm_service_shutdown (struct GNUNET_SCHEDULER_Handle *sched, | 233 | arm_service_shutdown (struct GNUNET_CLIENT_Connection *sock, |
252 | struct GNUNET_CLIENT_Connection *sock, | ||
253 | struct GNUNET_TIME_Relative timeout, | 234 | struct GNUNET_TIME_Relative timeout, |
254 | GNUNET_CLIENT_ShutdownTask cont, | 235 | GNUNET_CLIENT_ShutdownTask cont, |
255 | void *cont_cls) | 236 | void *cont_cls) |
256 | { | 237 | { |
257 | struct ShutdownContext *shutdown_ctx; | 238 | struct ShutdownContext *shutdown_ctx; |
258 | |||
259 | shutdown_ctx = GNUNET_malloc(sizeof(struct ShutdownContext)); | 239 | shutdown_ctx = GNUNET_malloc(sizeof(struct ShutdownContext)); |
260 | shutdown_ctx->sched = sched; | ||
261 | shutdown_ctx->cont = cont; | 240 | shutdown_ctx->cont = cont; |
262 | shutdown_ctx->cont_cls = cont_cls; | 241 | shutdown_ctx->cont_cls = cont_cls; |
263 | shutdown_ctx->sock = sock; | 242 | shutdown_ctx->sock = sock; |
@@ -278,20 +257,17 @@ arm_service_shutdown (struct GNUNET_SCHEDULER_Handle *sched, | |||
278 | * @param cfg configuration to use (needed to contact ARM; | 257 | * @param cfg configuration to use (needed to contact ARM; |
279 | * the ARM service may internally use a different | 258 | * the ARM service may internally use a different |
280 | * configuration to determine how to start the service). | 259 | * configuration to determine how to start the service). |
281 | * @param sched scheduler to use | ||
282 | * @param service service that *this* process is implementing/providing, can be NULL | 260 | * @param service service that *this* process is implementing/providing, can be NULL |
283 | * @return context to use for further ARM operations, NULL on error | 261 | * @return context to use for further ARM operations, NULL on error |
284 | */ | 262 | */ |
285 | struct GNUNET_ARM_Handle * | 263 | struct GNUNET_ARM_Handle * |
286 | GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, | 264 | GNUNET_ARM_connect (const struct GNUNET_CONFIGURATION_Handle *cfg, |
287 | struct GNUNET_SCHEDULER_Handle *sched, | ||
288 | const char *service) | 265 | const char *service) |
289 | { | 266 | { |
290 | struct GNUNET_ARM_Handle *ret; | 267 | struct GNUNET_ARM_Handle *ret; |
291 | 268 | ||
292 | ret = GNUNET_malloc (sizeof (struct GNUNET_ARM_Handle)); | 269 | ret = GNUNET_malloc (sizeof (struct GNUNET_ARM_Handle)); |
293 | ret->cfg = GNUNET_CONFIGURATION_dup (cfg); | 270 | ret->cfg = GNUNET_CONFIGURATION_dup (cfg); |
294 | ret->sched = sched; | ||
295 | return ret; | 271 | return ret; |
296 | } | 272 | } |
297 | 273 | ||
@@ -517,8 +493,7 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) | |||
517 | : "STOP", | 493 | : "STOP", |
518 | (const char*) &sc[1]); | 494 | (const char*) &sc[1]); |
519 | GNUNET_CLIENT_disconnect (sc->h->client, GNUNET_NO); | 495 | GNUNET_CLIENT_disconnect (sc->h->client, GNUNET_NO); |
520 | sc->h->client = GNUNET_CLIENT_connect (sc->h->sched, | 496 | sc->h->client = GNUNET_CLIENT_connect ("arm", |
521 | "arm", | ||
522 | sc->h->cfg); | 497 | sc->h->cfg); |
523 | GNUNET_assert (NULL != sc->h->client); | 498 | GNUNET_assert (NULL != sc->h->client); |
524 | GNUNET_CLIENT_ignore_shutdown (sc->h->client, GNUNET_YES); | 499 | GNUNET_CLIENT_ignore_shutdown (sc->h->client, GNUNET_YES); |
@@ -641,7 +616,6 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, | |||
641 | struct RequestContext *sctx; | 616 | struct RequestContext *sctx; |
642 | struct GNUNET_CLIENT_Connection *client; | 617 | struct GNUNET_CLIENT_Connection *client; |
643 | size_t slen; | 618 | size_t slen; |
644 | |||
645 | #if DEBUG_ARM | 619 | #if DEBUG_ARM |
646 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 620 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
647 | _("Asked to start service `%s' within %llu ms\n"), service_name, | 621 | _("Asked to start service `%s' within %llu ms\n"), service_name, |
@@ -656,14 +630,13 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, | |||
656 | sctx->cls = cb_cls; | 630 | sctx->cls = cb_cls; |
657 | sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 631 | sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
658 | memcpy (&sctx[1], service_name, slen); | 632 | memcpy (&sctx[1], service_name, slen); |
659 | GNUNET_CLIENT_service_test (h->sched, | 633 | GNUNET_CLIENT_service_test ("arm", |
660 | "arm", | ||
661 | h->cfg, timeout, &arm_service_report, sctx); | 634 | h->cfg, timeout, &arm_service_report, sctx); |
662 | return; | 635 | return; |
663 | } | 636 | } |
664 | if (h->client == NULL) | 637 | if (h->client == NULL) |
665 | { | 638 | { |
666 | client = GNUNET_CLIENT_connect (h->sched, "arm", h->cfg); | 639 | client = GNUNET_CLIENT_connect ("arm", h->cfg); |
667 | if (client == NULL) | 640 | if (client == NULL) |
668 | { | 641 | { |
669 | cb (cb_cls, GNUNET_SYSERR); | 642 | cb (cb_cls, GNUNET_SYSERR); |
@@ -718,7 +691,7 @@ GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, | |||
718 | (unsigned long long) timeout.rel_value); | 691 | (unsigned long long) timeout.rel_value); |
719 | if (h->client == NULL) | 692 | if (h->client == NULL) |
720 | { | 693 | { |
721 | client = GNUNET_CLIENT_connect (h->sched, "arm", h->cfg); | 694 | client = GNUNET_CLIENT_connect ("arm", h->cfg); |
722 | if (client == NULL) | 695 | if (client == NULL) |
723 | { | 696 | { |
724 | cb (cb_cls, GNUNET_SYSERR); | 697 | cb (cb_cls, GNUNET_SYSERR); |
@@ -732,7 +705,7 @@ GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, | |||
732 | arm_shutdown_ctx = GNUNET_malloc(sizeof(struct ARM_ShutdownContext)); | 705 | arm_shutdown_ctx = GNUNET_malloc(sizeof(struct ARM_ShutdownContext)); |
733 | arm_shutdown_ctx->cb = cb; | 706 | arm_shutdown_ctx->cb = cb; |
734 | arm_shutdown_ctx->cb_cls = cb_cls; | 707 | arm_shutdown_ctx->cb_cls = cb_cls; |
735 | arm_service_shutdown (h->sched, h->client, timeout, &arm_shutdown_callback, arm_shutdown_ctx); | 708 | arm_service_shutdown (h->client, timeout, &arm_shutdown_callback, arm_shutdown_ctx); |
736 | h->client = NULL; | 709 | h->client = NULL; |
737 | return; | 710 | return; |
738 | } | 711 | } |
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index c19020ccb..ba74e8223 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c | |||
@@ -116,11 +116,6 @@ static int ret; | |||
116 | static struct GNUNET_ARM_Handle *h; | 116 | static struct GNUNET_ARM_Handle *h; |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * Our scheduler. | ||
120 | */ | ||
121 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
122 | |||
123 | /** | ||
124 | * Our configuration. | 119 | * Our configuration. |
125 | */ | 120 | */ |
126 | const struct GNUNET_CONFIGURATION_Handle *cfg; | 121 | const struct GNUNET_CONFIGURATION_Handle *cfg; |
@@ -184,8 +179,7 @@ confirm_cb (void *cls, int success) | |||
184 | break; | 179 | break; |
185 | } | 180 | } |
186 | 181 | ||
187 | GNUNET_SCHEDULER_add_continuation (sched, | 182 | GNUNET_SCHEDULER_add_continuation (&cps_loop, |
188 | &cps_loop, | ||
189 | NULL, | 183 | NULL, |
190 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 184 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
191 | } | 185 | } |
@@ -213,8 +207,7 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
213 | if (quiet != GNUNET_YES) | 207 | if (quiet != GNUNET_YES) |
214 | fprintf(stdout, _("Service `%s' is not running.\n"), service); | 208 | fprintf(stdout, _("Service `%s' is not running.\n"), service); |
215 | } | 209 | } |
216 | GNUNET_SCHEDULER_add_continuation (sched, | 210 | GNUNET_SCHEDULER_add_continuation (&cps_loop, |
217 | &cps_loop, | ||
218 | NULL, | 211 | NULL, |
219 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 212 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
220 | } | 213 | } |
@@ -224,19 +217,16 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
224 | * Main function that will be run by the scheduler. | 217 | * Main function that will be run by the scheduler. |
225 | * | 218 | * |
226 | * @param cls closure | 219 | * @param cls closure |
227 | * @param s the scheduler to use | ||
228 | * @param args remaining command-line arguments | 220 | * @param args remaining command-line arguments |
229 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) | 221 | * @param cfgfile name of the configuration file used (for saving, can be NULL!) |
230 | * @param c configuration | 222 | * @param c configuration |
231 | */ | 223 | */ |
232 | static void | 224 | static void |
233 | run (void *cls, | 225 | run (void *cls, |
234 | struct GNUNET_SCHEDULER_Handle *s, | ||
235 | char *const *args, | 226 | char *const *args, |
236 | const char *cfgfile, | 227 | const char *cfgfile, |
237 | const struct GNUNET_CONFIGURATION_Handle *c) | 228 | const struct GNUNET_CONFIGURATION_Handle *c) |
238 | { | 229 | { |
239 | sched = s; | ||
240 | cfg = c; | 230 | cfg = c; |
241 | config_file = cfgfile; | 231 | config_file = cfgfile; |
242 | if (GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "SERVICEHOME", &dir) != GNUNET_OK) | 232 | if (GNUNET_CONFIGURATION_get_value_string(cfg, "PATHS", "SERVICEHOME", &dir) != GNUNET_OK) |
@@ -247,7 +237,7 @@ run (void *cls, | |||
247 | "PATHS"); | 237 | "PATHS"); |
248 | return; | 238 | return; |
249 | } | 239 | } |
250 | h = GNUNET_ARM_connect (cfg, sched, NULL); | 240 | h = GNUNET_ARM_connect (cfg, NULL); |
251 | if (h == NULL) | 241 | if (h == NULL) |
252 | { | 242 | { |
253 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 243 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -255,8 +245,7 @@ run (void *cls, | |||
255 | ret = 1; | 245 | ret = 1; |
256 | return; | 246 | return; |
257 | } | 247 | } |
258 | GNUNET_SCHEDULER_add_continuation (sched, | 248 | GNUNET_SCHEDULER_add_continuation (&cps_loop, |
259 | &cps_loop, | ||
260 | NULL, | 249 | NULL, |
261 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 250 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
262 | } | 251 | } |
@@ -330,7 +319,7 @@ cps_loop (void *cls, | |||
330 | case 4: | 319 | case 4: |
331 | if (test != NULL) | 320 | if (test != NULL) |
332 | { | 321 | { |
333 | GNUNET_CLIENT_service_test (sched, test, cfg, TEST_TIMEOUT, &confirm_task, test); | 322 | GNUNET_CLIENT_service_test (test, cfg, TEST_TIMEOUT, &confirm_task, test); |
334 | return; | 323 | return; |
335 | } | 324 | } |
336 | break; | 325 | break; |
@@ -342,7 +331,7 @@ cps_loop (void *cls, | |||
342 | end = 0; | 331 | end = 0; |
343 | start = 1; | 332 | start = 1; |
344 | restart = 0; | 333 | restart = 0; |
345 | h = GNUNET_ARM_connect (cfg, sched, NULL); | 334 | h = GNUNET_ARM_connect (cfg, NULL); |
346 | if (h == NULL) | 335 | if (h == NULL) |
347 | { | 336 | { |
348 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 337 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -350,7 +339,7 @@ cps_loop (void *cls, | |||
350 | ret = 1; | 339 | ret = 1; |
351 | return; | 340 | return; |
352 | } | 341 | } |
353 | GNUNET_SCHEDULER_add_now(sched, &cps_loop, NULL); | 342 | GNUNET_SCHEDULER_add_now(&cps_loop, NULL); |
354 | return; | 343 | return; |
355 | } | 344 | } |
356 | /* Fall through */ | 345 | /* Fall through */ |
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index ab4db97c7..c967c64e6 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c | |||
@@ -124,11 +124,6 @@ static struct ServiceList *running; | |||
124 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 124 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
125 | 125 | ||
126 | /** | 126 | /** |
127 | * Our scheduler. | ||
128 | */ | ||
129 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
130 | |||
131 | /** | ||
132 | * Command to prepend to each actual command. | 127 | * Command to prepend to each actual command. |
133 | */ | 128 | */ |
134 | static char *prefix_command; | 129 | static char *prefix_command; |
@@ -695,7 +690,7 @@ do_shutdown () | |||
695 | { | 690 | { |
696 | GNUNET_SERVER_destroy (server); | 691 | GNUNET_SERVER_destroy (server); |
697 | server = NULL; | 692 | server = NULL; |
698 | GNUNET_SCHEDULER_cancel (sched, child_death_task); | 693 | GNUNET_SCHEDULER_cancel (child_death_task); |
699 | child_death_task = GNUNET_SCHEDULER_NO_TASK; | 694 | child_death_task = GNUNET_SCHEDULER_NO_TASK; |
700 | } | 695 | } |
701 | 696 | ||
@@ -741,7 +736,7 @@ shutdown_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
741 | pos = pos->next; | 736 | pos = pos->next; |
742 | } | 737 | } |
743 | #if DELAY_SHUTDOWN | 738 | #if DELAY_SHUTDOWN |
744 | GNUNET_SCHEDULER_add_delayed(sched, GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &dummy_task, NULL); | 739 | GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 2), &dummy_task, NULL); |
745 | #endif | 740 | #endif |
746 | if (running == NULL) | 741 | if (running == NULL) |
747 | do_shutdown (); | 742 | do_shutdown (); |
@@ -802,8 +797,7 @@ delayed_restart_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
802 | (unsigned long long) lowestRestartDelay.rel_value); | 797 | (unsigned long long) lowestRestartDelay.rel_value); |
803 | #endif | 798 | #endif |
804 | child_restart_task | 799 | child_restart_task |
805 | = GNUNET_SCHEDULER_add_delayed (sched, | 800 | = GNUNET_SCHEDULER_add_delayed (lowestRestartDelay, |
806 | lowestRestartDelay, | ||
807 | &delayed_restart_task, | 801 | &delayed_restart_task, |
808 | NULL); | 802 | NULL); |
809 | } | 803 | } |
@@ -834,7 +828,7 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
834 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) | 828 | if (0 == (tc->reason & GNUNET_SCHEDULER_REASON_READ_READY)) |
835 | { | 829 | { |
836 | child_death_task = | 830 | child_death_task = |
837 | GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, pr, | 831 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr, |
838 | &maint_child_death, NULL); | 832 | &maint_child_death, NULL); |
839 | return; | 833 | return; |
840 | } | 834 | } |
@@ -909,10 +903,9 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
909 | pos->backoff | 903 | pos->backoff |
910 | = GNUNET_TIME_relative_multiply (pos->backoff, 2); | 904 | = GNUNET_TIME_relative_multiply (pos->backoff, 2); |
911 | if (GNUNET_SCHEDULER_NO_TASK != child_restart_task) | 905 | if (GNUNET_SCHEDULER_NO_TASK != child_restart_task) |
912 | GNUNET_SCHEDULER_cancel (sched, child_restart_task); | 906 | GNUNET_SCHEDULER_cancel (child_restart_task); |
913 | child_restart_task | 907 | child_restart_task |
914 | = GNUNET_SCHEDULER_add_with_priority (sched, | 908 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
915 | GNUNET_SCHEDULER_PRIORITY_IDLE, | ||
916 | &delayed_restart_task, | 909 | &delayed_restart_task, |
917 | NULL); | 910 | NULL); |
918 | } | 911 | } |
@@ -934,7 +927,7 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
934 | else | 927 | else |
935 | { | 928 | { |
936 | child_death_task = | 929 | child_death_task = |
937 | GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, pr, | 930 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr, |
938 | &maint_child_death, NULL); | 931 | &maint_child_death, NULL); |
939 | } | 932 | } |
940 | } | 933 | } |
@@ -986,7 +979,7 @@ handle_shutdown (void *cls, | |||
986 | GNUNET_TIME_UNIT_FOREVER_REL, | 979 | GNUNET_TIME_UNIT_FOREVER_REL, |
987 | &transmit_shutdown_ack, client); | 980 | &transmit_shutdown_ack, client); |
988 | GNUNET_SERVER_client_persist_ (client); | 981 | GNUNET_SERVER_client_persist_ (client); |
989 | GNUNET_SCHEDULER_shutdown (sched); | 982 | GNUNET_SCHEDULER_shutdown (); |
990 | } | 983 | } |
991 | 984 | ||
992 | 985 | ||
@@ -1011,13 +1004,11 @@ sighandler_child_death () | |||
1011 | * Process arm requests. | 1004 | * Process arm requests. |
1012 | * | 1005 | * |
1013 | * @param cls closure | 1006 | * @param cls closure |
1014 | * @param s scheduler to use | ||
1015 | * @param serv the initialized server | 1007 | * @param serv the initialized server |
1016 | * @param c configuration to use | 1008 | * @param c configuration to use |
1017 | */ | 1009 | */ |
1018 | static void | 1010 | static void |
1019 | run (void *cls, | 1011 | run (void *cls, |
1020 | struct GNUNET_SCHEDULER_Handle *s, | ||
1021 | struct GNUNET_SERVER_Handle *serv, | 1012 | struct GNUNET_SERVER_Handle *serv, |
1022 | const struct GNUNET_CONFIGURATION_Handle *c) | 1013 | const struct GNUNET_CONFIGURATION_Handle *c) |
1023 | { | 1014 | { |
@@ -1032,18 +1023,16 @@ run (void *cls, | |||
1032 | char *pos; | 1023 | char *pos; |
1033 | 1024 | ||
1034 | cfg = c; | 1025 | cfg = c; |
1035 | sched = s; | ||
1036 | server = serv; | 1026 | server = serv; |
1037 | GNUNET_assert (serv != NULL); | 1027 | GNUNET_assert (serv != NULL); |
1038 | pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); | 1028 | pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); |
1039 | GNUNET_assert (pr != NULL); | 1029 | GNUNET_assert (pr != NULL); |
1040 | GNUNET_SERVER_ignore_shutdown (serv, GNUNET_YES); | 1030 | GNUNET_SERVER_ignore_shutdown (serv, GNUNET_YES); |
1041 | GNUNET_SCHEDULER_add_delayed (sched, | 1031 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, |
1042 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
1043 | &shutdown_task, | 1032 | &shutdown_task, |
1044 | NULL); | 1033 | NULL); |
1045 | child_death_task = | 1034 | child_death_task = |
1046 | GNUNET_SCHEDULER_add_read_file (sched, GNUNET_TIME_UNIT_FOREVER_REL, pr, | 1035 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr, |
1047 | &maint_child_death, NULL); | 1036 | &maint_child_death, NULL); |
1048 | 1037 | ||
1049 | if (GNUNET_OK != | 1038 | if (GNUNET_OK != |
@@ -1089,14 +1078,13 @@ run (void *cls, | |||
1089 | } | 1078 | } |
1090 | 1079 | ||
1091 | /* create listening sockets for future services*/ | 1080 | /* create listening sockets for future services*/ |
1092 | prepareServices (cfg, sched); | 1081 | prepareServices (cfg); |
1093 | 1082 | ||
1094 | /* process client requests */ | 1083 | /* process client requests */ |
1095 | GNUNET_SERVER_add_handlers (server, handlers); | 1084 | GNUNET_SERVER_add_handlers (server, handlers); |
1096 | 1085 | ||
1097 | /* manage services */ | 1086 | /* manage services */ |
1098 | GNUNET_SCHEDULER_add_with_priority (sched, | 1087 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
1099 | GNUNET_SCHEDULER_PRIORITY_IDLE, | ||
1100 | &config_change_task, NULL); | 1088 | &config_change_task, NULL); |
1101 | } | 1089 | } |
1102 | 1090 | ||
diff --git a/src/arm/gnunet-service-arm.h b/src/arm/gnunet-service-arm.h index 1f9085889..0ef557157 100644 --- a/src/arm/gnunet-service-arm.h +++ b/src/arm/gnunet-service-arm.h | |||
@@ -49,7 +49,6 @@ int start_service (struct GNUNET_SERVER_Client *client, | |||
49 | int stop_listening (const char *serviceName); | 49 | int stop_listening (const char *serviceName); |
50 | 50 | ||
51 | void prepareServices (const struct GNUNET_CONFIGURATION_Handle | 51 | void prepareServices (const struct GNUNET_CONFIGURATION_Handle |
52 | *configurationHandle, | 52 | *configurationHandle); |
53 | struct GNUNET_SCHEDULER_Handle *sched); | ||
54 | 53 | ||
55 | #endif | 54 | #endif |
diff --git a/src/arm/gnunet-service-arm_interceptor.c b/src/arm/gnunet-service-arm_interceptor.c index 8f79db6c5..56268b2d0 100644 --- a/src/arm/gnunet-service-arm_interceptor.c +++ b/src/arm/gnunet-service-arm_interceptor.c | |||
@@ -208,11 +208,6 @@ static const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
208 | /** | 208 | /** |
209 | * | 209 | * |
210 | */ | 210 | */ |
211 | static struct GNUNET_SCHEDULER_Handle *scheduler; | ||
212 | |||
213 | /** | ||
214 | * | ||
215 | */ | ||
216 | static struct ServiceListeningInfo *serviceListeningInfoList_head; | 211 | static struct ServiceListeningInfo *serviceListeningInfoList_head; |
217 | 212 | ||
218 | /** | 213 | /** |
@@ -293,7 +288,7 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc, | |||
293 | #endif | 288 | #endif |
294 | if (fc->service_to_client_task != GNUNET_SCHEDULER_NO_TASK) | 289 | if (fc->service_to_client_task != GNUNET_SCHEDULER_NO_TASK) |
295 | { | 290 | { |
296 | GNUNET_SCHEDULER_cancel (scheduler, fc->service_to_client_task); | 291 | GNUNET_SCHEDULER_cancel (fc->service_to_client_task); |
297 | fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; | 292 | fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; |
298 | } | 293 | } |
299 | if (fc->armClientSocket != NULL) | 294 | if (fc->armClientSocket != NULL) |
@@ -312,8 +307,7 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc, | |||
312 | #endif | 307 | #endif |
313 | if (fc->client_to_service_task != GNUNET_SCHEDULER_NO_TASK) | 308 | if (fc->client_to_service_task != GNUNET_SCHEDULER_NO_TASK) |
314 | { | 309 | { |
315 | GNUNET_SCHEDULER_cancel (scheduler, | 310 | GNUNET_SCHEDULER_cancel ( fc->client_to_service_task); |
316 | fc->client_to_service_task); | ||
317 | fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK; | 311 | fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK; |
318 | } | 312 | } |
319 | if (fc->armClientSocket != NULL) | 313 | if (fc->armClientSocket != NULL) |
@@ -331,8 +325,7 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc, | |||
331 | "Closing forwarding connection (done with both directions)\n"); | 325 | "Closing forwarding connection (done with both directions)\n"); |
332 | #endif | 326 | #endif |
333 | if (fc->start_task != GNUNET_SCHEDULER_NO_TASK) | 327 | if (fc->start_task != GNUNET_SCHEDULER_NO_TASK) |
334 | GNUNET_SCHEDULER_cancel (scheduler, | 328 | GNUNET_SCHEDULER_cancel ( fc->start_task); |
335 | fc->start_task); | ||
336 | if ( (NULL != fc->armClientSocket) && | 329 | if ( (NULL != fc->armClientSocket) && |
337 | (GNUNET_SYSERR == | 330 | (GNUNET_SYSERR == |
338 | GNUNET_NETWORK_socket_close (fc->armClientSocket)) ) | 331 | GNUNET_NETWORK_socket_close (fc->armClientSocket)) ) |
@@ -388,7 +381,7 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
388 | fc->armClientSocket)) | 381 | fc->armClientSocket)) |
389 | { | 382 | { |
390 | fc->service_to_client_task = | 383 | fc->service_to_client_task = |
391 | GNUNET_SCHEDULER_add_write_net (scheduler, | 384 | GNUNET_SCHEDULER_add_write_net ( |
392 | GNUNET_TIME_UNIT_FOREVER_REL, | 385 | GNUNET_TIME_UNIT_FOREVER_REL, |
393 | fc->armClientSocket, | 386 | fc->armClientSocket, |
394 | &forwardToClient, fc); | 387 | &forwardToClient, fc); |
@@ -421,7 +414,7 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
421 | fc->service_to_client_bufferPos += numberOfBytesSent; | 414 | fc->service_to_client_bufferPos += numberOfBytesSent; |
422 | fc->service_to_client_bufferDataLength -= numberOfBytesSent; | 415 | fc->service_to_client_bufferDataLength -= numberOfBytesSent; |
423 | fc->service_to_client_task = | 416 | fc->service_to_client_task = |
424 | GNUNET_SCHEDULER_add_write_net (scheduler, | 417 | GNUNET_SCHEDULER_add_write_net ( |
425 | GNUNET_TIME_UNIT_FOREVER_REL, | 418 | GNUNET_TIME_UNIT_FOREVER_REL, |
426 | fc->armClientSocket, | 419 | fc->armClientSocket, |
427 | &forwardToClient, | 420 | &forwardToClient, |
@@ -429,8 +422,7 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
429 | return; | 422 | return; |
430 | } | 423 | } |
431 | fc->service_to_client_task = | 424 | fc->service_to_client_task = |
432 | GNUNET_SCHEDULER_add_read_net (scheduler, | 425 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
433 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
434 | fc->armServiceSocket, | 426 | fc->armServiceSocket, |
435 | &receiveFromService, | 427 | &receiveFromService, |
436 | fc); | 428 | fc); |
@@ -461,7 +453,7 @@ receiveFromService (void *cls, | |||
461 | fc->armServiceSocket)) | 453 | fc->armServiceSocket)) |
462 | { | 454 | { |
463 | fc->service_to_client_task = | 455 | fc->service_to_client_task = |
464 | GNUNET_SCHEDULER_add_read_net (scheduler, | 456 | GNUNET_SCHEDULER_add_read_net ( |
465 | GNUNET_TIME_UNIT_FOREVER_REL, | 457 | GNUNET_TIME_UNIT_FOREVER_REL, |
466 | fc->armServiceSocket, | 458 | fc->armServiceSocket, |
467 | &receiveFromService, fc); | 459 | &receiveFromService, fc); |
@@ -491,8 +483,7 @@ receiveFromService (void *cls, | |||
491 | if ( (fc->client_to_service_bufferDataLength > 0) && | 483 | if ( (fc->client_to_service_bufferDataLength > 0) && |
492 | (fc->client_to_service_task != GNUNET_SCHEDULER_NO_TASK) ) | 484 | (fc->client_to_service_task != GNUNET_SCHEDULER_NO_TASK) ) |
493 | { | 485 | { |
494 | GNUNET_SCHEDULER_cancel (scheduler, | 486 | GNUNET_SCHEDULER_cancel (fc->client_to_service_task); |
495 | fc->client_to_service_task); | ||
496 | fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK; | 487 | fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK; |
497 | } | 488 | } |
498 | fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2); | 489 | fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2); |
@@ -508,7 +499,7 @@ receiveFromService (void *cls, | |||
508 | rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); | 499 | rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); |
509 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); | 500 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); |
510 | fc->start_task | 501 | fc->start_task |
511 | = GNUNET_SCHEDULER_add_delayed (scheduler, | 502 | = GNUNET_SCHEDULER_add_delayed ( |
512 | GNUNET_TIME_relative_min (fc->back_off, | 503 | GNUNET_TIME_relative_min (fc->back_off, |
513 | rem), | 504 | rem), |
514 | &start_forwarding, | 505 | &start_forwarding, |
@@ -533,7 +524,7 @@ receiveFromService (void *cls, | |||
533 | fc->service_to_client_bufferDataLength); | 524 | fc->service_to_client_bufferDataLength); |
534 | #endif | 525 | #endif |
535 | fc->service_to_client_task = | 526 | fc->service_to_client_task = |
536 | GNUNET_SCHEDULER_add_write_net (scheduler, | 527 | GNUNET_SCHEDULER_add_write_net ( |
537 | GNUNET_TIME_UNIT_FOREVER_REL, | 528 | GNUNET_TIME_UNIT_FOREVER_REL, |
538 | fc->armClientSocket, | 529 | fc->armClientSocket, |
539 | &forwardToClient, fc); | 530 | &forwardToClient, fc); |
@@ -565,7 +556,7 @@ forwardToService (void *cls, | |||
565 | fc->armServiceSocket)) | 556 | fc->armServiceSocket)) |
566 | { | 557 | { |
567 | fc->client_to_service_task = | 558 | fc->client_to_service_task = |
568 | GNUNET_SCHEDULER_add_write_net (scheduler, | 559 | GNUNET_SCHEDULER_add_write_net ( |
569 | GNUNET_TIME_UNIT_FOREVER_REL, | 560 | GNUNET_TIME_UNIT_FOREVER_REL, |
570 | fc->armServiceSocket, | 561 | fc->armServiceSocket, |
571 | &forwardToService, fc); | 562 | &forwardToService, fc); |
@@ -585,8 +576,7 @@ forwardToService (void *cls, | |||
585 | if ( (fc->service_to_client_bufferDataLength == 0) && | 576 | if ( (fc->service_to_client_bufferDataLength == 0) && |
586 | (fc->service_to_client_task != GNUNET_SCHEDULER_NO_TASK) ) | 577 | (fc->service_to_client_task != GNUNET_SCHEDULER_NO_TASK) ) |
587 | { | 578 | { |
588 | GNUNET_SCHEDULER_cancel (scheduler, | 579 | GNUNET_SCHEDULER_cancel (fc->service_to_client_task); |
589 | fc->service_to_client_task); | ||
590 | fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; | 580 | fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; |
591 | } | 581 | } |
592 | fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2); | 582 | fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2); |
@@ -602,8 +592,7 @@ forwardToService (void *cls, | |||
602 | rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); | 592 | rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); |
603 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); | 593 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); |
604 | fc->start_task | 594 | fc->start_task |
605 | = GNUNET_SCHEDULER_add_delayed (scheduler, | 595 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_min (fc->back_off, |
606 | GNUNET_TIME_relative_min (fc->back_off, | ||
607 | rem), | 596 | rem), |
608 | &start_forwarding, | 597 | &start_forwarding, |
609 | fc); | 598 | fc); |
@@ -631,15 +620,14 @@ forwardToService (void *cls, | |||
631 | fc->client_to_service_bufferPos += numberOfBytesSent; | 620 | fc->client_to_service_bufferPos += numberOfBytesSent; |
632 | fc->client_to_service_bufferDataLength -= numberOfBytesSent; | 621 | fc->client_to_service_bufferDataLength -= numberOfBytesSent; |
633 | fc->client_to_service_task = | 622 | fc->client_to_service_task = |
634 | GNUNET_SCHEDULER_add_write_net (scheduler, | 623 | GNUNET_SCHEDULER_add_write_net ( |
635 | GNUNET_TIME_UNIT_FOREVER_REL, | 624 | GNUNET_TIME_UNIT_FOREVER_REL, |
636 | fc->armServiceSocket, | 625 | fc->armServiceSocket, |
637 | &forwardToService, fc); | 626 | &forwardToService, fc); |
638 | return; | 627 | return; |
639 | } | 628 | } |
640 | fc->client_to_service_task = | 629 | fc->client_to_service_task = |
641 | GNUNET_SCHEDULER_add_read_net (scheduler, | 630 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
642 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
643 | fc->armClientSocket, | 631 | fc->armClientSocket, |
644 | &receiveFromClient, fc); | 632 | &receiveFromClient, fc); |
645 | } | 633 | } |
@@ -661,7 +649,7 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
661 | fc->armClientSocket)) | 649 | fc->armClientSocket)) |
662 | { | 650 | { |
663 | fc->client_to_service_task = | 651 | fc->client_to_service_task = |
664 | GNUNET_SCHEDULER_add_read_net (scheduler, | 652 | GNUNET_SCHEDULER_add_read_net ( |
665 | GNUNET_TIME_UNIT_FOREVER_REL, | 653 | GNUNET_TIME_UNIT_FOREVER_REL, |
666 | fc->armClientSocket, | 654 | fc->armClientSocket, |
667 | &receiveFromClient, fc); | 655 | &receiveFromClient, fc); |
@@ -700,7 +688,7 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
700 | #endif | 688 | #endif |
701 | if (fc->armServiceSocket != NULL) | 689 | if (fc->armServiceSocket != NULL) |
702 | fc->client_to_service_task = | 690 | fc->client_to_service_task = |
703 | GNUNET_SCHEDULER_add_write_net (scheduler, | 691 | GNUNET_SCHEDULER_add_write_net ( |
704 | GNUNET_TIME_UNIT_FOREVER_REL, | 692 | GNUNET_TIME_UNIT_FOREVER_REL, |
705 | fc->armServiceSocket, | 693 | fc->armServiceSocket, |
706 | &forwardToService, fc); | 694 | &forwardToService, fc); |
@@ -769,8 +757,7 @@ start_forwarding (void *cls, | |||
769 | #endif | 757 | #endif |
770 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); | 758 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); |
771 | fc->start_task | 759 | fc->start_task |
772 | = GNUNET_SCHEDULER_add_delayed (scheduler, | 760 | = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_min (fc->back_off, |
773 | GNUNET_TIME_relative_min (fc->back_off, | ||
774 | rem), | 761 | rem), |
775 | &start_forwarding, | 762 | &start_forwarding, |
776 | fc); | 763 | fc); |
@@ -784,13 +771,13 @@ start_forwarding (void *cls, | |||
784 | { | 771 | { |
785 | if (fc->client_to_service_bufferDataLength == 0) | 772 | if (fc->client_to_service_bufferDataLength == 0) |
786 | fc->client_to_service_task = | 773 | fc->client_to_service_task = |
787 | GNUNET_SCHEDULER_add_read_net (scheduler, | 774 | GNUNET_SCHEDULER_add_read_net ( |
788 | GNUNET_TIME_UNIT_FOREVER_REL, | 775 | GNUNET_TIME_UNIT_FOREVER_REL, |
789 | fc->armClientSocket, | 776 | fc->armClientSocket, |
790 | &receiveFromClient, fc); | 777 | &receiveFromClient, fc); |
791 | else | 778 | else |
792 | fc->client_to_service_task = | 779 | fc->client_to_service_task = |
793 | GNUNET_SCHEDULER_add_write_net (scheduler, | 780 | GNUNET_SCHEDULER_add_write_net ( |
794 | GNUNET_TIME_UNIT_FOREVER_REL, | 781 | GNUNET_TIME_UNIT_FOREVER_REL, |
795 | fc->armServiceSocket, | 782 | fc->armServiceSocket, |
796 | &forwardToService, fc); | 783 | &forwardToService, fc); |
@@ -799,13 +786,13 @@ start_forwarding (void *cls, | |||
799 | { | 786 | { |
800 | if (fc->service_to_client_bufferDataLength == 0) | 787 | if (fc->service_to_client_bufferDataLength == 0) |
801 | fc->service_to_client_task = | 788 | fc->service_to_client_task = |
802 | GNUNET_SCHEDULER_add_read_net (scheduler, | 789 | GNUNET_SCHEDULER_add_read_net ( |
803 | GNUNET_TIME_UNIT_FOREVER_REL, | 790 | GNUNET_TIME_UNIT_FOREVER_REL, |
804 | fc->armServiceSocket, | 791 | fc->armServiceSocket, |
805 | &receiveFromService, fc); | 792 | &receiveFromService, fc); |
806 | else | 793 | else |
807 | fc->service_to_client_task = | 794 | fc->service_to_client_task = |
808 | GNUNET_SCHEDULER_add_write_net (scheduler, | 795 | GNUNET_SCHEDULER_add_write_net ( |
809 | GNUNET_TIME_UNIT_FOREVER_REL, | 796 | GNUNET_TIME_UNIT_FOREVER_REL, |
810 | fc->armClientSocket, | 797 | fc->armClientSocket, |
811 | &forwardToClient, fc); | 798 | &forwardToClient, fc); |
@@ -833,7 +820,7 @@ stop_listening (const char *serviceName) | |||
833 | (strcmp (pos->serviceName, serviceName) != 0) ) | 820 | (strcmp (pos->serviceName, serviceName) != 0) ) |
834 | continue; | 821 | continue; |
835 | if (pos->acceptTask != GNUNET_SCHEDULER_NO_TASK) | 822 | if (pos->acceptTask != GNUNET_SCHEDULER_NO_TASK) |
836 | GNUNET_SCHEDULER_cancel (scheduler, pos->acceptTask); | 823 | GNUNET_SCHEDULER_cancel (pos->acceptTask); |
837 | GNUNET_break (GNUNET_OK == | 824 | GNUNET_break (GNUNET_OK == |
838 | GNUNET_NETWORK_socket_close (pos->listeningSocket)); | 825 | GNUNET_NETWORK_socket_close (pos->listeningSocket)); |
839 | GNUNET_CONTAINER_DLL_remove (serviceListeningInfoList_head, | 826 | GNUNET_CONTAINER_DLL_remove (serviceListeningInfoList_head, |
@@ -882,7 +869,7 @@ accept_and_forward (struct ServiceListeningInfo *serviceListeningInfo) | |||
882 | serviceListeningInfoList_tail, | 869 | serviceListeningInfoList_tail, |
883 | serviceListeningInfo); | 870 | serviceListeningInfo); |
884 | serviceListeningInfo->acceptTask = | 871 | serviceListeningInfo->acceptTask = |
885 | GNUNET_SCHEDULER_add_read_net (scheduler, | 872 | GNUNET_SCHEDULER_add_read_net ( |
886 | GNUNET_TIME_UNIT_FOREVER_REL, | 873 | GNUNET_TIME_UNIT_FOREVER_REL, |
887 | serviceListeningInfo->listeningSocket, | 874 | serviceListeningInfo->listeningSocket, |
888 | &acceptConnection, | 875 | &acceptConnection, |
@@ -898,14 +885,13 @@ accept_and_forward (struct ServiceListeningInfo *serviceListeningInfo) | |||
898 | fc->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_SERVICE_TIMEOUT); | 885 | fc->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_SERVICE_TIMEOUT); |
899 | fc->back_off = GNUNET_TIME_UNIT_MILLISECONDS; | 886 | fc->back_off = GNUNET_TIME_UNIT_MILLISECONDS; |
900 | fc->client_to_service_task = | 887 | fc->client_to_service_task = |
901 | GNUNET_SCHEDULER_add_read_net (scheduler, | 888 | GNUNET_SCHEDULER_add_read_net ( |
902 | GNUNET_TIME_UNIT_FOREVER_REL, | 889 | GNUNET_TIME_UNIT_FOREVER_REL, |
903 | fc->armClientSocket, | 890 | fc->armClientSocket, |
904 | &receiveFromClient, fc); | 891 | &receiveFromClient, fc); |
905 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); | 892 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); |
906 | fc->start_task | 893 | fc->start_task |
907 | = GNUNET_SCHEDULER_add_now (scheduler, | 894 | = GNUNET_SCHEDULER_add_now (&start_forwarding, |
908 | &start_forwarding, | ||
909 | fc); | 895 | fc); |
910 | } | 896 | } |
911 | 897 | ||
@@ -963,8 +949,7 @@ acceptConnection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
963 | GNUNET_free (pos->listeningSocket); /* deliberately no closing! */ | 949 | GNUNET_free (pos->listeningSocket); /* deliberately no closing! */ |
964 | GNUNET_free (pos->service_addr); | 950 | GNUNET_free (pos->service_addr); |
965 | GNUNET_free (pos->serviceName); | 951 | GNUNET_free (pos->serviceName); |
966 | GNUNET_SCHEDULER_cancel (scheduler, | 952 | GNUNET_SCHEDULER_cancel ( pos->acceptTask); |
967 | pos->acceptTask); | ||
968 | GNUNET_CONTAINER_DLL_remove (serviceListeningInfoList_head, | 953 | GNUNET_CONTAINER_DLL_remove (serviceListeningInfoList_head, |
969 | serviceListeningInfoList_tail, | 954 | serviceListeningInfoList_tail, |
970 | pos); | 955 | pos); |
@@ -1073,7 +1058,7 @@ createListeningSocket (struct sockaddr *sa, | |||
1073 | serviceListeningInfo->service_addr_len = addr_len; | 1058 | serviceListeningInfo->service_addr_len = addr_len; |
1074 | serviceListeningInfo->listeningSocket = sock; | 1059 | serviceListeningInfo->listeningSocket = sock; |
1075 | serviceListeningInfo->acceptTask = | 1060 | serviceListeningInfo->acceptTask = |
1076 | GNUNET_SCHEDULER_add_read_net (scheduler, | 1061 | GNUNET_SCHEDULER_add_read_net ( |
1077 | GNUNET_TIME_UNIT_FOREVER_REL, sock, | 1062 | GNUNET_TIME_UNIT_FOREVER_REL, sock, |
1078 | &acceptConnection, | 1063 | &acceptConnection, |
1079 | serviceListeningInfo); | 1064 | serviceListeningInfo); |
@@ -1123,15 +1108,13 @@ checkPortNumberCB (void *cls, | |||
1123 | * Entry point to the Service Manager | 1108 | * Entry point to the Service Manager |
1124 | * | 1109 | * |
1125 | * @param configurationHandle configuration to use to get services | 1110 | * @param configurationHandle configuration to use to get services |
1126 | * @param sched scheduler to handle clients and services communications | ||
1127 | */ | 1111 | */ |
1128 | void | 1112 | void |
1129 | prepareServices (const struct GNUNET_CONFIGURATION_Handle | 1113 | prepareServices (const struct GNUNET_CONFIGURATION_Handle |
1130 | *configurationHandle, struct GNUNET_SCHEDULER_Handle *sched) | 1114 | *configurationHandle) |
1131 | { | 1115 | { |
1132 | char *defaultServicesString; | 1116 | char *defaultServicesString; |
1133 | 1117 | ||
1134 | scheduler = sched; | ||
1135 | cfg = configurationHandle; | 1118 | cfg = configurationHandle; |
1136 | /* Split the default services into a list */ | 1119 | /* Split the default services into a list */ |
1137 | if (GNUNET_OK == | 1120 | if (GNUNET_OK == |
diff --git a/src/arm/mockup-service.c b/src/arm/mockup-service.c index da8ada1db..4dae8ffb4 100644 --- a/src/arm/mockup-service.c +++ b/src/arm/mockup-service.c | |||
@@ -28,8 +28,6 @@ | |||
28 | #include "gnunet_strings_lib.h" | 28 | #include "gnunet_strings_lib.h" |
29 | #include "gnunet_time_lib.h" | 29 | #include "gnunet_time_lib.h" |
30 | 30 | ||
31 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
32 | |||
33 | 31 | ||
34 | static size_t | 32 | static size_t |
35 | transmit_shutdown_ack (void *cls, size_t size, void *buf) | 33 | transmit_shutdown_ack (void *cls, size_t size, void *buf) |
@@ -77,13 +75,12 @@ handle_shutdown (void *cls, | |||
77 | GNUNET_TIME_UNIT_FOREVER_REL, | 75 | GNUNET_TIME_UNIT_FOREVER_REL, |
78 | &transmit_shutdown_ack, client); | 76 | &transmit_shutdown_ack, client); |
79 | GNUNET_SERVER_client_persist_ (client); | 77 | GNUNET_SERVER_client_persist_ (client); |
80 | GNUNET_SCHEDULER_shutdown (sched); | 78 | GNUNET_SCHEDULER_shutdown (); |
81 | } | 79 | } |
82 | 80 | ||
83 | 81 | ||
84 | static void | 82 | static void |
85 | run (void *cls, | 83 | run (void *cls, |
86 | struct GNUNET_SCHEDULER_Handle *s, | ||
87 | struct GNUNET_SERVER_Handle *server, | 84 | struct GNUNET_SERVER_Handle *server, |
88 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 85 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
89 | { | 86 | { |
@@ -92,7 +89,6 @@ run (void *cls, | |||
92 | sizeof (struct GNUNET_MessageHeader)}, | 89 | sizeof (struct GNUNET_MessageHeader)}, |
93 | {NULL, NULL, 0, 0} | 90 | {NULL, NULL, 0, 0} |
94 | }; | 91 | }; |
95 | sched = s; | ||
96 | /* process client requests */ | 92 | /* process client requests */ |
97 | GNUNET_SERVER_ignore_shutdown (server, GNUNET_YES); | 93 | GNUNET_SERVER_ignore_shutdown (server, GNUNET_YES); |
98 | GNUNET_SERVER_add_handlers (server, handlers); | 94 | GNUNET_SERVER_add_handlers (server, handlers); |
diff --git a/src/arm/test_arm_api.c b/src/arm/test_arm_api.c index 6ec95f4a0..6952b2e59 100644 --- a/src/arm/test_arm_api.c +++ b/src/arm/test_arm_api.c | |||
@@ -38,8 +38,6 @@ | |||
38 | 38 | ||
39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) | 39 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 15) |
40 | 40 | ||
41 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
42 | |||
43 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 41 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
44 | 42 | ||
45 | static struct GNUNET_ARM_Handle *arm; | 43 | static struct GNUNET_ARM_Handle *arm; |
@@ -95,8 +93,7 @@ resolver_notify (void *cls, int success) | |||
95 | #endif | 93 | #endif |
96 | return; | 94 | return; |
97 | } | 95 | } |
98 | GNUNET_RESOLVER_ip_get (sched, | 96 | GNUNET_RESOLVER_ip_get (cfg, |
99 | cfg, | ||
100 | "localhost", AF_INET, TIMEOUT, &dns_notify, NULL); | 97 | "localhost", AF_INET, TIMEOUT, &dns_notify, NULL); |
101 | } | 98 | } |
102 | 99 | ||
@@ -118,14 +115,12 @@ arm_notify (void *cls, int success) | |||
118 | 115 | ||
119 | static void | 116 | static void |
120 | task (void *cls, | 117 | task (void *cls, |
121 | struct GNUNET_SCHEDULER_Handle *s, | ||
122 | char *const *args, | 118 | char *const *args, |
123 | const char *cfgfile, | 119 | const char *cfgfile, |
124 | const struct GNUNET_CONFIGURATION_Handle *c) | 120 | const struct GNUNET_CONFIGURATION_Handle *c) |
125 | { | 121 | { |
126 | cfg = c; | 122 | cfg = c; |
127 | sched = s; | 123 | arm = GNUNET_ARM_connect (cfg, NULL); |
128 | arm = GNUNET_ARM_connect (cfg, sched, NULL); | ||
129 | #if START_ARM | 124 | #if START_ARM |
130 | GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL); | 125 | GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL); |
131 | #else | 126 | #else |
diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index dd32f6a5d..8e5ac9bc1 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c | |||
@@ -35,7 +35,6 @@ | |||
35 | #define SERVICE_TEST_TIMEOUT GNUNET_TIME_UNIT_FOREVER_REL | 35 | #define SERVICE_TEST_TIMEOUT GNUNET_TIME_UNIT_FOREVER_REL |
36 | #define FIVE_MILLISECONDS GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 5) | 36 | #define FIVE_MILLISECONDS GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 5) |
37 | 37 | ||
38 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
39 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 38 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
40 | static struct GNUNET_ARM_Handle *arm; | 39 | static struct GNUNET_ARM_Handle *arm; |
41 | static int ok = 1; | 40 | static int ok = 1; |
@@ -56,10 +55,6 @@ static char *killLogFileName; | |||
56 | struct ShutdownContext | 55 | struct ShutdownContext |
57 | { | 56 | { |
58 | /** | 57 | /** |
59 | * Scheduler to be used to call continuation | ||
60 | */ | ||
61 | struct GNUNET_SCHEDULER_Handle *sched; | ||
62 | /** | ||
63 | * Connection to the service that is being shutdown. | 58 | * Connection to the service that is being shutdown. |
64 | */ | 59 | */ |
65 | struct GNUNET_CLIENT_Connection *sock; | 60 | struct GNUNET_CLIENT_Connection *sock; |
@@ -114,7 +109,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
114 | "Service handle shutdown before ACK!\n"); | 109 | "Service handle shutdown before ACK!\n"); |
115 | if (shutdown_ctx->cont != NULL) | 110 | if (shutdown_ctx->cont != NULL) |
116 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); | 111 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); |
117 | GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->cancel_task); | 112 | GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task); |
118 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); | 113 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); |
119 | GNUNET_free(shutdown_ctx); | 114 | GNUNET_free(shutdown_ctx); |
120 | } | 115 | } |
@@ -127,7 +122,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
127 | if (shutdown_ctx->cont != NULL) | 122 | if (shutdown_ctx->cont != NULL) |
128 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO); | 123 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO); |
129 | 124 | ||
130 | GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->cancel_task); | 125 | GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task); |
131 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); | 126 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); |
132 | GNUNET_free(shutdown_ctx); | 127 | GNUNET_free(shutdown_ctx); |
133 | } | 128 | } |
@@ -153,7 +148,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
153 | if (shutdown_ctx->cont != NULL) | 148 | if (shutdown_ctx->cont != NULL) |
154 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES); | 149 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES); |
155 | 150 | ||
156 | GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->cancel_task); | 151 | GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task); |
157 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); | 152 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); |
158 | GNUNET_free(shutdown_ctx); | 153 | GNUNET_free(shutdown_ctx); |
159 | break; | 154 | break; |
@@ -206,8 +201,7 @@ write_shutdown (void *cls, size_t size, void *buf) | |||
206 | GNUNET_CLIENT_receive (shutdown_ctx->sock, | 201 | GNUNET_CLIENT_receive (shutdown_ctx->sock, |
207 | &service_shutdown_handler, shutdown_ctx, | 202 | &service_shutdown_handler, shutdown_ctx, |
208 | GNUNET_TIME_UNIT_FOREVER_REL); | 203 | GNUNET_TIME_UNIT_FOREVER_REL); |
209 | shutdown_ctx->cancel_task = GNUNET_SCHEDULER_add_delayed (shutdown_ctx->sched, | 204 | shutdown_ctx->cancel_task = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout), |
210 | GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout), | ||
211 | &service_shutdown_cancel, | 205 | &service_shutdown_cancel, |
212 | shutdown_ctx); | 206 | shutdown_ctx); |
213 | msg = (struct GNUNET_MessageHeader *) buf; | 207 | msg = (struct GNUNET_MessageHeader *) buf; |
@@ -224,7 +218,6 @@ write_shutdown (void *cls, size_t size, void *buf) | |||
224 | * be used by the caller after this call | 218 | * be used by the caller after this call |
225 | * (calling this function frees "sock" after a while). | 219 | * (calling this function frees "sock" after a while). |
226 | * | 220 | * |
227 | * @param sched the scheduler to use for calling shutdown continuation | ||
228 | * @param sock the socket connected to the service | 221 | * @param sock the socket connected to the service |
229 | * @param timeout how long to wait before giving up on transmission | 222 | * @param timeout how long to wait before giving up on transmission |
230 | * @param cont continuation to call once the service is really down | 223 | * @param cont continuation to call once the service is really down |
@@ -232,15 +225,13 @@ write_shutdown (void *cls, size_t size, void *buf) | |||
232 | * | 225 | * |
233 | */ | 226 | */ |
234 | static void | 227 | static void |
235 | arm_service_shutdown (struct GNUNET_SCHEDULER_Handle *sched, | 228 | arm_service_shutdown (struct GNUNET_CLIENT_Connection *sock, |
236 | struct GNUNET_CLIENT_Connection *sock, | ||
237 | struct GNUNET_TIME_Relative timeout, | 229 | struct GNUNET_TIME_Relative timeout, |
238 | GNUNET_CLIENT_ShutdownTask cont, | 230 | GNUNET_CLIENT_ShutdownTask cont, |
239 | void *cont_cls) | 231 | void *cont_cls) |
240 | { | 232 | { |
241 | struct ShutdownContext *shutdown_ctx; | 233 | struct ShutdownContext *shutdown_ctx; |
242 | shutdown_ctx = GNUNET_malloc(sizeof(struct ShutdownContext)); | 234 | shutdown_ctx = GNUNET_malloc(sizeof(struct ShutdownContext)); |
243 | shutdown_ctx->sched = sched; | ||
244 | shutdown_ctx->cont = cont; | 235 | shutdown_ctx->cont = cont; |
245 | shutdown_ctx->cont_cls = cont_cls; | 236 | shutdown_ctx->cont_cls = cont_cls; |
246 | shutdown_ctx->sock = sock; | 237 | shutdown_ctx->sock = sock; |
@@ -274,7 +265,7 @@ do_nothing_notify (void *cls, int success) | |||
274 | { | 265 | { |
275 | GNUNET_assert (success == GNUNET_YES); | 266 | GNUNET_assert (success == GNUNET_YES); |
276 | ok = 1; | 267 | ok = 1; |
277 | GNUNET_SCHEDULER_add_delayed (sched, GNUNET_TIME_UNIT_SECONDS, | 268 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, |
278 | &kill_task, NULL); | 269 | &kill_task, NULL); |
279 | } | 270 | } |
280 | 271 | ||
@@ -322,7 +313,7 @@ do_nothing_restarted_notify_task (void *cls, | |||
322 | trialCount); | 313 | trialCount); |
323 | } | 314 | } |
324 | #endif | 315 | #endif |
325 | GNUNET_SCHEDULER_add_now (sched, &kill_task, &a); | 316 | GNUNET_SCHEDULER_add_now (&kill_task, &a); |
326 | } | 317 | } |
327 | 318 | ||
328 | 319 | ||
@@ -330,7 +321,7 @@ static void | |||
330 | do_test (void *cbData, | 321 | do_test (void *cbData, |
331 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 322 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
332 | { | 323 | { |
333 | GNUNET_CLIENT_service_test(sched, "do-nothing", | 324 | GNUNET_CLIENT_service_test("do-nothing", |
334 | cfg, TIMEOUT, | 325 | cfg, TIMEOUT, |
335 | &do_nothing_restarted_notify_task, NULL); | 326 | &do_nothing_restarted_notify_task, NULL); |
336 | } | 327 | } |
@@ -341,8 +332,7 @@ shutdown_cont (void *cls, int reason) | |||
341 | { | 332 | { |
342 | trialCount++; | 333 | trialCount++; |
343 | startedWaitingAt = GNUNET_TIME_absolute_get(); | 334 | startedWaitingAt = GNUNET_TIME_absolute_get(); |
344 | GNUNET_SCHEDULER_add_delayed (sched, | 335 | GNUNET_SCHEDULER_add_delayed (waitedFor, |
345 | waitedFor, | ||
346 | &do_test, | 336 | &do_test, |
347 | NULL); | 337 | NULL); |
348 | } | 338 | } |
@@ -369,7 +359,7 @@ kill_task (void *cbData, | |||
369 | waitedFor.rel_value = 0; | 359 | waitedFor.rel_value = 0; |
370 | } | 360 | } |
371 | /* Connect to the doNothing task */ | 361 | /* Connect to the doNothing task */ |
372 | doNothingConnection = GNUNET_CLIENT_connect (sched, "do-nothing", cfg); | 362 | doNothingConnection = GNUNET_CLIENT_connect ("do-nothing", cfg); |
373 | #if LOG_BACKOFF | 363 | #if LOG_BACKOFF |
374 | if (NULL == doNothingConnection) | 364 | if (NULL == doNothingConnection) |
375 | fprintf(killLogFilePtr, | 365 | fprintf(killLogFilePtr, |
@@ -385,8 +375,7 @@ kill_task (void *cbData, | |||
385 | } | 375 | } |
386 | 376 | ||
387 | /* Use the created connection to kill the doNothingTask */ | 377 | /* Use the created connection to kill the doNothingTask */ |
388 | arm_service_shutdown(sched, | 378 | arm_service_shutdown(doNothingConnection, |
389 | doNothingConnection, | ||
390 | TIMEOUT, | 379 | TIMEOUT, |
391 | &shutdown_cont, NULL); | 380 | &shutdown_cont, NULL); |
392 | } | 381 | } |
@@ -394,15 +383,13 @@ kill_task (void *cbData, | |||
394 | 383 | ||
395 | static void | 384 | static void |
396 | task (void *cls, | 385 | task (void *cls, |
397 | struct GNUNET_SCHEDULER_Handle *s, | ||
398 | char *const *args, | 386 | char *const *args, |
399 | const char *cfgfile, | 387 | const char *cfgfile, |
400 | const struct GNUNET_CONFIGURATION_Handle *c) | 388 | const struct GNUNET_CONFIGURATION_Handle *c) |
401 | { | 389 | { |
402 | cfg = c; | 390 | cfg = c; |
403 | sched = s; | ||
404 | 391 | ||
405 | arm = GNUNET_ARM_connect (cfg, sched, NULL); | 392 | arm = GNUNET_ARM_connect (cfg,NULL); |
406 | #if START_ARM | 393 | #if START_ARM |
407 | GNUNET_ARM_start_service (arm, "arm", GNUNET_TIME_UNIT_ZERO, &arm_notify, NULL); | 394 | GNUNET_ARM_start_service (arm, "arm", GNUNET_TIME_UNIT_ZERO, &arm_notify, NULL); |
408 | #else | 395 | #else |
diff --git a/src/arm/test_gnunet_service_manager.c b/src/arm/test_gnunet_service_manager.c index 26ea774d6..e4aecb8c4 100644 --- a/src/arm/test_gnunet_service_manager.c +++ b/src/arm/test_gnunet_service_manager.c | |||
@@ -43,7 +43,6 @@ | |||
43 | 43 | ||
44 | static int ret = 1; | 44 | static int ret = 1; |
45 | 45 | ||
46 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
47 | 46 | ||
48 | static const struct GNUNET_CONFIGURATION_Handle *cfg; | 47 | static const struct GNUNET_CONFIGURATION_Handle *cfg; |
49 | 48 | ||
@@ -108,8 +107,7 @@ arm_notify (void *cls, int success) | |||
108 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 107 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
109 | "Trying to resolve our own hostname!\n"); | 108 | "Trying to resolve our own hostname!\n"); |
110 | /* connect to the resolver service */ | 109 | /* connect to the resolver service */ |
111 | if (NULL == GNUNET_RESOLVER_hostname_resolve (sched, | 110 | if (NULL == GNUNET_RESOLVER_hostname_resolve (cfg, AF_UNSPEC, |
112 | cfg, AF_UNSPEC, | ||
113 | TIMEOUT, | 111 | TIMEOUT, |
114 | &hostNameResolveCB, | 112 | &hostNameResolveCB, |
115 | NULL)) | 113 | NULL)) |
@@ -125,16 +123,14 @@ arm_notify (void *cls, int success) | |||
125 | 123 | ||
126 | 124 | ||
127 | static void | 125 | static void |
128 | run(void *cls, | 126 | run(void *cls, |
129 | struct GNUNET_SCHEDULER_Handle *s, | ||
130 | char * const *args, | 127 | char * const *args, |
131 | const char *cfgfile, | 128 | const char *cfgfile, |
132 | const struct GNUNET_CONFIGURATION_Handle *c) | 129 | const struct GNUNET_CONFIGURATION_Handle *c) |
133 | { | 130 | { |
134 | cfg = c; | 131 | cfg = c; |
135 | sched = s; | ||
136 | #if START_ARM | 132 | #if START_ARM |
137 | arm = GNUNET_ARM_connect (cfg, sched, NULL); | 133 | arm = GNUNET_ARM_connect (cfg, NULL); |
138 | GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL); | 134 | GNUNET_ARM_start_service (arm, "arm", START_TIMEOUT, &arm_notify, NULL); |
139 | #else | 135 | #else |
140 | arm_notify (NULL, GNUNET_YES); | 136 | arm_notify (NULL, GNUNET_YES); |