diff options
author | Christian Grothoff <christian@grothoff.org> | 2010-05-11 12:44:35 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2010-05-11 12:44:35 +0000 |
commit | ae2f377aab457ebc51fe2873e11dd86a5abebad6 (patch) | |
tree | d40210697e63db1ed3eb3a9d741aa757d2fd28b6 /src | |
parent | 84cefefab29eba51ff056db7b87edaff000ac98e (diff) | |
download | gnunet-ae2f377aab457ebc51fe2873e11dd86a5abebad6.tar.gz gnunet-ae2f377aab457ebc51fe2873e11dd86a5abebad6.zip |
cleanup
Diffstat (limited to 'src')
-rw-r--r-- | src/util/client.c | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/util/client.c b/src/util/client.c index 8e27a4a71..588957d85 100644 --- a/src/util/client.c +++ b/src/util/client.c | |||
@@ -599,12 +599,13 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
599 | { | 599 | { |
600 | struct ShutdownContext *shutdown_ctx = cls; | 600 | struct ShutdownContext *shutdown_ctx = cls; |
601 | 601 | ||
602 | if ((msg == NULL) && (shutdown_ctx->confirmed != GNUNET_YES)) /* Means the other side closed the connection and never confirmed a shutdown */ | 602 | if ((msg == NULL) && (shutdown_ctx->confirmed != GNUNET_YES)) |
603 | { | 603 | { |
604 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Service handle shutdown before ACK!\n"); | 604 | /* Means the other side closed the connection and never confirmed a shutdown */ |
605 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, | ||
606 | "Service handle shutdown before ACK!\n"); | ||
605 | if (shutdown_ctx->cont != NULL) | 607 | if (shutdown_ctx->cont != NULL) |
606 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); | 608 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); |
607 | |||
608 | GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->cancel_task); | 609 | GNUNET_SCHEDULER_cancel(shutdown_ctx->sched, shutdown_ctx->cancel_task); |
609 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); | 610 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); |
610 | GNUNET_free(shutdown_ctx); | 611 | GNUNET_free(shutdown_ctx); |
@@ -626,13 +627,18 @@ service_shutdown_handler (void *cls, const struct GNUNET_MessageHeader *msg) | |||
626 | switch (ntohs(msg->type)) | 627 | switch (ntohs(msg->type)) |
627 | { | 628 | { |
628 | case GNUNET_MESSAGE_TYPE_SHUTDOWN_ACK: | 629 | case GNUNET_MESSAGE_TYPE_SHUTDOWN_ACK: |
629 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Received confirmation for service shutdown.\n"); | 630 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
631 | "Received confirmation for service shutdown.\n"); | ||
630 | shutdown_ctx->confirmed = GNUNET_YES; | 632 | shutdown_ctx->confirmed = GNUNET_YES; |
631 | GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); | 633 | GNUNET_CLIENT_receive (shutdown_ctx->sock, |
634 | &service_shutdown_handler, | ||
635 | shutdown_ctx, | ||
636 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
632 | break; | 637 | break; |
633 | case GNUNET_MESSAGE_TYPE_SHUTDOWN_REFUSE: | 638 | case GNUNET_MESSAGE_TYPE_SHUTDOWN_REFUSE: |
634 | default: /* Fall through */ | 639 | default: /* Fall through */ |
635 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, "Service shutdown refused!\n"); | 640 | GNUNET_log(GNUNET_ERROR_TYPE_WARNING, |
641 | "Service shutdown refused!\n"); | ||
636 | if (shutdown_ctx->cont != NULL) | 642 | if (shutdown_ctx->cont != NULL) |
637 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES); | 643 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_YES); |
638 | 644 | ||
@@ -659,6 +665,8 @@ void service_shutdown_cancel (void *cls, | |||
659 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); | 665 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); |
660 | GNUNET_free(shutdown_ctx); | 666 | GNUNET_free(shutdown_ctx); |
661 | } | 667 | } |
668 | |||
669 | |||
662 | /** | 670 | /** |
663 | * If possible, write a shutdown message to the target | 671 | * If possible, write a shutdown message to the target |
664 | * buffer and destroy the client connection. | 672 | * buffer and destroy the client connection. |
@@ -676,17 +684,21 @@ write_shutdown (void *cls, size_t size, void *buf) | |||
676 | 684 | ||
677 | if (size < sizeof (struct GNUNET_MessageHeader)) | 685 | if (size < sizeof (struct GNUNET_MessageHeader)) |
678 | { | 686 | { |
679 | GNUNET_log (GNUNET_ERROR_TYPE_INFO, | 687 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, |
680 | _("Failed to transmit shutdown request to client.\n")); | 688 | _("Failed to transmit shutdown request to client.\n")); |
681 | |||
682 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); | 689 | shutdown_ctx->cont(shutdown_ctx->cont_cls, GNUNET_SYSERR); |
683 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); | 690 | GNUNET_CLIENT_disconnect (shutdown_ctx->sock, GNUNET_NO); |
684 | GNUNET_free(shutdown_ctx); | 691 | GNUNET_free(shutdown_ctx); |
685 | return 0; /* client disconnected */ | 692 | return 0; /* client disconnected */ |
686 | } | 693 | } |
687 | 694 | ||
688 | GNUNET_CLIENT_receive (shutdown_ctx->sock, &service_shutdown_handler, shutdown_ctx, GNUNET_TIME_UNIT_FOREVER_REL); | 695 | GNUNET_CLIENT_receive (shutdown_ctx->sock, |
689 | shutdown_ctx->cancel_task = GNUNET_SCHEDULER_add_delayed (shutdown_ctx->sched, GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout), &service_shutdown_cancel, shutdown_ctx); | 696 | &service_shutdown_handler, shutdown_ctx, |
697 | GNUNET_TIME_UNIT_FOREVER_REL); | ||
698 | shutdown_ctx->cancel_task = GNUNET_SCHEDULER_add_delayed (shutdown_ctx->sched, | ||
699 | GNUNET_TIME_absolute_get_remaining(shutdown_ctx->timeout), | ||
700 | &service_shutdown_cancel, | ||
701 | shutdown_ctx); | ||
690 | msg = (struct GNUNET_MessageHeader *) buf; | 702 | msg = (struct GNUNET_MessageHeader *) buf; |
691 | msg->type = htons (GNUNET_MESSAGE_TYPE_SHUTDOWN); | 703 | msg->type = htons (GNUNET_MESSAGE_TYPE_SHUTDOWN); |
692 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); | 704 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); |
@@ -722,7 +734,6 @@ GNUNET_CLIENT_service_shutdown (struct GNUNET_SCHEDULER_Handle *sched, | |||
722 | shutdown_ctx->cont_cls = cont_cls; | 734 | shutdown_ctx->cont_cls = cont_cls; |
723 | shutdown_ctx->sock = sock; | 735 | shutdown_ctx->sock = sock; |
724 | shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute(timeout); | 736 | shutdown_ctx->timeout = GNUNET_TIME_relative_to_absolute(timeout); |
725 | |||
726 | GNUNET_CONNECTION_notify_transmit_ready (sock->sock, | 737 | GNUNET_CONNECTION_notify_transmit_ready (sock->sock, |
727 | sizeof (struct | 738 | sizeof (struct |
728 | GNUNET_MessageHeader), | 739 | GNUNET_MessageHeader), |
@@ -790,6 +801,7 @@ write_test (void *cls, size_t size, void *buf) | |||
790 | _("Failure to transmit TEST request.\n")); | 801 | _("Failure to transmit TEST request.\n")); |
791 | #endif | 802 | #endif |
792 | service_test_error (conn->sched, conn->test_cb, conn->test_cb_cls); | 803 | service_test_error (conn->sched, conn->test_cb, conn->test_cb_cls); |
804 | GNUNET_CLIENT_disconnect (conn, GNUNET_NO); | ||
793 | return 0; /* client disconnected */ | 805 | return 0; /* client disconnected */ |
794 | } | 806 | } |
795 | #if DEBUG_CLIENT | 807 | #if DEBUG_CLIENT |