diff options
Diffstat (limited to 'src/testing/testing_api_cmd_netjail_stop.c')
-rw-r--r-- | src/testing/testing_api_cmd_netjail_stop.c | 45 |
1 files changed, 11 insertions, 34 deletions
diff --git a/src/testing/testing_api_cmd_netjail_stop.c b/src/testing/testing_api_cmd_netjail_stop.c index c93e5cca3..8c78b5e93 100644 --- a/src/testing/testing_api_cmd_netjail_stop.c +++ b/src/testing/testing_api_cmd_netjail_stop.c | |||
@@ -39,6 +39,11 @@ struct GNUNET_ChildWaitHandle *cwh; | |||
39 | */ | 39 | */ |
40 | struct NetJailState | 40 | struct NetJailState |
41 | { | 41 | { |
42 | /** | ||
43 | * Context for our asynchronous completion. | ||
44 | */ | ||
45 | struct GNUNET_TESTING_AsyncContext ac; | ||
46 | |||
42 | // Number of local nodes in each namespace. | 47 | // Number of local nodes in each namespace. |
43 | char *local_m; | 48 | char *local_m; |
44 | 49 | ||
@@ -50,8 +55,6 @@ struct NetJailState | |||
50 | */ | 55 | */ |
51 | struct GNUNET_OS_Process *stop_proc; | 56 | struct GNUNET_OS_Process *stop_proc; |
52 | 57 | ||
53 | // Flag indication if the script finished. | ||
54 | unsigned int finished; | ||
55 | }; | 58 | }; |
56 | 59 | ||
57 | 60 | ||
@@ -108,16 +111,17 @@ child_completed_callback (void *cls, | |||
108 | struct NetJailState *ns = cls; | 111 | struct NetJailState *ns = cls; |
109 | 112 | ||
110 | cwh = NULL; | 113 | cwh = NULL; |
114 | GNUNET_OS_process_destroy (ns->stop_proc); | ||
115 | ns->stop_proc = NULL; | ||
111 | if (0 == exit_code) | 116 | if (0 == exit_code) |
112 | { | 117 | { |
113 | ns->finished = GNUNET_YES; | 118 | GNUNET_TESTING_async_finish (&ns->ac); |
114 | } | 119 | } |
115 | else | 120 | else |
116 | { | 121 | { |
117 | ns->finished = GNUNET_SYSERR; | 122 | // FIXME: log exit code! |
123 | GNUNET_TESTING_async_fail (&ns->ac); | ||
118 | } | 124 | } |
119 | GNUNET_OS_process_destroy (ns->stop_proc); | ||
120 | ns->stop_proc = NULL; | ||
121 | } | 125 | } |
122 | 126 | ||
123 | 127 | ||
@@ -174,33 +178,6 @@ netjail_stop_run (void *cls, | |||
174 | } | 178 | } |
175 | 179 | ||
176 | 180 | ||
177 | /** | ||
178 | * This function checks the flag NetJailState#finished, if this cmd finished. | ||
179 | * | ||
180 | */ | ||
181 | static enum GNUNET_GenericReturnValue | ||
182 | netjail_stop_finish (void *cls, | ||
183 | GNUNET_SCHEDULER_TaskCallback cont, | ||
184 | void *cont_cls) | ||
185 | { | ||
186 | struct NetJailState *ns = cls; | ||
187 | |||
188 | if (ns->finished) | ||
189 | { | ||
190 | cont (cont_cls); | ||
191 | } | ||
192 | return ns->finished; | ||
193 | } | ||
194 | |||
195 | |||
196 | /** | ||
197 | * Create command. | ||
198 | * | ||
199 | * @param label name for command. | ||
200 | * @param local_m Number of local nodes in each namespace. | ||
201 | * @param global_n The number of namespaces. | ||
202 | * @return command. | ||
203 | */ | ||
204 | struct GNUNET_TESTING_Command | 181 | struct GNUNET_TESTING_Command |
205 | GNUNET_TESTING_cmd_netjail_stop (const char *label, | 182 | GNUNET_TESTING_cmd_netjail_stop (const char *label, |
206 | char *local_m, | 183 | char *local_m, |
@@ -216,7 +193,7 @@ GNUNET_TESTING_cmd_netjail_stop (const char *label, | |||
216 | .cls = ns, | 193 | .cls = ns, |
217 | .label = label, | 194 | .label = label, |
218 | .run = &netjail_stop_run, | 195 | .run = &netjail_stop_run, |
219 | .finish = &netjail_stop_finish, | 196 | .ac = &ns->ac, |
220 | .cleanup = &netjail_stop_cleanup, | 197 | .cleanup = &netjail_stop_cleanup, |
221 | .traits = &netjail_stop_traits | 198 | .traits = &netjail_stop_traits |
222 | }; | 199 | }; |