diff options
Diffstat (limited to 'src/testing/testing_api_cmd_netjail_stop_v2.c')
-rw-r--r-- | src/testing/testing_api_cmd_netjail_stop_v2.c | 64 |
1 files changed, 13 insertions, 51 deletions
diff --git a/src/testing/testing_api_cmd_netjail_stop_v2.c b/src/testing/testing_api_cmd_netjail_stop_v2.c index 348e8c9f7..a0e2657cb 100644 --- a/src/testing/testing_api_cmd_netjail_stop_v2.c +++ b/src/testing/testing_api_cmd_netjail_stop_v2.c | |||
@@ -40,6 +40,11 @@ static struct GNUNET_ChildWaitHandle *cwh; | |||
40 | struct NetJailState | 40 | struct NetJailState |
41 | { | 41 | { |
42 | /** | 42 | /** |
43 | * Context for our asynchronous completion. | ||
44 | */ | ||
45 | struct GNUNET_TESTING_AsyncContext ac; | ||
46 | |||
47 | /** | ||
43 | * Configuration file for the test topology. | 48 | * Configuration file for the test topology. |
44 | */ | 49 | */ |
45 | char *topology_config; | 50 | char *topology_config; |
@@ -49,8 +54,6 @@ struct NetJailState | |||
49 | */ | 54 | */ |
50 | struct GNUNET_OS_Process *stop_proc; | 55 | struct GNUNET_OS_Process *stop_proc; |
51 | 56 | ||
52 | // Flag indication if the script finished. | ||
53 | enum GNUNET_GenericReturnValue finished; | ||
54 | }; | 57 | }; |
55 | 58 | ||
56 | 59 | ||
@@ -82,20 +85,6 @@ netjail_stop_cleanup (void *cls) | |||
82 | 85 | ||
83 | 86 | ||
84 | /** | 87 | /** |
85 | * Trait function of this cmd does nothing. | ||
86 | * | ||
87 | */ | ||
88 | static enum GNUNET_GenericReturnValue | ||
89 | netjail_stop_traits (void *cls, | ||
90 | const void **ret, | ||
91 | const char *trait, | ||
92 | unsigned int index) | ||
93 | { | ||
94 | return GNUNET_NO; | ||
95 | } | ||
96 | |||
97 | |||
98 | /** | ||
99 | * Callback which will be called if the setup script finished. | 88 | * Callback which will be called if the setup script finished. |
100 | * | 89 | * |
101 | */ | 90 | */ |
@@ -106,17 +95,17 @@ child_completed_callback (void *cls, | |||
106 | { | 95 | { |
107 | struct NetJailState *ns = cls; | 96 | struct NetJailState *ns = cls; |
108 | 97 | ||
109 | cwh = NULL; | 98 | cwh = NULL; // WTF? globals!?!?! |
99 | GNUNET_OS_process_destroy (ns->stop_proc); | ||
100 | ns->stop_proc = NULL; | ||
110 | if (0 == exit_code) | 101 | if (0 == exit_code) |
111 | { | 102 | { |
112 | ns->finished = GNUNET_YES; | 103 | GNUNET_TESTING_async_finish (&ns->ac); |
113 | } | 104 | } |
114 | else | 105 | else |
115 | { | 106 | { |
116 | ns->finished = GNUNET_SYSERR; | 107 | GNUNET_TESTING_async_fail (&ns->ac); |
117 | } | 108 | } |
118 | GNUNET_OS_process_destroy (ns->stop_proc); | ||
119 | ns->stop_proc = NULL; | ||
120 | } | 109 | } |
121 | 110 | ||
122 | 111 | ||
@@ -132,6 +121,7 @@ netjail_stop_run (void *cls, | |||
132 | { | 121 | { |
133 | struct NetJailState *ns = cls; | 122 | struct NetJailState *ns = cls; |
134 | char *pid; | 123 | char *pid; |
124 | |||
135 | GNUNET_asprintf (&pid, | 125 | GNUNET_asprintf (&pid, |
136 | "%u", | 126 | "%u", |
137 | getpid ()); | 127 | getpid ()); |
@@ -170,36 +160,9 @@ netjail_stop_run (void *cls, | |||
170 | &child_completed_callback, | 160 | &child_completed_callback, |
171 | ns); | 161 | ns); |
172 | GNUNET_break (NULL != cwh); | 162 | GNUNET_break (NULL != cwh); |
173 | |||
174 | } | 163 | } |
175 | 164 | ||
176 | 165 | ||
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 topology_config Configuration file for the test topology. | ||
201 | * @return command. | ||
202 | */ | ||
203 | struct GNUNET_TESTING_Command | 166 | struct GNUNET_TESTING_Command |
204 | GNUNET_TESTING_cmd_netjail_stop_v2 (const char *label, | 167 | GNUNET_TESTING_cmd_netjail_stop_v2 (const char *label, |
205 | char *topology_config) | 168 | char *topology_config) |
@@ -213,9 +176,8 @@ GNUNET_TESTING_cmd_netjail_stop_v2 (const char *label, | |||
213 | .cls = ns, | 176 | .cls = ns, |
214 | .label = label, | 177 | .label = label, |
215 | .run = &netjail_stop_run, | 178 | .run = &netjail_stop_run, |
216 | .finish = &netjail_stop_finish, | 179 | .ac = &ns->ac, |
217 | .cleanup = &netjail_stop_cleanup, | 180 | .cleanup = &netjail_stop_cleanup |
218 | .traits = &netjail_stop_traits | ||
219 | }; | 181 | }; |
220 | 182 | ||
221 | return cmd; | 183 | return cmd; |