diff options
author | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2011-08-15 21:54:06 +0000 |
commit | 5746309cb4be2073d550ad7a6885e918631dbc38 (patch) | |
tree | 89455bc4aadf977816b38df13f990372cd81d71a /src/arm | |
parent | 6fd3e715cae09fa6e657c96f1c6f9711ee51f42f (diff) | |
download | gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.tar.gz gnunet-5746309cb4be2073d550ad7a6885e918631dbc38.zip |
indentation
Diffstat (limited to 'src/arm')
-rw-r--r-- | src/arm/arm_api.c | 63 | ||||
-rw-r--r-- | src/arm/gnunet-arm.c | 42 | ||||
-rw-r--r-- | src/arm/gnunet-service-arm.c | 153 | ||||
-rw-r--r-- | src/arm/gnunet-service-arm_interceptor.c | 155 | ||||
-rw-r--r-- | src/arm/mockup-service.c | 15 | ||||
-rw-r--r-- | src/arm/test_arm_api.c | 10 | ||||
-rw-r--r-- | src/arm/test_exponential_backoff.c | 49 | ||||
-rw-r--r-- | src/arm/test_gnunet_service_manager.c | 18 |
8 files changed, 233 insertions, 272 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index 0db9e5c3e..cc75e46da 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c | |||
@@ -141,8 +141,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
141 | "Received confirmation for service shutdown.\n"); | 141 | "Received confirmation for service shutdown.\n"); |
142 | #endif | 142 | #endif |
143 | shutdown_ctx->confirmed = GNUNET_YES; | 143 | shutdown_ctx->confirmed = GNUNET_YES; |
144 | GNUNET_CLIENT_receive (shutdown_ctx->sock, | 144 | GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, |
145 | &service_shutdown_handler, | ||
146 | shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); | 145 | shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); |
147 | break; | 146 | break; |
148 | default: /* Fall through */ | 147 | default: /* Fall through */ |
@@ -206,9 +205,8 @@ write_shutdown (void *cls, size_t size, void *buf) | |||
206 | return 0; /* client disconnected */ | 205 | return 0; /* client disconnected */ |
207 | } | 206 | } |
208 | 207 | ||
209 | GNUNET_CLIENT_receive (shutdown_ctx->sock, | 208 | GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, |
210 | &service_shutdown_handler, shutdown_ctx, | 209 | shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); |
211 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
212 | shutdown_ctx->cancel_task = | 210 | shutdown_ctx->cancel_task = |
213 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 211 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
214 | (shutdown_ctx->timeout), | 212 | (shutdown_ctx->timeout), |
@@ -246,11 +244,9 @@ arm_service_shutdown (struct GNUNET_CLIENT_Connection *sock, | |||
246 | shutdown_ctx->sock = sock; | 244 | shutdown_ctx->sock = sock; |
247 | shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 245 | shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
248 | GNUNET_CLIENT_notify_transmit_ready (sock, | 246 | GNUNET_CLIENT_notify_transmit_ready (sock, |
249 | sizeof (struct | 247 | sizeof (struct GNUNET_MessageHeader), |
250 | GNUNET_MessageHeader), | 248 | timeout, GNUNET_YES, &write_shutdown, |
251 | timeout, | 249 | shutdown_ctx); |
252 | GNUNET_YES, | ||
253 | &write_shutdown, shutdown_ctx); | ||
254 | } | 250 | } |
255 | 251 | ||
256 | 252 | ||
@@ -378,16 +374,16 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
378 | "gnunet-service-arm"); | 374 | "gnunet-service-arm"); |
379 | #endif | 375 | #endif |
380 | if (GNUNET_OK != | 376 | if (GNUNET_OK != |
381 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, | 377 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "PREFIX", |
382 | "arm", "PREFIX", &loprefix)) | 378 | &loprefix)) |
383 | loprefix = GNUNET_strdup (""); | 379 | loprefix = GNUNET_strdup (""); |
384 | if (GNUNET_OK != | 380 | if (GNUNET_OK != |
385 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, | 381 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "OPTIONS", |
386 | "arm", "OPTIONS", &lopostfix)) | 382 | &lopostfix)) |
387 | lopostfix = GNUNET_strdup (""); | 383 | lopostfix = GNUNET_strdup (""); |
388 | if (GNUNET_OK != | 384 | if (GNUNET_OK != |
389 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, | 385 | GNUNET_CONFIGURATION_get_value_string (pos->h->cfg, "arm", "BINARY", |
390 | "arm", "BINARY", &binary)) | 386 | &binary)) |
391 | { | 387 | { |
392 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 388 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
393 | _ | 389 | _ |
@@ -401,8 +397,8 @@ arm_service_report (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
401 | return; | 397 | return; |
402 | } | 398 | } |
403 | if (GNUNET_OK != | 399 | if (GNUNET_OK != |
404 | GNUNET_CONFIGURATION_get_value_filename (pos->h->cfg, | 400 | GNUNET_CONFIGURATION_get_value_filename (pos->h->cfg, "arm", "CONFIG", |
405 | "arm", "CONFIG", &config)) | 401 | &config)) |
406 | { | 402 | { |
407 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 403 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
408 | _ | 404 | _ |
@@ -519,10 +515,9 @@ handle_response (void *cls, const struct GNUNET_MessageHeader *msg) | |||
519 | * @param type type of the request | 515 | * @param type type of the request |
520 | */ | 516 | */ |
521 | static void | 517 | static void |
522 | change_service (struct GNUNET_ARM_Handle *h, | 518 | change_service (struct GNUNET_ARM_Handle *h, const char *service_name, |
523 | const char *service_name, | 519 | struct GNUNET_TIME_Relative timeout, GNUNET_ARM_Callback cb, |
524 | struct GNUNET_TIME_Relative timeout, | 520 | void *cb_cls, uint16_t type) |
525 | GNUNET_ARM_Callback cb, void *cb_cls, uint16_t type) | ||
526 | { | 521 | { |
527 | struct RequestContext *sctx; | 522 | struct RequestContext *sctx; |
528 | size_t slen; | 523 | size_t slen; |
@@ -539,9 +534,10 @@ change_service (struct GNUNET_ARM_Handle *h, | |||
539 | } | 534 | } |
540 | #if DEBUG_ARM | 535 | #if DEBUG_ARM |
541 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 536 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
542 | (type == GNUNET_MESSAGE_TYPE_ARM_START) | 537 | (type == |
543 | ? _("Requesting start of service `%s'.\n") | 538 | GNUNET_MESSAGE_TYPE_ARM_START) ? |
544 | : _("Requesting termination of service `%s'.\n"), service_name); | 539 | _("Requesting start of service `%s'.\n") : |
540 | _("Requesting termination of service `%s'.\n"), service_name); | ||
545 | #endif | 541 | #endif |
546 | sctx = GNUNET_malloc (sizeof (struct RequestContext) + slen); | 542 | sctx = GNUNET_malloc (sizeof (struct RequestContext) + slen); |
547 | sctx->h = h; | 543 | sctx->h = h; |
@@ -555,15 +551,14 @@ change_service (struct GNUNET_ARM_Handle *h, | |||
555 | msg->type = htons (sctx->type); | 551 | msg->type = htons (sctx->type); |
556 | memcpy (&msg[1], service_name, slen); | 552 | memcpy (&msg[1], service_name, slen); |
557 | if (GNUNET_OK != | 553 | if (GNUNET_OK != |
558 | GNUNET_CLIENT_transmit_and_get_response (sctx->h->client, | 554 | GNUNET_CLIENT_transmit_and_get_response (sctx->h->client, msg, |
559 | msg, | ||
560 | GNUNET_TIME_absolute_get_remaining | 555 | GNUNET_TIME_absolute_get_remaining |
561 | (sctx->timeout), GNUNET_YES, | 556 | (sctx->timeout), GNUNET_YES, |
562 | &handle_response, sctx)) | 557 | &handle_response, sctx)) |
563 | { | 558 | { |
564 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 559 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
565 | (type == GNUNET_MESSAGE_TYPE_ARM_START) | 560 | (type == |
566 | ? | 561 | GNUNET_MESSAGE_TYPE_ARM_START) ? |
567 | _ | 562 | _ |
568 | ("Error while trying to transmit request to start `%s' to ARM\n") | 563 | ("Error while trying to transmit request to start `%s' to ARM\n") |
569 | : | 564 | : |
@@ -590,8 +585,7 @@ change_service (struct GNUNET_ARM_Handle *h, | |||
590 | * @param cb_cls closure for callback | 585 | * @param cb_cls closure for callback |
591 | */ | 586 | */ |
592 | void | 587 | void |
593 | GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, | 588 | GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, const char *service_name, |
594 | const char *service_name, | ||
595 | struct GNUNET_TIME_Relative timeout, | 589 | struct GNUNET_TIME_Relative timeout, |
596 | GNUNET_ARM_Callback cb, void *cb_cls) | 590 | GNUNET_ARM_Callback cb, void *cb_cls) |
597 | { | 591 | { |
@@ -616,8 +610,8 @@ GNUNET_ARM_start_service (struct GNUNET_ARM_Handle *h, | |||
616 | sctx->cls = cb_cls; | 610 | sctx->cls = cb_cls; |
617 | sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 611 | sctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
618 | memcpy (&sctx[1], service_name, slen); | 612 | memcpy (&sctx[1], service_name, slen); |
619 | GNUNET_CLIENT_service_test ("arm", | 613 | GNUNET_CLIENT_service_test ("arm", h->cfg, timeout, &arm_service_report, |
620 | h->cfg, timeout, &arm_service_report, sctx); | 614 | sctx); |
621 | return; | 615 | return; |
622 | } | 616 | } |
623 | if (h->client == NULL) | 617 | if (h->client == NULL) |
@@ -670,8 +664,7 @@ arm_shutdown_callback (void *cls, int reason) | |||
670 | * @param cb_cls closure for callback | 664 | * @param cb_cls closure for callback |
671 | */ | 665 | */ |
672 | void | 666 | void |
673 | GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, | 667 | GNUNET_ARM_stop_service (struct GNUNET_ARM_Handle *h, const char *service_name, |
674 | const char *service_name, | ||
675 | struct GNUNET_TIME_Relative timeout, | 668 | struct GNUNET_TIME_Relative timeout, |
676 | GNUNET_ARM_Callback cb, void *cb_cls) | 669 | GNUNET_ARM_Callback cb, void *cb_cls) |
677 | { | 670 | { |
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index f7ff536be..cf5e1592a 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c | |||
@@ -177,14 +177,14 @@ confirm_cb (void *cls, int success) | |||
177 | break; | 177 | break; |
178 | case GNUNET_SYSERR: | 178 | case GNUNET_SYSERR: |
179 | if (quiet != GNUNET_YES) | 179 | if (quiet != GNUNET_YES) |
180 | fprintf (stdout, | 180 | fprintf (stdout, _("Some error communicating with service `%s'.\n"), |
181 | _("Some error communicating with service `%s'.\n"), service); | 181 | service); |
182 | ret = 1; | 182 | ret = 1; |
183 | break; | 183 | break; |
184 | } | 184 | } |
185 | 185 | ||
186 | GNUNET_SCHEDULER_add_continuation (&cps_loop, | 186 | GNUNET_SCHEDULER_add_continuation (&cps_loop, NULL, |
187 | NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 187 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
188 | } | 188 | } |
189 | 189 | ||
190 | 190 | ||
@@ -210,8 +210,8 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
210 | if (quiet != GNUNET_YES) | 210 | if (quiet != GNUNET_YES) |
211 | fprintf (stdout, _("Service `%s' is not running.\n"), service); | 211 | fprintf (stdout, _("Service `%s' is not running.\n"), service); |
212 | } | 212 | } |
213 | GNUNET_SCHEDULER_add_continuation (&cps_loop, | 213 | GNUNET_SCHEDULER_add_continuation (&cps_loop, NULL, |
214 | NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 214 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | ||
@@ -224,9 +224,8 @@ confirm_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
224 | * @param c configuration | 224 | * @param c configuration |
225 | */ | 225 | */ |
226 | static void | 226 | static void |
227 | run (void *cls, | 227 | run (void *cls, char *const *args, const char *cfgfile, |
228 | char *const *args, | 228 | const struct GNUNET_CONFIGURATION_Handle *c) |
229 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) | ||
230 | { | 229 | { |
231 | cfg = c; | 230 | cfg = c; |
232 | config_file = cfgfile; | 231 | config_file = cfgfile; |
@@ -247,8 +246,8 @@ run (void *cls, | |||
247 | ret = 1; | 246 | ret = 1; |
248 | return; | 247 | return; |
249 | } | 248 | } |
250 | GNUNET_SCHEDULER_add_continuation (&cps_loop, | 249 | GNUNET_SCHEDULER_add_continuation (&cps_loop, NULL, |
251 | NULL, GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 250 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
252 | } | 251 | } |
253 | 252 | ||
254 | /** | 253 | /** |
@@ -306,8 +305,9 @@ cps_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
306 | { | 305 | { |
307 | GNUNET_ARM_stop_service (h, "arm", | 306 | GNUNET_ARM_stop_service (h, "arm", |
308 | (0 == | 307 | (0 == |
309 | timeout.rel_value) ? STOP_TIMEOUT_ARM : | 308 | timeout. |
310 | timeout, &confirm_cb, "arm"); | 309 | rel_value) ? STOP_TIMEOUT_ARM : timeout, |
310 | &confirm_cb, "arm"); | ||
311 | return; | 311 | return; |
312 | } | 312 | } |
313 | break; | 313 | break; |
@@ -336,8 +336,9 @@ cps_loop (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
336 | { | 336 | { |
337 | GNUNET_CLIENT_service_test (test, cfg, | 337 | GNUNET_CLIENT_service_test (test, cfg, |
338 | (0 == | 338 | (0 == |
339 | timeout.rel_value) ? TEST_TIMEOUT : | 339 | timeout. |
340 | timeout, &confirm_task, test); | 340 | rel_value) ? TEST_TIMEOUT : timeout, |
341 | &confirm_task, test); | ||
341 | return; | 342 | return; |
342 | } | 343 | } |
343 | break; | 344 | break; |
@@ -412,12 +413,11 @@ main (int argc, char *const *argv) | |||
412 | if (temp_timeout_ms > 0) | 413 | if (temp_timeout_ms > 0) |
413 | timeout.rel_value = temp_timeout_ms; | 414 | timeout.rel_value = temp_timeout_ms; |
414 | 415 | ||
415 | if (GNUNET_OK == GNUNET_PROGRAM_run (argc, | 416 | if (GNUNET_OK == |
416 | argv, | 417 | GNUNET_PROGRAM_run (argc, argv, "gnunet-arm", |
417 | "gnunet-arm", | 418 | gettext_noop |
418 | gettext_noop | 419 | ("Control services and the Automated Restart Manager (ARM)"), |
419 | ("Control services and the Automated Restart Manager (ARM)"), | 420 | options, &run, NULL)) |
420 | options, &run, NULL)) | ||
421 | { | 421 | { |
422 | return ret; | 422 | return ret; |
423 | } | 423 | } |
diff --git a/src/arm/gnunet-service-arm.c b/src/arm/gnunet-service-arm.c index e4a8e7c6c..ddccb7fa0 100644 --- a/src/arm/gnunet-service-arm.c +++ b/src/arm/gnunet-service-arm.c | |||
@@ -198,8 +198,8 @@ config_change_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
198 | while (pos != NULL) | 198 | while (pos != NULL) |
199 | { | 199 | { |
200 | /* FIXME: this test for config change may be a bit too coarse grained */ | 200 | /* FIXME: this test for config change may be a bit too coarse grained */ |
201 | if ((0 == STAT (pos->config, &sbuf)) && | 201 | if ((0 == STAT (pos->config, &sbuf)) && (pos->mtime < sbuf.st_mtime) && |
202 | (pos->mtime < sbuf.st_mtime) && (pos->proc != NULL)) | 202 | (pos->proc != NULL)) |
203 | { | 203 | { |
204 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 204 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
205 | _ | 205 | _ |
@@ -235,8 +235,8 @@ write_result (void *cls, size_t size, void *buf) | |||
235 | return 0; /* error, not much we can do */ | 235 | return 0; /* error, not much we can do */ |
236 | } | 236 | } |
237 | #if DEBUG_ARM | 237 | #if DEBUG_ARM |
238 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 238 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Sending status response %u to client\n", |
239 | "Sending status response %u to client\n", (unsigned int) *res); | 239 | (unsigned int) *res); |
240 | #endif | 240 | #endif |
241 | GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); | 241 | GNUNET_assert (size >= sizeof (struct GNUNET_MessageHeader)); |
242 | msg = buf; | 242 | msg = buf; |
@@ -257,8 +257,8 @@ write_result (void *cls, size_t size, void *buf) | |||
257 | * @return NULL if it was not found | 257 | * @return NULL if it was not found |
258 | */ | 258 | */ |
259 | static void | 259 | static void |
260 | signal_result (struct GNUNET_SERVER_Client *client, | 260 | signal_result (struct GNUNET_SERVER_Client *client, const char *name, |
261 | const char *name, uint16_t result) | 261 | uint16_t result) |
262 | { | 262 | { |
263 | uint16_t *res; | 263 | uint16_t *res; |
264 | 264 | ||
@@ -270,8 +270,8 @@ signal_result (struct GNUNET_SERVER_Client *client, | |||
270 | } | 270 | } |
271 | #if DEBUG_ARM | 271 | #if DEBUG_ARM |
272 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 272 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
273 | "Telling client that service `%s' is now %s\n", | 273 | "Telling client that service `%s' is now %s\n", name, |
274 | name, result == GNUNET_MESSAGE_TYPE_ARM_IS_DOWN ? "down" : "up"); | 274 | result == GNUNET_MESSAGE_TYPE_ARM_IS_DOWN ? "down" : "up"); |
275 | #endif | 275 | #endif |
276 | res = GNUNET_malloc (sizeof (uint16_t)); | 276 | res = GNUNET_malloc (sizeof (uint16_t)); |
277 | *res = result; | 277 | *res = result; |
@@ -344,12 +344,12 @@ start_process (struct ServiceList *sl, const int *lsocks) | |||
344 | 344 | ||
345 | /* start service */ | 345 | /* start service */ |
346 | if (GNUNET_OK != | 346 | if (GNUNET_OK != |
347 | GNUNET_CONFIGURATION_get_value_string (cfg, | 347 | GNUNET_CONFIGURATION_get_value_string (cfg, sl->name, "PREFIX", |
348 | sl->name, "PREFIX", &loprefix)) | 348 | &loprefix)) |
349 | loprefix = GNUNET_strdup (prefix_command); | 349 | loprefix = GNUNET_strdup (prefix_command); |
350 | if (GNUNET_OK != | 350 | if (GNUNET_OK != |
351 | GNUNET_CONFIGURATION_get_value_string (cfg, | 351 | GNUNET_CONFIGURATION_get_value_string (cfg, sl->name, "OPTIONS", |
352 | sl->name, "OPTIONS", &options)) | 352 | &options)) |
353 | { | 353 | { |
354 | options = GNUNET_strdup (final_option); | 354 | options = GNUNET_strdup (final_option); |
355 | if (NULL == strstr (options, "%")) | 355 | if (NULL == strstr (options, "%")) |
@@ -376,8 +376,8 @@ start_process (struct ServiceList *sl, const int *lsocks) | |||
376 | next = optend + 1; | 376 | next = optend + 1; |
377 | *optend = '\0'; | 377 | *optend = '\0'; |
378 | if (GNUNET_OK != | 378 | if (GNUNET_OK != |
379 | GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", | 379 | GNUNET_CONFIGURATION_get_value_string (cfg, "PATHS", optpos + 1, |
380 | optpos + 1, &val)) | 380 | &val)) |
381 | val = GNUNET_strdup (""); | 381 | val = GNUNET_strdup (""); |
382 | *optpos = '\0'; | 382 | *optpos = '\0'; |
383 | GNUNET_asprintf (&optpos, "%s%s%c%s", options, val, b, next); | 383 | GNUNET_asprintf (&optpos, "%s%s%c%s", options, val, b, next); |
@@ -395,18 +395,16 @@ start_process (struct ServiceList *sl, const int *lsocks) | |||
395 | sl->name, sl->binary, sl->config); | 395 | sl->name, sl->binary, sl->config); |
396 | #endif | 396 | #endif |
397 | if (GNUNET_YES == use_debug) | 397 | if (GNUNET_YES == use_debug) |
398 | sl->proc = do_start_process (lsocks, | 398 | sl->proc = |
399 | loprefix, | 399 | do_start_process (lsocks, loprefix, sl->binary, "-c", sl->config, "-L", |
400 | sl->binary, | 400 | "DEBUG", options, NULL); |
401 | "-c", sl->config, | ||
402 | "-L", "DEBUG", options, NULL); | ||
403 | else | 401 | else |
404 | sl->proc = do_start_process (lsocks, | 402 | sl->proc = |
405 | loprefix, | 403 | do_start_process (lsocks, loprefix, sl->binary, "-c", sl->config, |
406 | sl->binary, "-c", sl->config, options, NULL); | 404 | options, NULL); |
407 | if (sl->proc == NULL) | 405 | if (sl->proc == NULL) |
408 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 406 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, _("Failed to start service `%s'\n"), |
409 | _("Failed to start service `%s'\n"), sl->name); | 407 | sl->name); |
410 | else | 408 | else |
411 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting service `%s'\n"), sl->name); | 409 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Starting service `%s'\n"), sl->name); |
412 | GNUNET_free (loprefix); | 410 | GNUNET_free (loprefix); |
@@ -423,8 +421,8 @@ start_process (struct ServiceList *sl, const int *lsocks) | |||
423 | * @return GNUNET_OK on success, GNUNET_SYSERR on error | 421 | * @return GNUNET_OK on success, GNUNET_SYSERR on error |
424 | */ | 422 | */ |
425 | int | 423 | int |
426 | start_service (struct GNUNET_SERVER_Client *client, | 424 | start_service (struct GNUNET_SERVER_Client *client, const char *servicename, |
427 | const char *servicename, const int *lsocks) | 425 | const int *lsocks) |
428 | { | 426 | { |
429 | struct ServiceList *sl; | 427 | struct ServiceList *sl; |
430 | char *binary; | 428 | char *binary; |
@@ -442,14 +440,14 @@ start_service (struct GNUNET_SERVER_Client *client, | |||
442 | sl = find_service (servicename); | 440 | sl = find_service (servicename); |
443 | if (sl != NULL) | 441 | if (sl != NULL) |
444 | { | 442 | { |
445 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 443 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, _("Service `%s' already running.\n"), |
446 | _("Service `%s' already running.\n"), servicename); | 444 | servicename); |
447 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_UP); | 445 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_UP); |
448 | return GNUNET_SYSERR; | 446 | return GNUNET_SYSERR; |
449 | } | 447 | } |
450 | if (GNUNET_OK != | 448 | if (GNUNET_OK != |
451 | GNUNET_CONFIGURATION_get_value_string (cfg, | 449 | GNUNET_CONFIGURATION_get_value_string (cfg, servicename, "BINARY", |
452 | servicename, "BINARY", &binary)) | 450 | &binary)) |
453 | { | 451 | { |
454 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 452 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
455 | _("Binary implementing service `%s' not known!\n"), | 453 | _("Binary implementing service `%s' not known!\n"), |
@@ -458,9 +456,7 @@ start_service (struct GNUNET_SERVER_Client *client, | |||
458 | return GNUNET_SYSERR; | 456 | return GNUNET_SYSERR; |
459 | } | 457 | } |
460 | if ((GNUNET_OK != | 458 | if ((GNUNET_OK != |
461 | GNUNET_CONFIGURATION_get_value_filename (cfg, | 459 | GNUNET_CONFIGURATION_get_value_filename (cfg, servicename, "CONFIG", |
462 | servicename, | ||
463 | "CONFIG", | ||
464 | &config)) || | 460 | &config)) || |
465 | (0 != STAT (config, &sbuf))) | 461 | (0 != STAT (config, &sbuf))) |
466 | { | 462 | { |
@@ -499,8 +495,8 @@ stop_service (struct GNUNET_SERVER_Client *client, const char *servicename) | |||
499 | { | 495 | { |
500 | struct ServiceList *pos; | 496 | struct ServiceList *pos; |
501 | 497 | ||
502 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 498 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Preparing to stop `%s'\n"), |
503 | _("Preparing to stop `%s'\n"), servicename); | 499 | servicename); |
504 | pos = find_service (servicename); | 500 | pos = find_service (servicename); |
505 | if (pos == NULL) | 501 | if (pos == NULL) |
506 | { | 502 | { |
@@ -515,8 +511,8 @@ stop_service (struct GNUNET_SERVER_Client *client, const char *servicename) | |||
515 | { | 511 | { |
516 | /* killing already in progress */ | 512 | /* killing already in progress */ |
517 | #if DEBUG_ARM | 513 | #if DEBUG_ARM |
518 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 514 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service `%s' is already down\n", |
519 | "Service `%s' is already down\n", servicename); | 515 | servicename); |
520 | #endif | 516 | #endif |
521 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); | 517 | signal_result (client, servicename, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); |
522 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 518 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
@@ -564,8 +560,7 @@ stop_service (struct GNUNET_SERVER_Client *client, const char *servicename) | |||
564 | * GNUNET_SYSERR to close it (signal serious error) | 560 | * GNUNET_SYSERR to close it (signal serious error) |
565 | */ | 561 | */ |
566 | static void | 562 | static void |
567 | handle_start (void *cls, | 563 | handle_start (void *cls, struct GNUNET_SERVER_Client *client, |
568 | struct GNUNET_SERVER_Client *client, | ||
569 | const struct GNUNET_MessageHeader *message) | 564 | const struct GNUNET_MessageHeader *message) |
570 | { | 565 | { |
571 | const char *servicename; | 566 | const char *servicename; |
@@ -595,8 +590,7 @@ handle_start (void *cls, | |||
595 | * GNUNET_SYSERR to close it (signal serious error) | 590 | * GNUNET_SYSERR to close it (signal serious error) |
596 | */ | 591 | */ |
597 | static void | 592 | static void |
598 | handle_stop (void *cls, | 593 | handle_stop (void *cls, struct GNUNET_SERVER_Client *client, |
599 | struct GNUNET_SERVER_Client *client, | ||
600 | const struct GNUNET_MessageHeader *message) | 594 | const struct GNUNET_MessageHeader *message) |
601 | { | 595 | { |
602 | const char *servicename; | 596 | const char *servicename; |
@@ -720,16 +714,16 @@ delayed_restart_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
720 | { | 714 | { |
721 | if (GNUNET_TIME_absolute_get_remaining (pos->restartAt).rel_value == 0) | 715 | if (GNUNET_TIME_absolute_get_remaining (pos->restartAt).rel_value == 0) |
722 | { | 716 | { |
723 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 717 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Restarting service `%s'.\n"), |
724 | _("Restarting service `%s'.\n"), pos->name); | 718 | pos->name); |
725 | start_process (pos, NULL); | 719 | start_process (pos, NULL); |
726 | } | 720 | } |
727 | else | 721 | else |
728 | { | 722 | { |
729 | lowestRestartDelay | 723 | lowestRestartDelay = |
730 | = GNUNET_TIME_relative_min (lowestRestartDelay, | 724 | GNUNET_TIME_relative_min (lowestRestartDelay, |
731 | GNUNET_TIME_absolute_get_remaining | 725 | GNUNET_TIME_absolute_get_remaining (pos-> |
732 | (pos->restartAt)); | 726 | restartAt)); |
733 | } | 727 | } |
734 | } | 728 | } |
735 | pos = pos->next; | 729 | pos = pos->next; |
@@ -737,13 +731,12 @@ delayed_restart_task (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
737 | if (lowestRestartDelay.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value) | 731 | if (lowestRestartDelay.rel_value != GNUNET_TIME_UNIT_FOREVER_REL.rel_value) |
738 | { | 732 | { |
739 | #if DEBUG_ARM | 733 | #if DEBUG_ARM |
740 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 734 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Will restart process in %llums\n", |
741 | "Will restart process in %llums\n", | ||
742 | (unsigned long long) lowestRestartDelay.rel_value); | 735 | (unsigned long long) lowestRestartDelay.rel_value); |
743 | #endif | 736 | #endif |
744 | child_restart_task | 737 | child_restart_task = |
745 | = GNUNET_SCHEDULER_add_delayed (lowestRestartDelay, | 738 | GNUNET_SCHEDULER_add_delayed (lowestRestartDelay, &delayed_restart_task, |
746 | &delayed_restart_task, NULL); | 739 | NULL); |
747 | } | 740 | } |
748 | } | 741 | } |
749 | 742 | ||
@@ -786,12 +779,10 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
786 | next = pos->next; | 779 | next = pos->next; |
787 | if (pos->proc == NULL) | 780 | if (pos->proc == NULL) |
788 | continue; | 781 | continue; |
789 | if ((GNUNET_SYSERR == (ret = GNUNET_OS_process_status (pos->proc, | 782 | if ((GNUNET_SYSERR == |
790 | &statusType, | 783 | (ret = GNUNET_OS_process_status (pos->proc, &statusType, &statusCode))) |
791 | &statusCode))) || | 784 | || ((ret == GNUNET_NO) || (statusType == GNUNET_OS_PROCESS_STOPPED) || |
792 | ((ret == GNUNET_NO) || | 785 | (statusType == GNUNET_OS_PROCESS_RUNNING))) |
793 | (statusType == GNUNET_OS_PROCESS_STOPPED) || | ||
794 | (statusType == GNUNET_OS_PROCESS_RUNNING))) | ||
795 | continue; | 786 | continue; |
796 | 787 | ||
797 | if (statusType == GNUNET_OS_PROCESS_EXITED) | 788 | if (statusType == GNUNET_OS_PROCESS_EXITED) |
@@ -813,10 +804,10 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
813 | pos->proc = NULL; | 804 | pos->proc = NULL; |
814 | if (NULL != pos->killing_client) | 805 | if (NULL != pos->killing_client) |
815 | { | 806 | { |
816 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 807 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Service `%s' stopped\n"), |
817 | _("Service `%s' stopped\n"), pos->name); | 808 | pos->name); |
818 | signal_result (pos->killing_client, | 809 | signal_result (pos->killing_client, pos->name, |
819 | pos->name, GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); | 810 | GNUNET_MESSAGE_TYPE_ARM_IS_DOWN); |
820 | GNUNET_SERVER_receive_done (pos->killing_client, GNUNET_OK); | 811 | GNUNET_SERVER_receive_done (pos->killing_client, GNUNET_OK); |
821 | GNUNET_SERVER_client_drop (pos->killing_client); | 812 | GNUNET_SERVER_client_drop (pos->killing_client); |
822 | free_service (pos); | 813 | free_service (pos); |
@@ -835,15 +826,15 @@ maint_child_death (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
835 | pos->backoff = GNUNET_TIME_relative_multiply (pos->backoff, 2); | 826 | pos->backoff = GNUNET_TIME_relative_multiply (pos->backoff, 2); |
836 | if (GNUNET_SCHEDULER_NO_TASK != child_restart_task) | 827 | if (GNUNET_SCHEDULER_NO_TASK != child_restart_task) |
837 | GNUNET_SCHEDULER_cancel (child_restart_task); | 828 | GNUNET_SCHEDULER_cancel (child_restart_task); |
838 | child_restart_task | 829 | child_restart_task = |
839 | = GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, | 830 | GNUNET_SCHEDULER_add_with_priority (GNUNET_SCHEDULER_PRIORITY_IDLE, |
840 | &delayed_restart_task, NULL); | 831 | &delayed_restart_task, NULL); |
841 | } | 832 | } |
842 | #if DEBUG_ARM | 833 | #if DEBUG_ARM |
843 | else | 834 | else |
844 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 835 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
845 | "Service `%s' terminated with status %s/%d\n", | 836 | "Service `%s' terminated with status %s/%d\n", pos->name, |
846 | pos->name, statstr, statcode); | 837 | statstr, statcode); |
847 | #endif | 838 | #endif |
848 | } | 839 | } |
849 | child_death_task = | 840 | child_death_task = |
@@ -893,8 +884,7 @@ transmit_shutdown_ack (void *cls, size_t size, void *buf) | |||
893 | * @param message the actual message | 884 | * @param message the actual message |
894 | */ | 885 | */ |
895 | static void | 886 | static void |
896 | handle_shutdown (void *cls, | 887 | handle_shutdown (void *cls, struct GNUNET_SERVER_Client *client, |
897 | struct GNUNET_SERVER_Client *client, | ||
898 | const struct GNUNET_MessageHeader *message) | 888 | const struct GNUNET_MessageHeader *message) |
899 | { | 889 | { |
900 | GNUNET_SERVER_client_keep (client); | 890 | GNUNET_SERVER_client_keep (client); |
@@ -935,8 +925,7 @@ sighandler_child_death () | |||
935 | * @param c configuration to use | 925 | * @param c configuration to use |
936 | */ | 926 | */ |
937 | static void | 927 | static void |
938 | run (void *cls, | 928 | run (void *cls, struct GNUNET_SERVER_Handle *serv, |
939 | struct GNUNET_SERVER_Handle *serv, | ||
940 | const struct GNUNET_CONFIGURATION_Handle *c) | 929 | const struct GNUNET_CONFIGURATION_Handle *c) |
941 | { | 930 | { |
942 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 931 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
@@ -955,32 +944,28 @@ run (void *cls, | |||
955 | pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); | 944 | pr = GNUNET_DISK_pipe_handle (sigpipe, GNUNET_DISK_PIPE_END_READ); |
956 | GNUNET_assert (pr != NULL); | 945 | GNUNET_assert (pr != NULL); |
957 | GNUNET_SERVER_ignore_shutdown (serv, GNUNET_YES); | 946 | GNUNET_SERVER_ignore_shutdown (serv, GNUNET_YES); |
958 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, | 947 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_FOREVER_REL, &shutdown_task, |
959 | &shutdown_task, NULL); | 948 | NULL); |
960 | child_death_task = | 949 | child_death_task = |
961 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr, | 950 | GNUNET_SCHEDULER_add_read_file (GNUNET_TIME_UNIT_FOREVER_REL, pr, |
962 | &maint_child_death, NULL); | 951 | &maint_child_death, NULL); |
963 | 952 | ||
964 | if (GNUNET_OK != | 953 | if (GNUNET_OK != |
965 | GNUNET_CONFIGURATION_get_value_string (cfg, | 954 | GNUNET_CONFIGURATION_get_value_string (cfg, "ARM", "GLOBAL_PREFIX", |
966 | "ARM", | 955 | &prefix_command)) |
967 | "GLOBAL_PREFIX", &prefix_command)) | ||
968 | prefix_command = GNUNET_strdup (""); | 956 | prefix_command = GNUNET_strdup (""); |
969 | if (GNUNET_OK != | 957 | if (GNUNET_OK != |
970 | GNUNET_CONFIGURATION_get_value_string (cfg, | 958 | GNUNET_CONFIGURATION_get_value_string (cfg, "ARM", "GLOBAL_POSTFIX", |
971 | "ARM", | 959 | &final_option)) |
972 | "GLOBAL_POSTFIX", &final_option)) | ||
973 | final_option = GNUNET_strdup (""); | 960 | final_option = GNUNET_strdup (""); |
974 | /* start default services... */ | 961 | /* start default services... */ |
975 | if (GNUNET_OK == | 962 | if (GNUNET_OK == |
976 | GNUNET_CONFIGURATION_get_value_string (cfg, | 963 | GNUNET_CONFIGURATION_get_value_string (cfg, "ARM", "DEFAULTSERVICES", |
977 | "ARM", | ||
978 | "DEFAULTSERVICES", | ||
979 | &defaultservices)) | 964 | &defaultservices)) |
980 | { | 965 | { |
981 | #if DEBUG_ARM | 966 | #if DEBUG_ARM |
982 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 967 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Starting default services `%s'\n", |
983 | "Starting default services `%s'\n", defaultservices); | 968 | defaultservices); |
984 | #endif | 969 | #endif |
985 | if (0 < strlen (defaultservices)) | 970 | if (0 < strlen (defaultservices)) |
986 | { | 971 | { |
diff --git a/src/arm/gnunet-service-arm_interceptor.c b/src/arm/gnunet-service-arm_interceptor.c index b99b076da..6d417ba37 100644 --- a/src/arm/gnunet-service-arm_interceptor.c +++ b/src/arm/gnunet-service-arm_interceptor.c | |||
@@ -356,8 +356,8 @@ closeClientAndServiceSockets (struct ForwardedConnection *fc, int reason) | |||
356 | * @param cls callback data, struct ForwardedConnection for the communication between client and service | 356 | * @param cls callback data, struct ForwardedConnection for the communication between client and service |
357 | * @param tc context | 357 | * @param tc context |
358 | */ | 358 | */ |
359 | static void | 359 | static void receiveFromClient (void *cls, |
360 | receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 360 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
361 | 361 | ||
362 | 362 | ||
363 | /** | 363 | /** |
@@ -366,15 +366,15 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | |||
366 | * @param cls callback data, struct ForwardedConnection for the communication between client and service | 366 | * @param cls callback data, struct ForwardedConnection for the communication between client and service |
367 | * @param tc scheduler context | 367 | * @param tc scheduler context |
368 | */ | 368 | */ |
369 | static void | 369 | static void receiveFromService (void *cls, |
370 | receiveFromService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 370 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
371 | 371 | ||
372 | 372 | ||
373 | /** | 373 | /** |
374 | * | 374 | * |
375 | */ | 375 | */ |
376 | static void | 376 | static void start_forwarding (void *cls, |
377 | start_forwarding (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 377 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
378 | 378 | ||
379 | 379 | ||
380 | 380 | ||
@@ -391,13 +391,13 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
391 | ssize_t numberOfBytesSent; | 391 | ssize_t numberOfBytesSent; |
392 | 392 | ||
393 | fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; | 393 | fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; |
394 | if (GNUNET_YES != GNUNET_NETWORK_fdset_isset (tc->write_ready, | 394 | if (GNUNET_YES != |
395 | fc->armClientSocket)) | 395 | GNUNET_NETWORK_fdset_isset (tc->write_ready, fc->armClientSocket)) |
396 | { | 396 | { |
397 | fc->service_to_client_task = | 397 | fc->service_to_client_task = |
398 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, | 398 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, |
399 | fc->armClientSocket, | 399 | fc->armClientSocket, &forwardToClient, |
400 | &forwardToClient, fc); | 400 | fc); |
401 | return; | 401 | return; |
402 | } | 402 | } |
403 | /* Forwarding service response to client */ | 403 | /* Forwarding service response to client */ |
@@ -415,8 +415,8 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
415 | return; | 415 | return; |
416 | } | 416 | } |
417 | #if DEBUG_SERVICE_MANAGER | 417 | #if DEBUG_SERVICE_MANAGER |
418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 418 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Forwarded %d bytes to client\n", |
419 | "Forwarded %d bytes to client\n", numberOfBytesSent); | 419 | numberOfBytesSent); |
420 | #endif | 420 | #endif |
421 | if (numberOfBytesSent < fc->service_to_client_bufferDataLength) | 421 | if (numberOfBytesSent < fc->service_to_client_bufferDataLength) |
422 | { | 422 | { |
@@ -424,14 +424,14 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
424 | fc->service_to_client_bufferDataLength -= numberOfBytesSent; | 424 | fc->service_to_client_bufferDataLength -= numberOfBytesSent; |
425 | fc->service_to_client_task = | 425 | fc->service_to_client_task = |
426 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, | 426 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, |
427 | fc->armClientSocket, | 427 | fc->armClientSocket, &forwardToClient, |
428 | &forwardToClient, fc); | 428 | fc); |
429 | return; | 429 | return; |
430 | } | 430 | } |
431 | fc->service_to_client_task = | 431 | fc->service_to_client_task = |
432 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 432 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
433 | fc->armServiceSocket, | 433 | fc->armServiceSocket, &receiveFromService, |
434 | &receiveFromService, fc); | 434 | fc); |
435 | } | 435 | } |
436 | 436 | ||
437 | 437 | ||
@@ -454,8 +454,8 @@ receiveFromService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
454 | closeClientAndServiceSockets (fc, REASON_ERROR); | 454 | closeClientAndServiceSockets (fc, REASON_ERROR); |
455 | return; | 455 | return; |
456 | } | 456 | } |
457 | if (GNUNET_YES != GNUNET_NETWORK_fdset_isset (tc->read_ready, | 457 | if (GNUNET_YES != |
458 | fc->armServiceSocket)) | 458 | GNUNET_NETWORK_fdset_isset (tc->read_ready, fc->armServiceSocket)) |
459 | { | 459 | { |
460 | fc->service_to_client_task = | 460 | fc->service_to_client_task = |
461 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 461 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
@@ -497,12 +497,12 @@ receiveFromService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
497 | GNUNET_a2s (fc->listen_info->service_addr, | 497 | GNUNET_a2s (fc->listen_info->service_addr, |
498 | fc->listen_info->service_addr_len), | 498 | fc->listen_info->service_addr_len), |
499 | (unsigned long long) GNUNET_TIME_relative_min (fc->back_off, | 499 | (unsigned long long) GNUNET_TIME_relative_min (fc->back_off, |
500 | rem).rel_value); | 500 | rem). |
501 | rel_value); | ||
501 | #endif | 502 | #endif |
502 | rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); | 503 | rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); |
503 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); | 504 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); |
504 | fc->start_task | 505 | fc->start_task = |
505 | = | ||
506 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_min | 506 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_min |
507 | (fc->back_off, rem), &start_forwarding, | 507 | (fc->back_off, rem), &start_forwarding, |
508 | fc); | 508 | fc); |
@@ -520,14 +520,13 @@ receiveFromService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
520 | } | 520 | } |
521 | fc->first_write_done = GNUNET_YES; | 521 | fc->first_write_done = GNUNET_YES; |
522 | #if DEBUG_SERVICE_MANAGER | 522 | #if DEBUG_SERVICE_MANAGER |
523 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 523 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %d bytes for client\n", |
524 | "Received %d bytes for client\n", | ||
525 | fc->service_to_client_bufferDataLength); | 524 | fc->service_to_client_bufferDataLength); |
526 | #endif | 525 | #endif |
527 | fc->service_to_client_task = | 526 | fc->service_to_client_task = |
528 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, | 527 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, |
529 | fc->armClientSocket, | 528 | fc->armClientSocket, &forwardToClient, |
530 | &forwardToClient, fc); | 529 | fc); |
531 | } | 530 | } |
532 | 531 | ||
533 | 532 | ||
@@ -551,13 +550,13 @@ forwardToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
551 | closeClientAndServiceSockets (fc, REASON_ERROR); | 550 | closeClientAndServiceSockets (fc, REASON_ERROR); |
552 | return; | 551 | return; |
553 | } | 552 | } |
554 | if (GNUNET_YES != GNUNET_NETWORK_fdset_isset (tc->write_ready, | 553 | if (GNUNET_YES != |
555 | fc->armServiceSocket)) | 554 | GNUNET_NETWORK_fdset_isset (tc->write_ready, fc->armServiceSocket)) |
556 | { | 555 | { |
557 | fc->client_to_service_task = | 556 | fc->client_to_service_task = |
558 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, | 557 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, |
559 | fc->armServiceSocket, | 558 | fc->armServiceSocket, &forwardToService, |
560 | &forwardToService, fc); | 559 | fc); |
561 | return; | 560 | return; |
562 | } | 561 | } |
563 | numberOfBytesSent = | 562 | numberOfBytesSent = |
@@ -585,12 +584,12 @@ forwardToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
585 | GNUNET_a2s (fc->listen_info->service_addr, | 584 | GNUNET_a2s (fc->listen_info->service_addr, |
586 | fc->listen_info->service_addr_len), | 585 | fc->listen_info->service_addr_len), |
587 | (unsigned long long) GNUNET_TIME_relative_min (fc->back_off, | 586 | (unsigned long long) GNUNET_TIME_relative_min (fc->back_off, |
588 | rem).rel_value); | 587 | rem). |
588 | rel_value); | ||
589 | #endif | 589 | #endif |
590 | rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); | 590 | rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); |
591 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); | 591 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); |
592 | fc->start_task | 592 | fc->start_task = |
593 | = | ||
594 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_min | 593 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_relative_min |
595 | (fc->back_off, rem), &start_forwarding, | 594 | (fc->back_off, rem), &start_forwarding, |
596 | fc); | 595 | fc); |
@@ -606,8 +605,8 @@ forwardToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
606 | return; | 605 | return; |
607 | } | 606 | } |
608 | #if DEBUG_SERVICE_MANAGER | 607 | #if DEBUG_SERVICE_MANAGER |
609 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 608 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Forwarded %d bytes to service\n", |
610 | "Forwarded %d bytes to service\n", numberOfBytesSent); | 609 | numberOfBytesSent); |
611 | #endif | 610 | #endif |
612 | fc->first_write_done = GNUNET_YES; | 611 | fc->first_write_done = GNUNET_YES; |
613 | if (numberOfBytesSent < fc->client_to_service_bufferDataLength) | 612 | if (numberOfBytesSent < fc->client_to_service_bufferDataLength) |
@@ -616,14 +615,14 @@ forwardToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
616 | fc->client_to_service_bufferDataLength -= numberOfBytesSent; | 615 | fc->client_to_service_bufferDataLength -= numberOfBytesSent; |
617 | fc->client_to_service_task = | 616 | fc->client_to_service_task = |
618 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, | 617 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, |
619 | fc->armServiceSocket, | 618 | fc->armServiceSocket, &forwardToService, |
620 | &forwardToService, fc); | 619 | fc); |
621 | return; | 620 | return; |
622 | } | 621 | } |
623 | fc->client_to_service_task = | 622 | fc->client_to_service_task = |
624 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 623 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
625 | fc->armClientSocket, | 624 | fc->armClientSocket, &receiveFromClient, |
626 | &receiveFromClient, fc); | 625 | fc); |
627 | } | 626 | } |
628 | 627 | ||
629 | 628 | ||
@@ -639,13 +638,13 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
639 | struct ForwardedConnection *fc = cls; | 638 | struct ForwardedConnection *fc = cls; |
640 | 639 | ||
641 | fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK; | 640 | fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK; |
642 | if (GNUNET_YES != GNUNET_NETWORK_fdset_isset (tc->read_ready, | 641 | if (GNUNET_YES != |
643 | fc->armClientSocket)) | 642 | GNUNET_NETWORK_fdset_isset (tc->read_ready, fc->armClientSocket)) |
644 | { | 643 | { |
645 | fc->client_to_service_task = | 644 | fc->client_to_service_task = |
646 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 645 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
647 | fc->armClientSocket, | 646 | fc->armClientSocket, &receiveFromClient, |
648 | &receiveFromClient, fc); | 647 | fc); |
649 | return; | 648 | return; |
650 | } | 649 | } |
651 | fc->client_to_service_bufferPos = fc->client_to_service_buffer; | 650 | fc->client_to_service_bufferPos = fc->client_to_service_buffer; |
@@ -665,23 +664,22 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
665 | else | 664 | else |
666 | { | 665 | { |
667 | #if DEBUG_SERVICE_MANAGER | 666 | #if DEBUG_SERVICE_MANAGER |
668 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 667 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Error receiving from client: %s\n", |
669 | "Error receiving from client: %s\n", STRERROR (errno)); | 668 | STRERROR (errno)); |
670 | #endif | 669 | #endif |
671 | } | 670 | } |
672 | closeClientAndServiceSockets (fc, REASON_CLIENT_TO_SERVICE); | 671 | closeClientAndServiceSockets (fc, REASON_CLIENT_TO_SERVICE); |
673 | return; | 672 | return; |
674 | } | 673 | } |
675 | #if DEBUG_SERVICE_MANAGER | 674 | #if DEBUG_SERVICE_MANAGER |
676 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 675 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Received %d bytes for service\n", |
677 | "Received %d bytes for service\n", | ||
678 | fc->client_to_service_bufferDataLength); | 676 | fc->client_to_service_bufferDataLength); |
679 | #endif | 677 | #endif |
680 | if (fc->armServiceSocket != NULL) | 678 | if (fc->armServiceSocket != NULL) |
681 | fc->client_to_service_task = | 679 | fc->client_to_service_task = |
682 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, | 680 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, |
683 | fc->armServiceSocket, | 681 | fc->armServiceSocket, &forwardToService, |
684 | &forwardToService, fc); | 682 | fc); |
685 | else | 683 | else |
686 | /* We have not added any task with fc as a closure, so we're | 684 | /* We have not added any task with fc as a closure, so we're |
687 | * dropping our reference to fc | 685 | * dropping our reference to fc |
@@ -742,8 +740,8 @@ fc_acceptConnection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
742 | else | 740 | else |
743 | fc->service_to_client_task = | 741 | fc->service_to_client_task = |
744 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, | 742 | GNUNET_SCHEDULER_add_write_net (GNUNET_TIME_UNIT_FOREVER_REL, |
745 | fc->armClientSocket, | 743 | fc->armClientSocket, &forwardToClient, |
746 | &forwardToClient, fc); | 744 | fc); |
747 | fc->reference_count += 1; | 745 | fc->reference_count += 1; |
748 | } | 746 | } |
749 | GNUNET_free (sli); | 747 | GNUNET_free (sli); |
@@ -751,9 +749,8 @@ fc_acceptConnection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
751 | 749 | ||
752 | 750 | ||
753 | static struct ServiceListeningInfo * | 751 | static struct ServiceListeningInfo * |
754 | service_try_to_connect (const struct sockaddr *addr, | 752 | service_try_to_connect (const struct sockaddr *addr, int pf, socklen_t addrlen, |
755 | int pf, | 753 | struct ForwardedConnection *fc) |
756 | socklen_t addrlen, struct ForwardedConnection *fc) | ||
757 | { | 754 | { |
758 | struct GNUNET_NETWORK_Handle *sock; | 755 | struct GNUNET_NETWORK_Handle *sock; |
759 | struct ServiceListeningInfo *serviceListeningInfo; | 756 | struct ServiceListeningInfo *serviceListeningInfo; |
@@ -839,8 +836,8 @@ start_forwarding (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
839 | target_ipv4.sin_port = v4->sin_port; | 836 | target_ipv4.sin_port = v4->sin_port; |
840 | v4 = &target_ipv4; | 837 | v4 = &target_ipv4; |
841 | } | 838 | } |
842 | sc = service_try_to_connect ((const struct sockaddr *) v4, | 839 | sc = service_try_to_connect ((const struct sockaddr *) v4, PF_INET, |
843 | PF_INET, sizeof (struct sockaddr_in), fc); | 840 | sizeof (struct sockaddr_in), fc); |
844 | break; | 841 | break; |
845 | case AF_INET6: | 842 | case AF_INET6: |
846 | v6 = (struct sockaddr_in6 *) fc->listen_info->service_addr; | 843 | v6 = (struct sockaddr_in6 *) fc->listen_info->service_addr; |
@@ -855,12 +852,11 @@ start_forwarding (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
855 | target_ipv6.sin6_port = v6->sin6_port; | 852 | target_ipv6.sin6_port = v6->sin6_port; |
856 | v6 = &target_ipv6; | 853 | v6 = &target_ipv6; |
857 | } | 854 | } |
858 | sc = service_try_to_connect ((const struct sockaddr *) v6, | 855 | sc = service_try_to_connect ((const struct sockaddr *) v6, PF_INET6, |
859 | PF_INET6, sizeof (struct sockaddr_in6), fc); | 856 | sizeof (struct sockaddr_in6), fc); |
860 | break; | 857 | break; |
861 | case AF_UNIX: | 858 | case AF_UNIX: |
862 | sc = service_try_to_connect (fc->listen_info->service_addr, | 859 | sc = service_try_to_connect (fc->listen_info->service_addr, PF_UNIX, |
863 | PF_UNIX, | ||
864 | fc->listen_info->service_addr_len, fc); | 860 | fc->listen_info->service_addr_len, fc); |
865 | break; | 861 | break; |
866 | default: | 862 | default: |
@@ -917,8 +913,8 @@ stop_listening (const char *serviceName) | |||
917 | * @param cls callback data, struct ServiceListeningInfo describing a listen socket | 913 | * @param cls callback data, struct ServiceListeningInfo describing a listen socket |
918 | * @param tc context | 914 | * @param tc context |
919 | */ | 915 | */ |
920 | static void | 916 | static void acceptConnection (void *cls, |
921 | acceptConnection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | 917 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
922 | 918 | ||
923 | 919 | ||
924 | static void | 920 | static void |
@@ -952,18 +948,18 @@ accept_and_forward (struct ServiceListeningInfo *serviceListeningInfo) | |||
952 | return; | 948 | return; |
953 | } | 949 | } |
954 | GNUNET_break (GNUNET_OK == | 950 | GNUNET_break (GNUNET_OK == |
955 | GNUNET_NETWORK_socket_close | 951 | GNUNET_NETWORK_socket_close (serviceListeningInfo-> |
956 | (serviceListeningInfo->listeningSocket)); | 952 | listeningSocket)); |
957 | start_service (NULL, serviceListeningInfo->serviceName, NULL); | 953 | start_service (NULL, serviceListeningInfo->serviceName, NULL); |
958 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 954 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, _("Service `%s' started\n"), |
959 | _("Service `%s' started\n"), fc->listen_info->serviceName); | 955 | fc->listen_info->serviceName); |
960 | fc->timeout = | 956 | fc->timeout = |
961 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_SERVICE_TIMEOUT); | 957 | GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_SERVICE_TIMEOUT); |
962 | fc->back_off = GNUNET_TIME_UNIT_MILLISECONDS; | 958 | fc->back_off = GNUNET_TIME_UNIT_MILLISECONDS; |
963 | fc->client_to_service_task = | 959 | fc->client_to_service_task = |
964 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, | 960 | GNUNET_SCHEDULER_add_read_net (GNUNET_TIME_UNIT_FOREVER_REL, |
965 | fc->armClientSocket, | 961 | fc->armClientSocket, &receiveFromClient, |
966 | &receiveFromClient, fc); | 962 | fc); |
967 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); | 963 | GNUNET_assert (GNUNET_SCHEDULER_NO_TASK == fc->start_task); |
968 | /* We're creating another chain of tasks for this fc that | 964 | /* We're creating another chain of tasks for this fc that |
969 | * will have its own reference to it. | 965 | * will have its own reference to it. |
@@ -997,12 +993,12 @@ acceptConnection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
997 | serviceListeningInfoList_tail, sli); | 993 | serviceListeningInfoList_tail, sli); |
998 | #ifndef MINGW | 994 | #ifndef MINGW |
999 | use_lsocks = GNUNET_NO; | 995 | use_lsocks = GNUNET_NO; |
1000 | if (GNUNET_YES == GNUNET_CONFIGURATION_have_value (cfg, | 996 | if (GNUNET_YES == |
1001 | sli->serviceName, | 997 | GNUNET_CONFIGURATION_have_value (cfg, sli->serviceName, |
1002 | "DISABLE_SOCKET_FORWARDING")) | 998 | "DISABLE_SOCKET_FORWARDING")) |
1003 | use_lsocks = GNUNET_CONFIGURATION_get_value_yesno (cfg, | 999 | use_lsocks = |
1004 | sli->serviceName, | 1000 | GNUNET_CONFIGURATION_get_value_yesno (cfg, sli->serviceName, |
1005 | "DISABLE_SOCKET_FORWARDING"); | 1001 | "DISABLE_SOCKET_FORWARDING"); |
1006 | #else | 1002 | #else |
1007 | use_lsocks = GNUNET_YES; | 1003 | use_lsocks = GNUNET_YES; |
1008 | #endif | 1004 | #endif |
@@ -1100,8 +1096,8 @@ createListeningSocket (struct sockaddr *sa, socklen_t addr_len, | |||
1100 | "setsockopt"); | 1096 | "setsockopt"); |
1101 | #endif | 1097 | #endif |
1102 | 1098 | ||
1103 | if (GNUNET_NETWORK_socket_bind | 1099 | if (GNUNET_NETWORK_socket_bind (sock, (const struct sockaddr *) sa, addr_len) |
1104 | (sock, (const struct sockaddr *) sa, addr_len) != GNUNET_OK) | 1100 | != GNUNET_OK) |
1105 | { | 1101 | { |
1106 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 1102 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
1107 | _ | 1103 | _ |
@@ -1145,8 +1141,8 @@ createListeningSocket (struct sockaddr *sa, socklen_t addr_len, | |||
1145 | * @param value the option's value | 1141 | * @param value the option's value |
1146 | */ | 1142 | */ |
1147 | static void | 1143 | static void |
1148 | checkPortNumberCB (void *cls, | 1144 | checkPortNumberCB (void *cls, const char *section, const char *option, |
1149 | const char *section, const char *option, const char *value) | 1145 | const char *value) |
1150 | { | 1146 | { |
1151 | struct sockaddr **addrs; | 1147 | struct sockaddr **addrs; |
1152 | socklen_t *addr_lens; | 1148 | socklen_t *addr_lens; |
@@ -1158,8 +1154,9 @@ checkPortNumberCB (void *cls, | |||
1158 | (strcasecmp (value, "YES") != 0) || | 1154 | (strcasecmp (value, "YES") != 0) || |
1159 | (isInDefaultList (section) == GNUNET_YES)) | 1155 | (isInDefaultList (section) == GNUNET_YES)) |
1160 | return; | 1156 | return; |
1161 | if (0 >= (ret = GNUNET_SERVICE_get_server_addresses (section, cfg, &addrs, | 1157 | if (0 >= |
1162 | &addr_lens))) | 1158 | (ret = |
1159 | GNUNET_SERVICE_get_server_addresses (section, cfg, &addrs, &addr_lens))) | ||
1163 | return; | 1160 | return; |
1164 | /* this will free (or capture) addrs[i] */ | 1161 | /* this will free (or capture) addrs[i] */ |
1165 | for (i = 0; i < ret; i++) | 1162 | for (i = 0; i < ret; i++) |
diff --git a/src/arm/mockup-service.c b/src/arm/mockup-service.c index 0a0e1de5a..53a502fa8 100644 --- a/src/arm/mockup-service.c +++ b/src/arm/mockup-service.c | |||
@@ -61,8 +61,7 @@ transmit_shutdown_ack (void *cls, size_t size, void *buf) | |||
61 | * @param message the actual message | 61 | * @param message the actual message |
62 | */ | 62 | */ |
63 | static void | 63 | static void |
64 | handle_shutdown (void *cls, | 64 | handle_shutdown (void *cls, struct GNUNET_SERVER_Client *client, |
65 | struct GNUNET_SERVER_Client *client, | ||
66 | const struct GNUNET_MessageHeader *message) | 65 | const struct GNUNET_MessageHeader *message) |
67 | { | 66 | { |
68 | GNUNET_SERVER_client_keep (client); | 67 | GNUNET_SERVER_client_keep (client); |
@@ -79,8 +78,7 @@ handle_shutdown (void *cls, | |||
79 | 78 | ||
80 | 79 | ||
81 | static void | 80 | static void |
82 | run (void *cls, | 81 | run (void *cls, struct GNUNET_SERVER_Handle *server, |
83 | struct GNUNET_SERVER_Handle *server, | ||
84 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 82 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
85 | { | 83 | { |
86 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { | 84 | static const struct GNUNET_SERVER_MessageHandler handlers[] = { |
@@ -99,10 +97,9 @@ main (int argc, char *const *argv) | |||
99 | { | 97 | { |
100 | int ret; | 98 | int ret; |
101 | 99 | ||
102 | ret = (GNUNET_OK == | 100 | ret = |
103 | GNUNET_SERVICE_run (argc, | 101 | (GNUNET_OK == |
104 | argv, | 102 | GNUNET_SERVICE_run (argc, argv, "do-nothing", GNUNET_SERVICE_OPTION_NONE, |
105 | "do-nothing", GNUNET_SERVICE_OPTION_NONE, | 103 | &run, NULL)) ? 0 : 1; |
106 | &run, NULL)) ? 0 : 1; | ||
107 | return ret; | 104 | return ret; |
108 | } | 105 | } |
diff --git a/src/arm/test_arm_api.c b/src/arm/test_arm_api.c index 1e9d84202..11c245ea1 100644 --- a/src/arm/test_arm_api.c +++ b/src/arm/test_arm_api.c | |||
@@ -114,9 +114,8 @@ arm_notify (void *cls, int success) | |||
114 | 114 | ||
115 | 115 | ||
116 | static void | 116 | static void |
117 | task (void *cls, | 117 | task (void *cls, char *const *args, const char *cfgfile, |
118 | char *const *args, | 118 | const struct GNUNET_CONFIGURATION_Handle *c) |
119 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) | ||
120 | { | 119 | { |
121 | cfg = c; | 120 | cfg = c; |
122 | arm = GNUNET_ARM_connect (cfg, NULL); | 121 | arm = GNUNET_ARM_connect (cfg, NULL); |
@@ -145,9 +144,8 @@ check () | |||
145 | }; | 144 | }; |
146 | GNUNET_assert (GNUNET_OK == | 145 | GNUNET_assert (GNUNET_OK == |
147 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 146 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, |
148 | argv, | 147 | argv, "test-arm-api", "nohelp", options, |
149 | "test-arm-api", | 148 | &task, NULL)); |
150 | "nohelp", options, &task, NULL)); | ||
151 | return ok; | 149 | return ok; |
152 | } | 150 | } |
153 | 151 | ||
diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index eb6421d5f..04c52d0eb 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c | |||
@@ -136,8 +136,7 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
136 | "Received confirmation for service shutdown.\n"); | 136 | "Received confirmation for service shutdown.\n"); |
137 | #endif | 137 | #endif |
138 | shutdown_ctx->confirmed = GNUNET_YES; | 138 | shutdown_ctx->confirmed = GNUNET_YES; |
139 | GNUNET_CLIENT_receive (shutdown_ctx->sock, | 139 | GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, |
140 | &service_shutdown_handler, | ||
141 | shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); | 140 | shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); |
142 | break; | 141 | break; |
143 | default: /* Fall through */ | 142 | default: /* Fall through */ |
@@ -197,9 +196,8 @@ write_shutdown (void *cls, size_t size, void *buf) | |||
197 | return 0; /* client disconnected */ | 196 | return 0; /* client disconnected */ |
198 | } | 197 | } |
199 | 198 | ||
200 | GNUNET_CLIENT_receive (shutdown_ctx->sock, | 199 | GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, |
201 | &service_shutdown_handler, shutdown_ctx, | 200 | shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); |
202 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
203 | shutdown_ctx->cancel_task = | 201 | shutdown_ctx->cancel_task = |
204 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining | 202 | GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_absolute_get_remaining |
205 | (shutdown_ctx->timeout), | 203 | (shutdown_ctx->timeout), |
@@ -237,11 +235,9 @@ arm_service_shutdown (struct GNUNET_CLIENT_Connection *sock, | |||
237 | shutdown_ctx->sock = sock; | 235 | shutdown_ctx->sock = sock; |
238 | shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); | 236 | shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute (timeout); |
239 | GNUNET_CLIENT_notify_transmit_ready (sock, | 237 | GNUNET_CLIENT_notify_transmit_ready (sock, |
240 | sizeof (struct | 238 | sizeof (struct GNUNET_MessageHeader), |
241 | GNUNET_MessageHeader), | 239 | timeout, GNUNET_NO, &write_shutdown, |
242 | timeout, | 240 | shutdown_ctx); |
243 | GNUNET_NO, | ||
244 | &write_shutdown, shutdown_ctx); | ||
245 | } | 241 | } |
246 | 242 | ||
247 | 243 | ||
@@ -255,8 +251,8 @@ arm_notify_stop (void *cls, int success) | |||
255 | } | 251 | } |
256 | 252 | ||
257 | 253 | ||
258 | static void | 254 | static void kill_task (void *cbData, |
259 | kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc); | 255 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
260 | 256 | ||
261 | 257 | ||
262 | static void | 258 | static void |
@@ -272,13 +268,13 @@ static void | |||
272 | arm_notify (void *cls, int success) | 268 | arm_notify (void *cls, int success) |
273 | { | 269 | { |
274 | GNUNET_assert (success == GNUNET_YES); | 270 | GNUNET_assert (success == GNUNET_YES); |
275 | GNUNET_ARM_start_service (arm, | 271 | GNUNET_ARM_start_service (arm, "do-nothing", TIMEOUT, &do_nothing_notify, |
276 | "do-nothing", TIMEOUT, &do_nothing_notify, NULL); | 272 | NULL); |
277 | } | 273 | } |
278 | 274 | ||
279 | 275 | ||
280 | static void | 276 | static void kill_task (void *cbData, |
281 | kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc); | 277 | const struct GNUNET_SCHEDULER_TaskContext *tc); |
282 | 278 | ||
283 | 279 | ||
284 | static void | 280 | static void |
@@ -310,8 +306,7 @@ do_nothing_restarted_notify_task (void *cls, | |||
310 | static void | 306 | static void |
311 | do_test (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) | 307 | do_test (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) |
312 | { | 308 | { |
313 | GNUNET_CLIENT_service_test ("do-nothing", | 309 | GNUNET_CLIENT_service_test ("do-nothing", cfg, TIMEOUT, |
314 | cfg, TIMEOUT, | ||
315 | &do_nothing_restarted_notify_task, NULL); | 310 | &do_nothing_restarted_notify_task, NULL); |
316 | } | 311 | } |
317 | 312 | ||
@@ -335,8 +330,8 @@ kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
335 | waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt); | 330 | waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt); |
336 | 331 | ||
337 | #if LOG_BACKOFF | 332 | #if LOG_BACKOFF |
338 | fprintf (killLogFilePtr, | 333 | fprintf (killLogFilePtr, "Waited for: %llu ms\n", |
339 | "Waited for: %llu ms\n", (unsigned long long) waitedFor.rel_value); | 334 | (unsigned long long) waitedFor.rel_value); |
340 | #endif | 335 | #endif |
341 | } | 336 | } |
342 | else | 337 | else |
@@ -349,8 +344,8 @@ kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
349 | if (trialCount == 12) | 344 | if (trialCount == 12) |
350 | { | 345 | { |
351 | GNUNET_CLIENT_disconnect (doNothingConnection, GNUNET_NO); | 346 | GNUNET_CLIENT_disconnect (doNothingConnection, GNUNET_NO); |
352 | GNUNET_ARM_stop_service (arm, | 347 | GNUNET_ARM_stop_service (arm, "do-nothing", TIMEOUT, &arm_notify_stop, |
353 | "do-nothing", TIMEOUT, &arm_notify_stop, NULL); | 348 | NULL); |
354 | ok = 0; | 349 | ok = 0; |
355 | return; | 350 | return; |
356 | } | 351 | } |
@@ -360,9 +355,8 @@ kill_task (void *cbData, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
360 | 355 | ||
361 | 356 | ||
362 | static void | 357 | static void |
363 | task (void *cls, | 358 | task (void *cls, char *const *args, const char *cfgfile, |
364 | char *const *args, | 359 | const struct GNUNET_CONFIGURATION_Handle *c) |
365 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) | ||
366 | { | 360 | { |
367 | cfg = c; | 361 | cfg = c; |
368 | 362 | ||
@@ -393,9 +387,8 @@ check () | |||
393 | /* Running ARM and running the do_nothing task */ | 387 | /* Running ARM and running the do_nothing task */ |
394 | GNUNET_assert (GNUNET_OK == | 388 | GNUNET_assert (GNUNET_OK == |
395 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 389 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, |
396 | argv, | 390 | argv, "test-exponential-backoff", "nohelp", |
397 | "test-exponential-backoff", | 391 | options, &task, NULL)); |
398 | "nohelp", options, &task, NULL)); | ||
399 | 392 | ||
400 | 393 | ||
401 | return ok; | 394 | return ok; |
diff --git a/src/arm/test_gnunet_service_manager.c b/src/arm/test_gnunet_service_manager.c index 4c4de9242..4f863ed19 100644 --- a/src/arm/test_gnunet_service_manager.c +++ b/src/arm/test_gnunet_service_manager.c | |||
@@ -101,9 +101,9 @@ arm_notify (void *cls, int success) | |||
101 | } | 101 | } |
102 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to resolve our own hostname!\n"); | 102 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Trying to resolve our own hostname!\n"); |
103 | /* connect to the resolver service */ | 103 | /* connect to the resolver service */ |
104 | if (NULL == GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, | 104 | if (NULL == |
105 | TIMEOUT, | 105 | GNUNET_RESOLVER_hostname_resolve (AF_UNSPEC, TIMEOUT, &hostNameResolveCB, |
106 | &hostNameResolveCB, NULL)) | 106 | NULL)) |
107 | { | 107 | { |
108 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 108 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
109 | "Unable initiate connection to resolver service\n"); | 109 | "Unable initiate connection to resolver service\n"); |
@@ -116,9 +116,8 @@ arm_notify (void *cls, int success) | |||
116 | 116 | ||
117 | 117 | ||
118 | static void | 118 | static void |
119 | run (void *cls, | 119 | run (void *cls, char *const *args, const char *cfgfile, |
120 | char *const *args, | 120 | const struct GNUNET_CONFIGURATION_Handle *c) |
121 | const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) | ||
122 | { | 121 | { |
123 | cfg = c; | 122 | cfg = c; |
124 | #if START_ARM | 123 | #if START_ARM |
@@ -146,8 +145,7 @@ check () | |||
146 | }; | 145 | }; |
147 | GNUNET_assert (GNUNET_OK == | 146 | GNUNET_assert (GNUNET_OK == |
148 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 147 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, |
149 | argv, | 148 | argv, "test-gnunet-service-manager", |
150 | "test-gnunet-service-manager", | ||
151 | "nohelp", options, &run, NULL)); | 149 | "nohelp", options, &run, NULL)); |
152 | } | 150 | } |
153 | 151 | ||
@@ -159,8 +157,8 @@ main (int argc, char *argv[]) | |||
159 | 157 | ||
160 | if (0 != gethostname (hostname, sizeof (hostname) - 1)) | 158 | if (0 != gethostname (hostname, sizeof (hostname) - 1)) |
161 | { | 159 | { |
162 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | | 160 | GNUNET_log_strerror (GNUNET_ERROR_TYPE_ERROR | GNUNET_ERROR_TYPE_BULK, |
163 | GNUNET_ERROR_TYPE_BULK, "gethostname"); | 161 | "gethostname"); |
164 | fprintf (stderr, | 162 | fprintf (stderr, |
165 | "Failed to determine my own hostname, testcase not run.\n"); | 163 | "Failed to determine my own hostname, testcase not run.\n"); |
166 | return 0; | 164 | return 0; |