diff options
Diffstat (limited to 'src/util/test_service.c')
-rw-r--r-- | src/util/test_service.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/util/test_service.c b/src/util/test_service.c index 6c78a4eb9..9bd58352b 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c | |||
@@ -37,8 +37,6 @@ | |||
37 | 37 | ||
38 | #define MY_TYPE 256 | 38 | #define MY_TYPE 256 |
39 | 39 | ||
40 | static struct GNUNET_SCHEDULER_Handle *sched; | ||
41 | |||
42 | static struct GNUNET_SERVICE_Context *sctx; | 40 | static struct GNUNET_SERVICE_Context *sctx; |
43 | 41 | ||
44 | static int ok = 1; | 42 | static int ok = 1; |
@@ -67,8 +65,7 @@ ready (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
67 | 65 | ||
68 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | 66 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); |
69 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service confirmed running\n"); | 67 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service confirmed running\n"); |
70 | sched = tc->sched; | 68 | client = GNUNET_CLIENT_connect ("test_service", cfg); |
71 | client = GNUNET_CLIENT_connect (tc->sched, "test_service", cfg); | ||
72 | GNUNET_assert (client != NULL); | 69 | GNUNET_assert (client != NULL); |
73 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 70 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
74 | "Client connecting, waiting to transmit\n"); | 71 | "Client connecting, waiting to transmit\n"); |
@@ -94,9 +91,9 @@ recv_cb (void *cls, | |||
94 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); | 91 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Receiving client message...\n"); |
95 | GNUNET_SERVER_receive_done (client, GNUNET_OK); | 92 | GNUNET_SERVER_receive_done (client, GNUNET_OK); |
96 | if (sctx != NULL) | 93 | if (sctx != NULL) |
97 | GNUNET_SCHEDULER_add_now (sched, &do_stop, NULL); | 94 | GNUNET_SCHEDULER_add_now (&do_stop, NULL); |
98 | else | 95 | else |
99 | GNUNET_SCHEDULER_shutdown (sched); | 96 | GNUNET_SCHEDULER_shutdown (); |
100 | ok = 0; | 97 | ok = 0; |
101 | } | 98 | } |
102 | 99 | ||
@@ -110,14 +107,12 @@ static struct GNUNET_SERVER_MessageHandler myhandlers[] = { | |||
110 | 107 | ||
111 | static void | 108 | static void |
112 | runner (void *cls, | 109 | runner (void *cls, |
113 | struct GNUNET_SCHEDULER_Handle *sched, | ||
114 | struct GNUNET_SERVER_Handle *server, | 110 | struct GNUNET_SERVER_Handle *server, |
115 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 111 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
116 | { | 112 | { |
117 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service initializing\n"); | 113 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Service initializing\n"); |
118 | GNUNET_SERVER_add_handlers (server, myhandlers); | 114 | GNUNET_SERVER_add_handlers (server, myhandlers); |
119 | GNUNET_CLIENT_service_test (sched, | 115 | GNUNET_CLIENT_service_test ("test_service", |
120 | "test_service", | ||
121 | cfg, GNUNET_TIME_UNIT_SECONDS, &ready, | 116 | cfg, GNUNET_TIME_UNIT_SECONDS, &ready, |
122 | (void *) cfg); | 117 | (void *) cfg); |
123 | } | 118 | } |
@@ -161,9 +156,8 @@ ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
161 | struct GNUNET_CLIENT_Connection *client; | 156 | struct GNUNET_CLIENT_Connection *client; |
162 | 157 | ||
163 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 ready\n"); | 158 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 ready\n"); |
164 | sched = tc->sched; | ||
165 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); | 159 | GNUNET_assert (0 != (tc->reason & GNUNET_SCHEDULER_REASON_PREREQ_DONE)); |
166 | client = GNUNET_CLIENT_connect (tc->sched, "test_service6", cfg); | 160 | client = GNUNET_CLIENT_connect ("test_service6", cfg); |
167 | GNUNET_assert (client != NULL); | 161 | GNUNET_assert (client != NULL); |
168 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n"); | 162 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "V6 client connected\n"); |
169 | GNUNET_CLIENT_notify_transmit_ready (client, | 163 | GNUNET_CLIENT_notify_transmit_ready (client, |
@@ -174,14 +168,12 @@ ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
174 | 168 | ||
175 | static void | 169 | static void |
176 | runner6 (void *cls, | 170 | runner6 (void *cls, |
177 | struct GNUNET_SCHEDULER_Handle *sched, | ||
178 | struct GNUNET_SERVER_Handle *server, | 171 | struct GNUNET_SERVER_Handle *server, |
179 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 172 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
180 | { | 173 | { |
181 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); | 174 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Initializing v6 service\n"); |
182 | GNUNET_SERVER_add_handlers (server, myhandlers); | 175 | GNUNET_SERVER_add_handlers (server, myhandlers); |
183 | GNUNET_CLIENT_service_test (sched, | 176 | GNUNET_CLIENT_service_test ("test_service6", |
184 | "test_service6", | ||
185 | cfg, GNUNET_TIME_UNIT_SECONDS, &ready6, | 177 | cfg, GNUNET_TIME_UNIT_SECONDS, &ready6, |
186 | (void *) cfg); | 178 | (void *) cfg); |
187 | } | 179 | } |
@@ -220,7 +212,6 @@ check6 () | |||
220 | 212 | ||
221 | static void | 213 | static void |
222 | start_stop_main (void *cls, | 214 | start_stop_main (void *cls, |
223 | struct GNUNET_SCHEDULER_Handle *sched, | ||
224 | char *const *args, | 215 | char *const *args, |
225 | const char *cfgfile, | 216 | const char *cfgfile, |
226 | const struct GNUNET_CONFIGURATION_Handle *cfg) | 217 | const struct GNUNET_CONFIGURATION_Handle *cfg) |
@@ -228,9 +219,9 @@ start_stop_main (void *cls, | |||
228 | int *ret = cls; | 219 | int *ret = cls; |
229 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 220 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
230 | "Starting service using start method\n"); | 221 | "Starting service using start method\n"); |
231 | sctx = GNUNET_SERVICE_start ("test_service", sched, cfg); | 222 | sctx = GNUNET_SERVICE_start ("test_service", cfg); |
232 | GNUNET_assert (NULL != sctx); | 223 | GNUNET_assert (NULL != sctx); |
233 | runner (cls, sched, GNUNET_SERVICE_get_server (sctx), cfg); | 224 | runner (cls, GNUNET_SERVICE_get_server (sctx), cfg); |
234 | *ret = 0; | 225 | *ret = 0; |
235 | } | 226 | } |
236 | 227 | ||