aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2010-02-02 10:25:43 +0000
committerChristian Grothoff <christian@grothoff.org>2010-02-02 10:25:43 +0000
commitba5afc688c7bc8804524290830bd3e473b180b71 (patch)
tree353fb3d36664ef3de1de243a9ce4b93a495fea25 /src
parent7c227e687a03a00e4e87d8319aa5315a839ddd24 (diff)
downloadgnunet-ba5afc688c7bc8804524290830bd3e473b180b71.tar.gz
gnunet-ba5afc688c7bc8804524290830bd3e473b180b71.zip
fixing test service running to retry if service is not running
Diffstat (limited to 'src')
-rw-r--r--src/util/client.c44
-rw-r--r--src/util/service.c5
2 files changed, 23 insertions, 26 deletions
diff --git a/src/util/client.c b/src/util/client.c
index d66ce9ed0..0ebd484e2 100644
--- a/src/util/client.c
+++ b/src/util/client.c
@@ -34,8 +34,7 @@
34#include "gnunet_server_lib.h" 34#include "gnunet_server_lib.h"
35#include "gnunet_scheduler_lib.h" 35#include "gnunet_scheduler_lib.h"
36 36
37#define DEBUG_CLIENT GNUNET_YES 37#define DEBUG_CLIENT GNUNET_NO
38
39 38
40/** 39/**
41 * How often do we re-try tranmsitting requests before giving up? 40 * How often do we re-try tranmsitting requests before giving up?
@@ -195,6 +194,11 @@ struct GNUNET_CLIENT_Connection
195 GNUNET_SCHEDULER_Task test_cb; 194 GNUNET_SCHEDULER_Task test_cb;
196 195
197 /** 196 /**
197 * Deadline for calling 'test_cb'.
198 */
199 struct GNUNET_TIME_Absolute test_deadline;
200
201 /**
198 * If we are re-trying and are delaying to do so, 202 * If we are re-trying and are delaying to do so,
199 * handle to the scheduled task managing the delay. 203 * handle to the scheduled task managing the delay.
200 */ 204 */
@@ -322,6 +326,7 @@ GNUNET_CLIENT_connect (struct GNUNET_SCHEDULER_Handle *sched,
322 return ret; 326 return ret;
323} 327}
324 328
329
325/** 330/**
326 * Configure this connection to ignore shutdown signals. 331 * Configure this connection to ignore shutdown signals.
327 * 332 *
@@ -629,6 +634,7 @@ confirm_handler (void *cls, const struct GNUNET_MessageHeader *msg)
629static size_t 634static size_t
630write_test (void *cls, size_t size, void *buf) 635write_test (void *cls, size_t size, void *buf)
631{ 636{
637 struct GNUNET_CLIENT_Connection *conn = cls;
632 struct GNUNET_MessageHeader *msg; 638 struct GNUNET_MessageHeader *msg;
633 639
634 if (size < sizeof (struct GNUNET_MessageHeader)) 640 if (size < sizeof (struct GNUNET_MessageHeader))
@@ -637,6 +643,7 @@ write_test (void *cls, size_t size, void *buf)
637 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 643 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
638 _("Failure to transmit TEST request.\n")); 644 _("Failure to transmit TEST request.\n"));
639#endif 645#endif
646 service_test_error (conn->sched, conn->test_cb, conn->test_cb_cls);
640 return 0; /* client disconnected */ 647 return 0; /* client disconnected */
641 } 648 }
642#if DEBUG_CLIENT 649#if DEBUG_CLIENT
@@ -646,6 +653,10 @@ write_test (void *cls, size_t size, void *buf)
646 msg = (struct GNUNET_MessageHeader *) buf; 653 msg = (struct GNUNET_MessageHeader *) buf;
647 msg->type = htons (GNUNET_MESSAGE_TYPE_TEST); 654 msg->type = htons (GNUNET_MESSAGE_TYPE_TEST);
648 msg->size = htons (sizeof (struct GNUNET_MessageHeader)); 655 msg->size = htons (sizeof (struct GNUNET_MessageHeader));
656 GNUNET_CLIENT_receive (conn,
657 &confirm_handler,
658 conn,
659 GNUNET_TIME_absolute_get_remaining (conn->test_deadline));
649 return sizeof (struct GNUNET_MessageHeader); 660 return sizeof (struct GNUNET_MessageHeader);
650} 661}
651 662
@@ -687,20 +698,13 @@ GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched,
687 } 698 }
688 conn->test_cb = task; 699 conn->test_cb = task;
689 conn->test_cb_cls = task_cls; 700 conn->test_cb_cls = task_cls;
690 701 conn->test_deadline = GNUNET_TIME_relative_to_absolute (timeout);
691 702
692 if (NULL == GNUNET_CLIENT_notify_transmit_ready (conn, 703 if (NULL == GNUNET_CLIENT_notify_transmit_ready (conn,
693 sizeof (struct GNUNET_MessageHeader), 704 sizeof (struct GNUNET_MessageHeader),
694 timeout, 705 timeout,
695 GNUNET_YES, 706 GNUNET_YES,
696 &write_test, NULL)) 707 &write_test, conn))
697 /*
698 if (NULL ==
699 GNUNET_CONNECTION_notify_transmit_ready (conn->sock,
700 sizeof (struct
701 GNUNET_MessageHeader),
702 timeout, &write_test, NULL))
703 */
704 { 708 {
705 GNUNET_log (GNUNET_ERROR_TYPE_WARNING, 709 GNUNET_log (GNUNET_ERROR_TYPE_WARNING,
706 _("Failure to transmit request to service `%s'\n"), 710 _("Failure to transmit request to service `%s'\n"),
@@ -709,7 +713,6 @@ GNUNET_CLIENT_service_test (struct GNUNET_SCHEDULER_Handle *sched,
709 GNUNET_CLIENT_disconnect (conn); 713 GNUNET_CLIENT_disconnect (conn);
710 return; 714 return;
711 } 715 }
712 GNUNET_CLIENT_receive (conn, &confirm_handler, conn, timeout);
713} 716}
714 717
715 718
@@ -739,7 +742,6 @@ client_delayed_retry (void *cls,
739{ 742{
740 struct GNUNET_CLIENT_TransmitHandle *th = cls; 743 struct GNUNET_CLIENT_TransmitHandle *th = cls;
741 744
742 fprintf (stderr, "cdr running\n");
743 th->reconnect_task = GNUNET_SCHEDULER_NO_TASK; 745 th->reconnect_task = GNUNET_SCHEDULER_NO_TASK;
744 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN)) 746 if (0 != (tc->reason & GNUNET_SCHEDULER_REASON_SHUTDOWN))
745 { 747 {
@@ -768,9 +770,8 @@ client_delayed_retry (void *cls,
768 770
769 771
770/** 772/**
771 * Connection notifies us about failure or success of 773 * Connection notifies us about failure or success of a transmission
772 * a transmission request. Either pass it on to our 774 * request. Either pass it on to our user or, if possible, retry.
773 * user or, if possible, retry.
774 * 775 *
775 * @param cls our "struct GNUNET_CLIENT_TransmissionHandle" 776 * @param cls our "struct GNUNET_CLIENT_TransmissionHandle"
776 * @param size number of bytes available for transmission 777 * @param size number of bytes available for transmission
@@ -795,11 +796,6 @@ client_notify (void *cls, size_t size, void *buf)
795 (0 == --th->attempts_left) || 796 (0 == --th->attempts_left) ||
796 (delay.value < 1) ) 797 (delay.value < 1) )
797 { 798 {
798 fprintf (stderr, "Signaling timeout, reason: %d %d %d %d\n",
799 (0 != (GNUNET_SCHEDULER_REASON_SHUTDOWN & GNUNET_SCHEDULER_get_reason (th->sock->sched))),
800 (GNUNET_YES != th->auto_retry),
801 (0 == --th->attempts_left) ,
802 (delay.value < 1) );
803#if DEBUG_CLIENT 799#if DEBUG_CLIENT
804 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, 800 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
805 "Transmission failed %u times, giving up.\n", 801 "Transmission failed %u times, giving up.\n",
diff --git a/src/util/service.c b/src/util/service.c
index f64734b8f..aa07eecde 100644
--- a/src/util/service.c
+++ b/src/util/service.c
@@ -1452,8 +1452,9 @@ shutdown:
1452 1452
1453 GNUNET_CONFIGURATION_destroy (cfg); 1453 GNUNET_CONFIGURATION_destroy (cfg);
1454 i = 0; 1454 i = 0;
1455 while (sctx.addrs[i] != NULL) 1455 if (sctx.addrs != NULL)
1456 GNUNET_free (sctx.addrs[i++]); 1456 while (sctx.addrs[i] != NULL)
1457 GNUNET_free (sctx.addrs[i++]);
1457 GNUNET_free_non_null (sctx.addrs); 1458 GNUNET_free_non_null (sctx.addrs);
1458 GNUNET_free_non_null (sctx.addrlens); 1459 GNUNET_free_non_null (sctx.addrlens);
1459 GNUNET_free_non_null (logfile); 1460 GNUNET_free_non_null (logfile);