diff options
Diffstat (limited to 'src/util/test_service.c')
-rw-r--r-- | src/util/test_service.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/util/test_service.c b/src/util/test_service.c index 93cafb4d2..fa35da6e9 100644 --- a/src/util/test_service.c +++ b/src/util/test_service.c | |||
@@ -30,6 +30,7 @@ | |||
30 | #include "gnunet_scheduler_lib.h" | 30 | #include "gnunet_scheduler_lib.h" |
31 | #include "gnunet_time_lib.h" | 31 | #include "gnunet_time_lib.h" |
32 | 32 | ||
33 | |||
33 | #define VERBOSE GNUNET_NO | 34 | #define VERBOSE GNUNET_NO |
34 | 35 | ||
35 | #define PORT 12435 | 36 | #define PORT 12435 |
@@ -40,6 +41,9 @@ static struct GNUNET_SCHEDULER_Handle *sched; | |||
40 | 41 | ||
41 | static struct GNUNET_SERVICE_Context *sctx; | 42 | static struct GNUNET_SERVICE_Context *sctx; |
42 | 43 | ||
44 | static int ok = 1; | ||
45 | |||
46 | |||
43 | static void | 47 | static void |
44 | end_it (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 48 | end_it (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
45 | { | 49 | { |
@@ -47,8 +51,11 @@ end_it (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | |||
47 | 51 | ||
48 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down service\n"); | 52 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Shutting down service\n"); |
49 | GNUNET_CLIENT_service_shutdown (client); | 53 | GNUNET_CLIENT_service_shutdown (client); |
50 | if (sctx != NULL) | 54 | if (sctx != NULL) |
51 | GNUNET_SERVICE_stop (sctx); | 55 | GNUNET_SERVICE_stop (sctx); |
56 | else | ||
57 | GNUNET_SCHEDULER_shutdown (sched); | ||
58 | ok = 0; | ||
52 | } | 59 | } |
53 | 60 | ||
54 | 61 | ||
@@ -63,7 +70,6 @@ build_msg (void *cls, size_t size, void *buf) | |||
63 | msg->type = htons (MY_TYPE); | 70 | msg->type = htons (MY_TYPE); |
64 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); | 71 | msg->size = htons (sizeof (struct GNUNET_MessageHeader)); |
65 | GNUNET_SCHEDULER_add_continuation (sched, | 72 | GNUNET_SCHEDULER_add_continuation (sched, |
66 | GNUNET_YES, | ||
67 | &end_it, | 73 | &end_it, |
68 | client, | 74 | client, |
69 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); | 75 | GNUNET_SCHEDULER_REASON_PREREQ_DONE); |
@@ -103,6 +109,9 @@ static struct GNUNET_SERVER_MessageHandler myhandlers[] = { | |||
103 | {NULL, NULL, 0, 0} | 109 | {NULL, NULL, 0, 0} |
104 | }; | 110 | }; |
105 | 111 | ||
112 | |||
113 | |||
114 | |||
106 | static void | 115 | static void |
107 | runner (void *cls, | 116 | runner (void *cls, |
108 | struct GNUNET_SCHEDULER_Handle *sched, | 117 | struct GNUNET_SCHEDULER_Handle *sched, |
@@ -117,12 +126,6 @@ runner (void *cls, | |||
117 | (void *) cfg); | 126 | (void *) cfg); |
118 | } | 127 | } |
119 | 128 | ||
120 | static void | ||
121 | term (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | ||
122 | { | ||
123 | int *ok = cls; | ||
124 | *ok = 0; | ||
125 | } | ||
126 | 129 | ||
127 | /** | 130 | /** |
128 | * Main method, starts scheduler with task1, | 131 | * Main method, starts scheduler with task1, |
@@ -131,7 +134,7 @@ term (void *cls, const struct GNUNET_CONFIGURATION_Handle *cfg) | |||
131 | static int | 134 | static int |
132 | check () | 135 | check () |
133 | { | 136 | { |
134 | int ok = 1; | 137 | ok = 1; |
135 | char *const argv[] = { | 138 | char *const argv[] = { |
136 | "test_service", | 139 | "test_service", |
137 | "-c", | 140 | "-c", |
@@ -149,12 +152,12 @@ check () | |||
149 | GNUNET_SERVICE_run (5, | 152 | GNUNET_SERVICE_run (5, |
150 | argv, | 153 | argv, |
151 | "test_service", | 154 | "test_service", |
152 | &runner, &ok, &term, &ok)); | 155 | &runner, &ok)); |
153 | GNUNET_assert (0 == ok); | 156 | GNUNET_assert (0 == ok); |
154 | return ok; | 157 | return ok; |
155 | } | 158 | } |
156 | 159 | ||
157 | static void | 160 | static void |
158 | ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) | 161 | ready6 (void *cls, const struct GNUNET_SCHEDULER_TaskContext *tc) |
159 | { | 162 | { |
160 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; | 163 | const struct GNUNET_CONFIGURATION_Handle *cfg = cls; |
@@ -193,7 +196,6 @@ runner6 (void *cls, | |||
193 | static int | 196 | static int |
194 | check6 () | 197 | check6 () |
195 | { | 198 | { |
196 | int ok = 1; | ||
197 | char *const argv[] = { | 199 | char *const argv[] = { |
198 | "test_service6", | 200 | "test_service6", |
199 | "-c", | 201 | "-c", |
@@ -211,7 +213,7 @@ check6 () | |||
211 | GNUNET_SERVICE_run (5, | 213 | GNUNET_SERVICE_run (5, |
212 | argv, | 214 | argv, |
213 | "test_service6", | 215 | "test_service6", |
214 | &runner6, &ok, &term, &ok)); | 216 | &runner6, &ok)); |
215 | GNUNET_assert (0 == ok); | 217 | GNUNET_assert (0 == ok); |
216 | return ok; | 218 | return ok; |
217 | } | 219 | } |
@@ -224,7 +226,7 @@ check6 () | |||
224 | static int | 226 | static int |
225 | check6d () | 227 | check6d () |
226 | { | 228 | { |
227 | int ok = 1; | 229 | ok = 1; |
228 | char *const argv[] = { | 230 | char *const argv[] = { |
229 | "test_service6", | 231 | "test_service6", |
230 | "-c", | 232 | "-c", |
@@ -243,7 +245,7 @@ check6d () | |||
243 | GNUNET_SERVICE_run (6, | 245 | GNUNET_SERVICE_run (6, |
244 | argv, | 246 | argv, |
245 | "test_service6", | 247 | "test_service6", |
246 | &runner6, &ok, &term, &ok)); | 248 | &runner6, &ok)); |
247 | GNUNET_break (0 == ok); | 249 | GNUNET_break (0 == ok); |
248 | return ok; | 250 | return ok; |
249 | } | 251 | } |