diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-18 12:23:00 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-18 12:23:00 +0000 |
commit | 8a6311d5c6d1434e2cc01781d7b30e0788c89fba (patch) | |
tree | abc66f2388824e1ea9dc321399576423f3d6bea9 /src | |
parent | a9b5a58a55dd8c6f4b8dc1cadd7d4639f30bb1fd (diff) | |
download | gnunet-8a6311d5c6d1434e2cc01781d7b30e0788c89fba.tar.gz gnunet-8a6311d5c6d1434e2cc01781d7b30e0788c89fba.zip |
fixes
Diffstat (limited to 'src')
-rw-r--r-- | src/arm/arm_api.c | 6 | ||||
-rw-r--r-- | src/arm/gnunet-arm.c | 10 | ||||
-rw-r--r-- | src/arm/gnunet-service-manager.c | 250 | ||||
-rw-r--r-- | src/arm/test_arm_api_data.conf | 2 | ||||
-rw-r--r-- | src/arm/test_exponential_backoff.c | 8 |
5 files changed, 186 insertions, 90 deletions
diff --git a/src/arm/arm_api.c b/src/arm/arm_api.c index f3116f3b5..f98b4100a 100644 --- a/src/arm/arm_api.c +++ b/src/arm/arm_api.c | |||
@@ -127,8 +127,10 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
127 | } | 127 | } |
128 | else if ((msg == NULL) && (shutdown_ctx->confirmed == GNUNET_YES)) | 128 | else if ((msg == NULL) && (shutdown_ctx->confirmed == GNUNET_YES)) |
129 | { | 129 | { |
130 | #if DEBUG_ARM | ||
130 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 131 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
131 | "Service shutdown complete.\n"); | 132 | "Service shutdown complete.\n"); |
133 | #endif | ||
132 | if (shutdown_ctx->cont != NULL) | 134 | if (shutdown_ctx->cont != NULL) |
133 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO); | 135 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO); |
134 | 136 | ||
@@ -142,8 +144,10 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
142 | switch (ntohs(msg->type)) | 144 | switch (ntohs(msg->type)) |
143 | { | 145 | { |
144 | case GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK: | 146 | case GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK: |
147 | #if DEBUG_ARM | ||
145 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 148 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
146 | "Received confirmation for service shutdown.\n"); | 149 | "Received confirmation for service shutdown.\n"); |
150 | #endif | ||
147 | shutdown_ctx->confirmed = GNUNET_YES; | 151 | shutdown_ctx->confirmed = GNUNET_YES; |
148 | GNUNET_CLIENT_receive (shutdown_ctx->sock, | 152 | GNUNET_CLIENT_receive (shutdown_ctx->sock, |
149 | &service_shutdown_handler, | 153 | &service_shutdown_handler, |
@@ -151,8 +155,10 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
151 | GNUNET_TIME_UNIT_FOREVER_REL); | 155 | GNUNET_TIME_UNIT_FOREVER_REL); |
152 | break; | 156 | break; |
153 | default: /* Fall through */ | 157 | default: /* Fall through */ |
158 | #if DEBUG_ARM | ||
154 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | 159 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
155 | "Service shutdown refused!\n"); | 160 | "Service shutdown refused!\n"); |
161 | #endif | ||
156 | if (shutdown_ctx->cont != NULL) | 162 | if (shutdown_ctx->cont != NULL) |
157 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES); | 163 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES); |
158 | 164 | ||
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index 7ad3e48e7..c631ec480 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c | |||
@@ -26,6 +26,7 @@ | |||
26 | #include "platform.h" | 26 | #include "platform.h" |
27 | #include "gnunet_arm_service.h" | 27 | #include "gnunet_arm_service.h" |
28 | #include "gnunet_client_lib.h" | 28 | #include "gnunet_client_lib.h" |
29 | #include "gnunet_constants.h" | ||
29 | #include "gnunet_getopt_lib.h" | 30 | #include "gnunet_getopt_lib.h" |
30 | #include "gnunet_program_lib.h" | 31 | #include "gnunet_program_lib.h" |
31 | #include "gnunet_time_lib.h" | 32 | #include "gnunet_time_lib.h" |
@@ -43,6 +44,13 @@ | |||
43 | #define START_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 50) | 44 | #define START_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 50) |
44 | 45 | ||
45 | /** | 46 | /** |
47 | * Timeout for starting services, very short because of the strange way start works | ||
48 | * (by checking if running before starting, so really this time is always waited on | ||
49 | * startup (annoying)). | ||
50 | */ | ||
51 | #define TEST_TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 2) | ||
52 | |||
53 | /** | ||
46 | * Set if we are to shutdown all services (including ARM). | 54 | * Set if we are to shutdown all services (including ARM). |
47 | */ | 55 | */ |
48 | static int end; | 56 | static int end; |
@@ -314,7 +322,7 @@ cps_loop (void *cls, | |||
314 | case 4: | 322 | case 4: |
315 | if (test != NULL) | 323 | if (test != NULL) |
316 | { | 324 | { |
317 | GNUNET_CLIENT_service_test (sched, test, cfg, START_TIMEOUT, &confirm_task, test); | 325 | GNUNET_CLIENT_service_test (sched, test, cfg, TEST_TIMEOUT, &confirm_task, test); |
318 | return; | 326 | return; |
319 | } | 327 | } |
320 | break; | 328 | break; |
diff --git a/src/arm/gnunet-service-manager.c b/src/arm/gnunet-service-manager.c index f1b4e8507..d97ce7ffd 100644 --- a/src/arm/gnunet-service-manager.c +++ b/src/arm/gnunet-service-manager.c | |||
@@ -39,8 +39,6 @@ | |||
39 | 39 | ||
40 | #define DEBUG_SERVICE_MANAGER GNUNET_NO | 40 | #define DEBUG_SERVICE_MANAGER GNUNET_NO |
41 | 41 | ||
42 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | ||
43 | |||
44 | #define BUFFER_SIZE (64 * 1024) | 42 | #define BUFFER_SIZE (64 * 1024) |
45 | 43 | ||
46 | /** | 44 | /** |
@@ -180,6 +178,10 @@ struct ForwardedConnection | |||
180 | */ | 178 | */ |
181 | socklen_t client_addr_len; | 179 | socklen_t client_addr_len; |
182 | 180 | ||
181 | /** | ||
182 | * Have we ever successfully written data to the service? | ||
183 | */ | ||
184 | int first_write_done; | ||
183 | }; | 185 | }; |
184 | 186 | ||
185 | 187 | ||
@@ -353,6 +355,15 @@ receiveFromService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc); | |||
353 | 355 | ||
354 | 356 | ||
355 | /** | 357 | /** |
358 | * | ||
359 | */ | ||
360 | static void | ||
361 | start_forwarding (void *cls, | ||
362 | const struct GNUNET_SCHEDULER_TaskContext *tc); | ||
363 | |||
364 | |||
365 | |||
366 | /** | ||
356 | * Forward messages sent from service to client | 367 | * Forward messages sent from service to client |
357 | * | 368 | * |
358 | * @param cls callback data, struct ForwardedConnection for the communication between client and service | 369 | * @param cls callback data, struct ForwardedConnection for the communication between client and service |
@@ -383,7 +394,8 @@ forwardToClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
383 | if (numberOfBytesSent <= 0) | 394 | if (numberOfBytesSent <= 0) |
384 | { | 395 | { |
385 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 396 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
386 | "Failed to forward data to client: %s\n", | 397 | "Failed to forward %u bytes of data to client: %s\n", |
398 | fc->service_to_client_bufferDataLength, | ||
387 | STRERROR (errno)); | 399 | STRERROR (errno)); |
388 | closeClientAndServiceSockets (fc, | 400 | closeClientAndServiceSockets (fc, |
389 | REASON_SERVICE_TO_CLIENT); | 401 | REASON_SERVICE_TO_CLIENT); |
@@ -426,6 +438,7 @@ receiveFromService (void *cls, | |||
426 | const struct GNUNET_SCHEDULER_TaskContext *tc) | 438 | const struct GNUNET_SCHEDULER_TaskContext *tc) |
427 | { | 439 | { |
428 | struct ForwardedConnection *fc = cls; | 440 | struct ForwardedConnection *fc = cls; |
441 | struct GNUNET_TIME_Relative rem; | ||
429 | 442 | ||
430 | fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; | 443 | fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; |
431 | if (GNUNET_YES != GNUNET_NETWORK_fdset_isset (tc->read_ready, | 444 | if (GNUNET_YES != GNUNET_NETWORK_fdset_isset (tc->read_ready, |
@@ -453,17 +466,49 @@ receiveFromService (void *cls, | |||
453 | fc->listen_info->serviceName); | 466 | fc->listen_info->serviceName); |
454 | #endif | 467 | #endif |
455 | } | 468 | } |
456 | else | 469 | if (fc->first_write_done != GNUNET_YES) |
457 | { | 470 | { |
471 | fc->service_to_client_bufferDataLength = 0; | ||
472 | GNUNET_break (GNUNET_OK == | ||
473 | GNUNET_NETWORK_socket_close (fc->armServiceSocket)); | ||
474 | fc->armServiceSocket = NULL; | ||
475 | if ( (fc->client_to_service_bufferDataLength > 0) && | ||
476 | (fc->client_to_service_task != GNUNET_SCHEDULER_NO_TASK) ) | ||
477 | { | ||
478 | GNUNET_SCHEDULER_cancel (scheduler, | ||
479 | fc->client_to_service_task); | ||
480 | fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; | ||
481 | } | ||
482 | fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2); | ||
458 | #if DEBUG_SERVICE_MANAGER | 483 | #if DEBUG_SERVICE_MANAGER |
459 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 484 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
460 | "Error receiving from service: %s\n", | 485 | "Failed to connected to service `%s' at `%s', will try again in %llu ms\n", |
461 | STRERROR (errno)); | 486 | fc->listen_info->serviceName, |
487 | GNUNET_a2s (fc->listen_info->service_addr, | ||
488 | fc->listen_info->service_addr_len), | ||
489 | (unsigned long long) GNUNET_TIME_relative_min (fc->back_off, | ||
490 | rem).value); | ||
491 | #endif | ||
492 | rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); | ||
493 | GNUNET_SCHEDULER_add_delayed (scheduler, | ||
494 | GNUNET_TIME_relative_min (fc->back_off, | ||
495 | rem), | ||
496 | &start_forwarding, | ||
497 | fc); | ||
498 | } | ||
499 | else | ||
500 | { | ||
501 | if (fc->service_to_client_bufferDataLength != 0) | ||
502 | #if DEBUG_SERVICE_MANAGER | ||
503 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
504 | "Error receiving from service: %s\n", | ||
505 | STRERROR (errno)); | ||
462 | #endif | 506 | #endif |
507 | closeClientAndServiceSockets (fc, REASON_SERVICE_TO_CLIENT); | ||
463 | } | 508 | } |
464 | closeClientAndServiceSockets (fc, REASON_SERVICE_TO_CLIENT); | ||
465 | return; | 509 | return; |
466 | } | 510 | } |
511 | fc->first_write_done = GNUNET_YES; | ||
467 | #if DEBUG_SERVICE_MANAGER | 512 | #if DEBUG_SERVICE_MANAGER |
468 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 513 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
469 | "Received %d bytes for client\n", | 514 | "Received %d bytes for client\n", |
@@ -489,6 +534,7 @@ forwardToService (void *cls, | |||
489 | { | 534 | { |
490 | struct ForwardedConnection *fc = cls; | 535 | struct ForwardedConnection *fc = cls; |
491 | ssize_t numberOfBytesSent; | 536 | ssize_t numberOfBytesSent; |
537 | struct GNUNET_TIME_Relative rem; | ||
492 | 538 | ||
493 | fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK; | 539 | fc->client_to_service_task = GNUNET_SCHEDULER_NO_TASK; |
494 | if (GNUNET_YES != GNUNET_NETWORK_fdset_isset (tc->write_ready, | 540 | if (GNUNET_YES != GNUNET_NETWORK_fdset_isset (tc->write_ready, |
@@ -507,11 +553,43 @@ forwardToService (void *cls, | |||
507 | fc->client_to_service_bufferDataLength); | 553 | fc->client_to_service_bufferDataLength); |
508 | if (numberOfBytesSent <= 0) | 554 | if (numberOfBytesSent <= 0) |
509 | { | 555 | { |
510 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | 556 | if (GNUNET_YES != fc->first_write_done) |
511 | "Failed to forward data to service: %s\n", | 557 | { |
512 | STRERROR (errno)); | 558 | GNUNET_break (GNUNET_OK == |
513 | closeClientAndServiceSockets (fc, | 559 | GNUNET_NETWORK_socket_close (fc->armServiceSocket)); |
514 | REASON_CLIENT_TO_SERVICE); | 560 | fc->armServiceSocket = NULL; |
561 | if ( (fc->service_to_client_bufferDataLength == 0) && | ||
562 | (fc->service_to_client_task != GNUNET_SCHEDULER_NO_TASK) ) | ||
563 | { | ||
564 | GNUNET_SCHEDULER_cancel (scheduler, | ||
565 | fc->service_to_client_task); | ||
566 | fc->service_to_client_task = GNUNET_SCHEDULER_NO_TASK; | ||
567 | } | ||
568 | fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2); | ||
569 | #if DEBUG_SERVICE_MANAGER | ||
570 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
571 | "Failed to connect to service `%s' at `%s', will try again in %llu ms\n", | ||
572 | fc->listen_info->serviceName, | ||
573 | GNUNET_a2s (fc->listen_info->service_addr, | ||
574 | fc->listen_info->service_addr_len), | ||
575 | (unsigned long long) GNUNET_TIME_relative_min (fc->back_off, | ||
576 | rem).value); | ||
577 | #endif | ||
578 | rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); | ||
579 | GNUNET_SCHEDULER_add_delayed (scheduler, | ||
580 | GNUNET_TIME_relative_min (fc->back_off, | ||
581 | rem), | ||
582 | &start_forwarding, | ||
583 | fc); | ||
584 | } | ||
585 | else | ||
586 | { | ||
587 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
588 | "Failed to forward data to service: %s\n", | ||
589 | STRERROR (errno)); | ||
590 | closeClientAndServiceSockets (fc, | ||
591 | REASON_CLIENT_TO_SERVICE); | ||
592 | } | ||
515 | return; | 593 | return; |
516 | } | 594 | } |
517 | #if DEBUG_SERVICE_MANAGER | 595 | #if DEBUG_SERVICE_MANAGER |
@@ -519,6 +597,7 @@ forwardToService (void *cls, | |||
519 | "Forwarded %d bytes to service\n", | 597 | "Forwarded %d bytes to service\n", |
520 | numberOfBytesSent); | 598 | numberOfBytesSent); |
521 | #endif | 599 | #endif |
600 | fc->first_write_done = GNUNET_YES; | ||
522 | if (numberOfBytesSent < fc->client_to_service_bufferDataLength) | 601 | if (numberOfBytesSent < fc->client_to_service_bufferDataLength) |
523 | { | 602 | { |
524 | fc->client_to_service_bufferPos += numberOfBytesSent; | 603 | fc->client_to_service_bufferPos += numberOfBytesSent; |
@@ -591,11 +670,12 @@ receiveFromClient (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
591 | "Received %d bytes for service\n", | 670 | "Received %d bytes for service\n", |
592 | fc->client_to_service_bufferDataLength); | 671 | fc->client_to_service_bufferDataLength); |
593 | #endif | 672 | #endif |
594 | fc->client_to_service_task = | 673 | if (fc->armServiceSocket != NULL) |
595 | GNUNET_SCHEDULER_add_write_net (scheduler, | 674 | fc->client_to_service_task = |
596 | GNUNET_TIME_UNIT_FOREVER_REL, | 675 | GNUNET_SCHEDULER_add_write_net (scheduler, |
597 | fc->armServiceSocket, | 676 | GNUNET_TIME_UNIT_FOREVER_REL, |
598 | &forwardToService, fc); | 677 | fc->armServiceSocket, |
678 | &forwardToService, fc); | ||
599 | } | 679 | } |
600 | 680 | ||
601 | 681 | ||
@@ -619,6 +699,14 @@ start_forwarding (void *cls, | |||
619 | return; | 699 | return; |
620 | } | 700 | } |
621 | rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); | 701 | rem = GNUNET_TIME_absolute_get_remaining (fc->timeout); |
702 | if (rem.value == 0) | ||
703 | { | ||
704 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
705 | _("Unable to forward to service `%s': timeout before connect\n"), | ||
706 | fc->listen_info->serviceName); | ||
707 | closeClientAndServiceSockets (fc, REASON_ERROR); | ||
708 | return; | ||
709 | } | ||
622 | fc->armServiceSocket = | 710 | fc->armServiceSocket = |
623 | GNUNET_NETWORK_socket_create (fc->listen_info->service_addr->sa_family, | 711 | GNUNET_NETWORK_socket_create (fc->listen_info->service_addr->sa_family, |
624 | SOCK_STREAM, 0); | 712 | SOCK_STREAM, 0); |
@@ -631,85 +719,69 @@ start_forwarding (void *cls, | |||
631 | closeClientAndServiceSockets (fc, REASON_ERROR); | 719 | closeClientAndServiceSockets (fc, REASON_ERROR); |
632 | return; | 720 | return; |
633 | } | 721 | } |
634 | if ((GNUNET_SYSERR == | 722 | if ( (GNUNET_SYSERR == |
635 | GNUNET_NETWORK_socket_connect (fc->armServiceSocket, | 723 | GNUNET_NETWORK_socket_connect (fc->armServiceSocket, |
636 | fc->listen_info->service_addr, | 724 | fc->listen_info->service_addr, |
637 | fc->listen_info->service_addr_len)) && | 725 | fc->listen_info->service_addr_len)) && |
638 | (EINPROGRESS != errno) ) | 726 | (errno != EINPROGRESS) ) |
639 | { | 727 | { |
640 | if (rem.value == 0) | 728 | GNUNET_NETWORK_socket_close (fc->armServiceSocket); |
641 | { | 729 | fc->armServiceSocket = NULL; |
642 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
643 | _("Unable to forward to service `%s': timeout before connect\n"), | ||
644 | fc->listen_info->serviceName); | ||
645 | closeClientAndServiceSockets (fc, REASON_ERROR); | ||
646 | return; | ||
647 | } | ||
648 | fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2); | 730 | fc->back_off = GNUNET_TIME_relative_multiply (fc->back_off, 2); |
731 | #if DEBUG_SERVICE_MANAGER | ||
732 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | ||
733 | "Failed to connected to service `%s' at `%s', will try again in %llu ms\n", | ||
734 | fc->listen_info->serviceName, | ||
735 | GNUNET_a2s (fc->listen_info->service_addr, | ||
736 | fc->listen_info->service_addr_len), | ||
737 | (unsigned long long) GNUNET_TIME_relative_min (fc->back_off, | ||
738 | rem).value); | ||
739 | #endif | ||
649 | GNUNET_SCHEDULER_add_delayed (scheduler, | 740 | GNUNET_SCHEDULER_add_delayed (scheduler, |
650 | GNUNET_TIME_relative_min (fc->back_off, | 741 | GNUNET_TIME_relative_min (fc->back_off, |
651 | rem), | 742 | rem), |
652 | &start_forwarding, | 743 | &start_forwarding, |
653 | fc); | 744 | fc); |
745 | return; | ||
654 | } | 746 | } |
655 | #if DEBUG_SERVICE_MANAGER | 747 | #if DEBUG_SERVICE_MANAGER |
656 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 748 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
657 | "Connected to service, now starting forwarding\n"); | 749 | "Connected to service, now starting forwarding\n"); |
658 | #endif | 750 | #endif |
659 | fc->client_to_service_task = | 751 | if (fc->client_to_service_task == GNUNET_SCHEDULER_NO_TASK) |
660 | GNUNET_SCHEDULER_add_read_net (scheduler, | ||
661 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
662 | fc->armClientSocket, | ||
663 | &receiveFromClient, fc); | ||
664 | fc->service_to_client_task = | ||
665 | GNUNET_SCHEDULER_add_read_net (scheduler, | ||
666 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
667 | fc->armServiceSocket, | ||
668 | &receiveFromService, fc); | ||
669 | } | ||
670 | |||
671 | |||
672 | /** | ||
673 | * ARM connects to the just created service, | ||
674 | * starts the processes for relaying messages between the client and the service | ||
675 | * | ||
676 | * @param cls callback data, struct ForwardedConnection for the communication between client and service | ||
677 | * @param tc context | ||
678 | */ | ||
679 | static void | ||
680 | connectToService (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | ||
681 | { | ||
682 | struct ForwardedConnection *fc = cls; | ||
683 | |||
684 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) | ||
685 | { | 752 | { |
686 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 753 | if (fc->client_to_service_bufferDataLength == 0) |
687 | _("Unable to start service `%s': shutdown\n"), | 754 | fc->client_to_service_task = |
688 | fc->listen_info->serviceName); | 755 | GNUNET_SCHEDULER_add_read_net (scheduler, |
689 | closeClientAndServiceSockets (fc, | 756 | GNUNET_TIME_UNIT_FOREVER_REL, |
690 | (REASON_CLIENT_TO_SERVICE & REASON_SERVICE_TO_CLIENT)); | 757 | fc->armClientSocket, |
691 | return; | 758 | &receiveFromClient, fc); |
759 | else | ||
760 | fc->client_to_service_task = | ||
761 | GNUNET_SCHEDULER_add_write_net (scheduler, | ||
762 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
763 | fc->armServiceSocket, | ||
764 | &forwardToService, fc); | ||
692 | } | 765 | } |
693 | if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_TIMEOUT)) | 766 | if (fc->service_to_client_task == GNUNET_SCHEDULER_NO_TASK) |
694 | { | 767 | { |
695 | /* Service is not up. Unable to proceed */ | 768 | if (fc->service_to_client_bufferDataLength == 0) |
696 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 769 | fc->service_to_client_task = |
697 | _("Unable to start service `%s': timeout\n"), | 770 | GNUNET_SCHEDULER_add_read_net (scheduler, |
698 | fc->listen_info->serviceName); | 771 | GNUNET_TIME_UNIT_FOREVER_REL, |
699 | closeClientAndServiceSockets (fc, | 772 | fc->armServiceSocket, |
700 | (REASON_CLIENT_TO_SERVICE & REASON_SERVICE_TO_CLIENT)); | 773 | &receiveFromService, fc); |
701 | return; | 774 | else |
775 | fc->service_to_client_task = | ||
776 | GNUNET_SCHEDULER_add_write_net (scheduler, | ||
777 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
778 | fc->armClientSocket, | ||
779 | &forwardToClient, fc); | ||
702 | } | 780 | } |
703 | GNUNET_break (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | ||
704 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | ||
705 | _("Service `%s' started\n"), | ||
706 | fc->listen_info->serviceName); | ||
707 | fc->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_SERVICE_TIMEOUT); | ||
708 | fc->back_off = GNUNET_TIME_UNIT_MILLISECONDS; | ||
709 | start_forwarding (fc, NULL); | ||
710 | } | 781 | } |
711 | 782 | ||
712 | 783 | ||
784 | |||
713 | /** | 785 | /** |
714 | * | 786 | * |
715 | */ | 787 | */ |
@@ -728,7 +800,8 @@ stop_listening (const char *serviceName) | |||
728 | if ( (serviceName != NULL) && | 800 | if ( (serviceName != NULL) && |
729 | (strcmp (pos->serviceName, serviceName) != 0) ) | 801 | (strcmp (pos->serviceName, serviceName) != 0) ) |
730 | continue; | 802 | continue; |
731 | GNUNET_SCHEDULER_cancel (scheduler, pos->acceptTask); | 803 | if (pos->acceptTask != GNUNET_SCHEDULER_NO_TASK) |
804 | GNUNET_SCHEDULER_cancel (scheduler, pos->acceptTask); | ||
732 | GNUNET_break (GNUNET_OK == | 805 | GNUNET_break (GNUNET_OK == |
733 | GNUNET_NETWORK_socket_close (pos->listeningSocket)); | 806 | GNUNET_NETWORK_socket_close (pos->listeningSocket)); |
734 | GNUNET_CONTAINER_DLL_remove (serviceListeningInfoList_head, | 807 | GNUNET_CONTAINER_DLL_remove (serviceListeningInfoList_head, |
@@ -788,12 +861,17 @@ acceptConnection (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
788 | serviceListeningInfoList_tail, | 861 | serviceListeningInfoList_tail, |
789 | serviceListeningInfo); | 862 | serviceListeningInfo); |
790 | start_service (NULL, serviceListeningInfo->serviceName); | 863 | start_service (NULL, serviceListeningInfo->serviceName); |
791 | GNUNET_CLIENT_service_test (scheduler, | 864 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, |
792 | serviceListeningInfo->serviceName, | 865 | _("Service `%s' started\n"), |
793 | cfg, | 866 | fc->listen_info->serviceName); |
794 | TIMEOUT, | 867 | fc->timeout = GNUNET_TIME_relative_to_absolute (GNUNET_CONSTANTS_SERVICE_TIMEOUT); |
795 | &connectToService, | 868 | fc->back_off = GNUNET_TIME_UNIT_MILLISECONDS; |
796 | fc); | 869 | fc->client_to_service_task = |
870 | GNUNET_SCHEDULER_add_read_net (scheduler, | ||
871 | GNUNET_TIME_UNIT_FOREVER_REL, | ||
872 | fc->armClientSocket, | ||
873 | &receiveFromClient, fc); | ||
874 | start_forwarding (fc, NULL); | ||
797 | } | 875 | } |
798 | 876 | ||
799 | 877 | ||
@@ -914,7 +992,7 @@ checkPortNumberCB (void *cls, | |||
914 | if (0 >= (ret = GNUNET_SERVICE_get_server_addresses (section, cfg, &addrs, | 992 | if (0 >= (ret = GNUNET_SERVICE_get_server_addresses (section, cfg, &addrs, |
915 | &addr_lens))) | 993 | &addr_lens))) |
916 | return; | 994 | return; |
917 | /* this will free (or capture) addrs[i] for i in 0..ret */ | 995 | /* this will free (or capture) addrs[i] */ |
918 | for (i = 0; i < ret; i++) | 996 | for (i = 0; i < ret; i++) |
919 | createListeningSocket (addrs[i], addr_lens[i], section); | 997 | createListeningSocket (addrs[i], addr_lens[i], section); |
920 | GNUNET_free (addrs); | 998 | GNUNET_free (addrs); |
diff --git a/src/arm/test_arm_api_data.conf b/src/arm/test_arm_api_data.conf index 8ab08247c..29ef6e4a7 100644 --- a/src/arm/test_arm_api_data.conf +++ b/src/arm/test_arm_api_data.conf | |||
@@ -13,7 +13,7 @@ OPTIONS = -L ERROR | |||
13 | [resolver] | 13 | [resolver] |
14 | # DEBUG = YES | 14 | # DEBUG = YES |
15 | PORT = 23355 | 15 | PORT = 23355 |
16 | 16 | # PREFIX = valgrind | |
17 | 17 | ||
18 | [do-nothing] | 18 | [do-nothing] |
19 | #DEBUG = YES | 19 | #DEBUG = YES |
diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index 0ff0ebdad..e20ccd53e 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c | |||
@@ -120,8 +120,10 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
120 | } | 120 | } |
121 | else if ((msg == NULL) && (shutdown_ctx->confirmed == GNUNET_YES)) | 121 | else if ((msg == NULL) && (shutdown_ctx->confirmed == GNUNET_YES)) |
122 | { | 122 | { |
123 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 123 | #if VERBOSE |
124 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
124 | "Service shutdown complete.\n"); | 125 | "Service shutdown complete.\n"); |
126 | #endif | ||
125 | if (shutdown_ctx->cont != NULL) | 127 | if (shutdown_ctx->cont != NULL) |
126 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO); | 128 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_NO); |
127 | 129 | ||
@@ -135,8 +137,10 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
135 | switch (ntohs(msg->type)) | 137 | switch (ntohs(msg->type)) |
136 | { | 138 | { |
137 | case GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK: | 139 | case GNUNET_MESSAGE_TYPE_ARM_SHUTDOWN_ACK: |
138 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | 140 | #if VERBOSE |
141 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, | ||
139 | "Received confirmation for service shutdown.\n"); | 142 | "Received confirmation for service shutdown.\n"); |
143 | #endif | ||
140 | shutdown_ctx->confirmed = GNUNET_YES; | 144 | shutdown_ctx->confirmed = GNUNET_YES; |
141 | GNUNET_CLIENT_receive (shutdown_ctx->sock, | 145 | GNUNET_CLIENT_receive (shutdown_ctx->sock, |
142 | &service_shutdown_handler, | 146 | &service_shutdown_handler, |