aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_service.c
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2018-01-04 16:46:18 +0100
committerChristian Grothoff <christian@grothoff.org>2018-01-04 16:46:18 +0100
commite20eca334a33b8340524a8fa6ad1d6b606e1dd0c (patch)
treee79ce20f787cae4aea7403d2e9c9b8fb2546ad1f /src/util/test_service.c
parent056ca89d207cd1865a90fe3fcd430a4381097da5 (diff)
downloadgnunet-e20eca334a33b8340524a8fa6ad1d6b606e1dd0c.tar.gz
gnunet-e20eca334a33b8340524a8fa6ad1d6b606e1dd0c.zip
fix timeout of test_service, misc signed/unsigned and unused argument issues
Diffstat (limited to 'src/util/test_service.c')
-rw-r--r--src/util/test_service.c27
1 files changed, 26 insertions, 1 deletions
diff --git a/src/util/test_service.c b/src/util/test_service.c
index 1567c97ce..3ffacb0a9 100644
--- a/src/util/test_service.c
+++ b/src/util/test_service.c
@@ -30,10 +30,17 @@
30 */ 30 */
31#define MY_TYPE 256 31#define MY_TYPE 256
32 32
33#define TIMEOUT GNUNET_TIME_UNIT_SECONDS
34
33static int global_ret = 1; 35static int global_ret = 1;
34 36
35static struct GNUNET_MQ_Handle *mq; 37static struct GNUNET_MQ_Handle *mq;
36 38
39/**
40 * Timeout task.
41 */
42static struct GNUNET_SCHEDULER_Task *tt;
43
37 44
38static void 45static void
39handle_recv (void *cls, 46handle_recv (void *cls,
@@ -86,10 +93,24 @@ disconnect_cb (void *cls,
86 { 93 {
87 GNUNET_SCHEDULER_shutdown (); 94 GNUNET_SCHEDULER_shutdown ();
88 global_ret = 0; 95 global_ret = 0;
96 if (NULL != tt)
97 {
98 GNUNET_SCHEDULER_cancel (tt);
99 tt = NULL;
100 }
89 } 101 }
90} 102}
91 103
92 104
105static void
106timeout_task (void *cls)
107{
108 tt = NULL;
109 global_ret = 33;
110 GNUNET_SCHEDULER_shutdown ();
111}
112
113
93/** 114/**
94 * Initialization function of the service. Starts 115 * Initialization function of the service. Starts
95 * a client to connect to the service. 116 * a client to connect to the service.
@@ -106,7 +127,11 @@ service_init (void *cls,
106 const char *service_name = cls; 127 const char *service_name = cls;
107 struct GNUNET_MQ_Envelope *env; 128 struct GNUNET_MQ_Envelope *env;
108 struct GNUNET_MessageHeader *msg; 129 struct GNUNET_MessageHeader *msg;
109 130
131 GNUNET_assert (NULL == tt);
132 tt = GNUNET_SCHEDULER_add_delayed (TIMEOUT,
133 &timeout_task,
134 NULL);
110 mq = GNUNET_CLIENT_connect (cfg, 135 mq = GNUNET_CLIENT_connect (cfg,
111 service_name, 136 service_name,
112 NULL, 137 NULL,