diff options
Diffstat (limited to 'src/arm/test_exponential_backoff.c')
-rw-r--r-- | src/arm/test_exponential_backoff.c | 386 |
1 files changed, 192 insertions, 194 deletions
diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index 43984f9bf..8190d29c2 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c | |||
@@ -11,12 +11,12 @@ | |||
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
13 | Affero General Public License for more details. | 13 | Affero General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU Affero General Public License | 15 | You should have received a copy of the GNU Affero General Public License |
16 | along with this program. If not, see <http://www.gnu.org/licenses/>. | 16 | along with this program. If not, see <http://www.gnu.org/licenses/>. |
17 | 17 | ||
18 | SPDX-License-Identifier: AGPL3.0-or-later | 18 | SPDX-License-Identifier: AGPL3.0-or-later |
19 | */ | 19 | */ |
20 | /** | 20 | /** |
21 | * @file arm/test_exponential_backoff.c | 21 | * @file arm/test_exponential_backoff.c |
22 | * @brief testcase for gnunet-service-arm.c | 22 | * @brief testcase for gnunet-service-arm.c |
@@ -27,15 +27,15 @@ | |||
27 | #include "gnunet_util_lib.h" | 27 | #include "gnunet_util_lib.h" |
28 | #include "gnunet_protocols.h" | 28 | #include "gnunet_protocols.h" |
29 | 29 | ||
30 | #define LOG(...) GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) | 30 | #define LOG(...) GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, __VA_ARGS__) |
31 | 31 | ||
32 | #define LOG_BACKOFF GNUNET_NO | 32 | #define LOG_BACKOFF GNUNET_NO |
33 | 33 | ||
34 | #define TIMEOUT GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_SECONDS, 10) | 34 | #define TIMEOUT GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_SECONDS, 10) |
35 | 35 | ||
36 | #define SERVICE_TEST_TIMEOUT GNUNET_TIME_UNIT_FOREVER_REL | 36 | #define SERVICE_TEST_TIMEOUT GNUNET_TIME_UNIT_FOREVER_REL |
37 | 37 | ||
38 | #define FIVE_MILLISECONDS GNUNET_TIME_relative_multiply (GNUNET_TIME_UNIT_MILLISECONDS, 5) | 38 | #define FIVE_MILLISECONDS GNUNET_TIME_relative_multiply(GNUNET_TIME_UNIT_MILLISECONDS, 5) |
39 | 39 | ||
40 | #define SERVICE "do-nothing" | 40 | #define SERVICE "do-nothing" |
41 | 41 | ||
@@ -74,8 +74,7 @@ static char *killLogFileName; | |||
74 | /** | 74 | /** |
75 | * Context for handling the shutdown of a service. | 75 | * Context for handling the shutdown of a service. |
76 | */ | 76 | */ |
77 | struct ShutdownContext | 77 | struct ShutdownContext { |
78 | { | ||
79 | /** | 78 | /** |
80 | * Connection to the service that is being shutdown. | 79 | * Connection to the service that is being shutdown. |
81 | */ | 80 | */ |
@@ -85,12 +84,11 @@ struct ShutdownContext | |||
85 | * Task set up to cancel the shutdown request on timeout. | 84 | * Task set up to cancel the shutdown request on timeout. |
86 | */ | 85 | */ |
87 | struct GNUNET_SCHEDULER_Task *cancel_task; | 86 | struct GNUNET_SCHEDULER_Task *cancel_task; |
88 | |||
89 | }; | 87 | }; |
90 | 88 | ||
91 | 89 | ||
92 | static void | 90 | static void |
93 | kill_task (void *cbData); | 91 | kill_task(void *cbData); |
94 | 92 | ||
95 | 93 | ||
96 | /** | 94 | /** |
@@ -99,9 +97,9 @@ kill_task (void *cbData); | |||
99 | * @param cls closure | 97 | * @param cls closure |
100 | */ | 98 | */ |
101 | static void | 99 | static void |
102 | service_shutdown_timeout (void *cls) | 100 | service_shutdown_timeout(void *cls) |
103 | { | 101 | { |
104 | GNUNET_assert (0); | 102 | GNUNET_assert(0); |
105 | } | 103 | } |
106 | 104 | ||
107 | 105 | ||
@@ -114,196 +112,196 @@ service_shutdown_timeout (void *cls) | |||
114 | * @param error error code | 112 | * @param error error code |
115 | */ | 113 | */ |
116 | static void | 114 | static void |
117 | mq_error_handler (void *cls, | 115 | mq_error_handler(void *cls, |
118 | enum GNUNET_MQ_Error error) | 116 | enum GNUNET_MQ_Error error) |
119 | { | 117 | { |
120 | struct ShutdownContext *shutdown_ctx = cls; | 118 | struct ShutdownContext *shutdown_ctx = cls; |
121 | 119 | ||
122 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 120 | GNUNET_log(GNUNET_ERROR_TYPE_DEBUG, |
123 | "Service shutdown complete (MQ error).\n"); | 121 | "Service shutdown complete (MQ error).\n"); |
124 | GNUNET_SCHEDULER_cancel (shutdown_ctx->cancel_task); | 122 | GNUNET_SCHEDULER_cancel(shutdown_ctx->cancel_task); |
125 | GNUNET_MQ_destroy (shutdown_ctx->mq); | 123 | GNUNET_MQ_destroy(shutdown_ctx->mq); |
126 | GNUNET_free (shutdown_ctx); | 124 | GNUNET_free(shutdown_ctx); |
127 | } | 125 | } |
128 | 126 | ||
129 | 127 | ||
130 | static void | 128 | static void |
131 | kill_task (void *cbData) | 129 | kill_task(void *cbData) |
132 | { | 130 | { |
133 | struct ShutdownContext *shutdown_ctx | 131 | struct ShutdownContext *shutdown_ctx |
134 | = GNUNET_new (struct ShutdownContext); | 132 | = GNUNET_new(struct ShutdownContext); |
135 | struct GNUNET_MQ_Envelope *env; | 133 | struct GNUNET_MQ_Envelope *env; |
136 | struct GNUNET_MessageHeader *msg; | 134 | struct GNUNET_MessageHeader *msg; |
137 | struct GNUNET_MQ_MessageHandler handlers[] = { | 135 | struct GNUNET_MQ_MessageHandler handlers[] = { |
138 | GNUNET_MQ_handler_end () | 136 | GNUNET_MQ_handler_end() |
139 | }; | 137 | }; |
140 | 138 | ||
141 | kt = NULL; | 139 | kt = NULL; |
142 | if (trialCount == 13) | 140 | if (trialCount == 13) |
143 | { | 141 | { |
144 | LOG ("Saw enough kills, asking ARM to stop mock service for good\n"); | 142 | LOG("Saw enough kills, asking ARM to stop mock service for good\n"); |
145 | GNUNET_ARM_request_service_stop (arm, | 143 | GNUNET_ARM_request_service_stop(arm, |
146 | SERVICE, | 144 | SERVICE, |
147 | NULL, | 145 | NULL, |
148 | NULL); | 146 | NULL); |
149 | ok = 0; | 147 | ok = 0; |
150 | trialCount++; | 148 | trialCount++; |
151 | GNUNET_free (shutdown_ctx); | 149 | GNUNET_free(shutdown_ctx); |
152 | return; | 150 | return; |
153 | } | 151 | } |
154 | shutdown_ctx->mq = GNUNET_CLIENT_connect (cfg, | 152 | shutdown_ctx->mq = GNUNET_CLIENT_connect(cfg, |
155 | SERVICE, | 153 | SERVICE, |
156 | handlers, | 154 | handlers, |
157 | &mq_error_handler, | 155 | &mq_error_handler, |
158 | shutdown_ctx); | 156 | shutdown_ctx); |
159 | GNUNET_assert (NULL != shutdown_ctx->mq); | 157 | GNUNET_assert(NULL != shutdown_ctx->mq); |
160 | trialCount++; | 158 | trialCount++; |
161 | LOG ("Sending a shutdown request to the mock service\n"); | 159 | LOG("Sending a shutdown request to the mock service\n"); |
162 | env = GNUNET_MQ_msg (msg, | 160 | env = GNUNET_MQ_msg(msg, |
163 | GNUNET_MESSAGE_TYPE_ARM_STOP); /* FIXME: abuse of message type */ | 161 | GNUNET_MESSAGE_TYPE_ARM_STOP); /* FIXME: abuse of message type */ |
164 | GNUNET_MQ_send (shutdown_ctx->mq, | 162 | GNUNET_MQ_send(shutdown_ctx->mq, |
165 | env); | 163 | env); |
166 | shutdown_ctx->cancel_task | 164 | shutdown_ctx->cancel_task |
167 | = GNUNET_SCHEDULER_add_delayed (TIMEOUT, | 165 | = GNUNET_SCHEDULER_add_delayed(TIMEOUT, |
168 | &service_shutdown_timeout, | 166 | &service_shutdown_timeout, |
169 | shutdown_ctx); | 167 | shutdown_ctx); |
170 | } | 168 | } |
171 | 169 | ||
172 | 170 | ||
173 | static void | 171 | static void |
174 | trigger_disconnect (void *cls) | 172 | trigger_disconnect(void *cls) |
175 | { | 173 | { |
176 | GNUNET_ARM_disconnect (arm); | 174 | GNUNET_ARM_disconnect(arm); |
177 | GNUNET_ARM_monitor_stop (mon); | 175 | GNUNET_ARM_monitor_stop(mon); |
178 | if (NULL != kt) | 176 | if (NULL != kt) |
179 | { | 177 | { |
180 | GNUNET_SCHEDULER_cancel (kt); | 178 | GNUNET_SCHEDULER_cancel(kt); |
181 | kt = NULL; | 179 | kt = NULL; |
182 | } | 180 | } |
183 | } | 181 | } |
184 | 182 | ||
185 | 183 | ||
186 | static void | 184 | static void |
187 | arm_stop_cb (void *cls, | 185 | arm_stop_cb(void *cls, |
188 | enum GNUNET_ARM_RequestStatus status, | 186 | enum GNUNET_ARM_RequestStatus status, |
189 | enum GNUNET_ARM_Result result) | 187 | enum GNUNET_ARM_Result result) |
190 | { | 188 | { |
191 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); | 189 | GNUNET_break(status == GNUNET_ARM_REQUEST_SENT_OK); |
192 | GNUNET_break (result == GNUNET_ARM_RESULT_STOPPED); | 190 | GNUNET_break(result == GNUNET_ARM_RESULT_STOPPED); |
193 | LOG ("ARM service stopped\n"); | 191 | LOG("ARM service stopped\n"); |
194 | GNUNET_SCHEDULER_shutdown (); | 192 | GNUNET_SCHEDULER_shutdown(); |
195 | } | 193 | } |
196 | 194 | ||
197 | 195 | ||
198 | static void | 196 | static void |
199 | srv_status (void *cls, | 197 | srv_status(void *cls, |
200 | const char *service, | 198 | const char *service, |
201 | enum GNUNET_ARM_ServiceStatus status) | 199 | enum GNUNET_ARM_ServiceStatus status) |
202 | { | 200 | { |
203 | if (status == GNUNET_ARM_SERVICE_MONITORING_STARTED) | 201 | if (status == GNUNET_ARM_SERVICE_MONITORING_STARTED) |
204 | { | 202 | { |
205 | LOG ("ARM monitor started, starting mock service\n"); | 203 | LOG("ARM monitor started, starting mock service\n"); |
206 | phase++; | 204 | phase++; |
207 | GNUNET_ARM_request_service_start (arm, | 205 | GNUNET_ARM_request_service_start(arm, |
208 | SERVICE, | 206 | SERVICE, |
209 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | 207 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, |
210 | NULL, | 208 | NULL, |
211 | NULL); | 209 | NULL); |
212 | return; | 210 | return; |
213 | } | 211 | } |
214 | if (0 != strcasecmp (service, SERVICE)) | 212 | if (0 != strcasecmp(service, SERVICE)) |
215 | return; /* not what we care about */ | 213 | return; /* not what we care about */ |
216 | if (phase == 1) | 214 | if (phase == 1) |
217 | { | ||
218 | GNUNET_break (status == GNUNET_ARM_SERVICE_STARTING); | ||
219 | GNUNET_break (phase == 1); | ||
220 | LOG ("do-nothing is starting\n"); | ||
221 | phase++; | ||
222 | ok = 1; | ||
223 | GNUNET_assert (NULL == kt); | ||
224 | startedWaitingAt = GNUNET_TIME_absolute_get (); | ||
225 | kt = GNUNET_SCHEDULER_add_delayed (GNUNET_TIME_UNIT_SECONDS, | ||
226 | &kill_task, | ||
227 | NULL); | ||
228 | } | ||
229 | else if (phase == 2) | ||
230 | { | ||
231 | /* We passively monitor ARM for status updates. ARM should tell us | ||
232 | * when do-nothing dies (no need to run a service upness test ourselves). | ||
233 | */ | ||
234 | if (status == GNUNET_ARM_SERVICE_STARTING) | ||
235 | { | 215 | { |
236 | waitedFor = GNUNET_TIME_absolute_get_duration (startedWaitingAt); | 216 | GNUNET_break(status == GNUNET_ARM_SERVICE_STARTING); |
237 | LOG ("Waited for: %s\n", | 217 | GNUNET_break(phase == 1); |
238 | GNUNET_STRINGS_relative_time_to_string (waitedFor, | 218 | LOG("do-nothing is starting\n"); |
239 | GNUNET_YES)); | 219 | phase++; |
240 | 220 | ok = 1; | |
241 | LOG ("do-nothing is starting, killing it...\n"); | 221 | GNUNET_assert(NULL == kt); |
242 | GNUNET_assert (NULL == kt); | 222 | startedWaitingAt = GNUNET_TIME_absolute_get(); |
243 | kt = GNUNET_SCHEDULER_add_now (&kill_task, &ok); | 223 | kt = GNUNET_SCHEDULER_add_delayed(GNUNET_TIME_UNIT_SECONDS, |
224 | &kill_task, | ||
225 | NULL); | ||
244 | } | 226 | } |
245 | else if ((status == GNUNET_ARM_SERVICE_STOPPED) && (trialCount == 14)) | 227 | else if (phase == 2) |
246 | { | 228 | { |
247 | phase++; | 229 | /* We passively monitor ARM for status updates. ARM should tell us |
248 | LOG ("do-nothing stopped working %u times, we are done here\n", | 230 | * when do-nothing dies (no need to run a service upness test ourselves). |
249 | (unsigned int) trialCount); | 231 | */ |
250 | GNUNET_ARM_request_service_stop (arm, | 232 | if (status == GNUNET_ARM_SERVICE_STARTING) |
251 | "arm", | 233 | { |
252 | &arm_stop_cb, | 234 | waitedFor = GNUNET_TIME_absolute_get_duration(startedWaitingAt); |
253 | NULL); | 235 | LOG("Waited for: %s\n", |
236 | GNUNET_STRINGS_relative_time_to_string(waitedFor, | ||
237 | GNUNET_YES)); | ||
238 | |||
239 | LOG("do-nothing is starting, killing it...\n"); | ||
240 | GNUNET_assert(NULL == kt); | ||
241 | kt = GNUNET_SCHEDULER_add_now(&kill_task, &ok); | ||
242 | } | ||
243 | else if ((status == GNUNET_ARM_SERVICE_STOPPED) && (trialCount == 14)) | ||
244 | { | ||
245 | phase++; | ||
246 | LOG("do-nothing stopped working %u times, we are done here\n", | ||
247 | (unsigned int)trialCount); | ||
248 | GNUNET_ARM_request_service_stop(arm, | ||
249 | "arm", | ||
250 | &arm_stop_cb, | ||
251 | NULL); | ||
252 | } | ||
254 | } | 253 | } |
255 | } | ||
256 | } | 254 | } |
257 | 255 | ||
258 | 256 | ||
259 | static void | 257 | static void |
260 | arm_start_cb (void *cls, | 258 | arm_start_cb(void *cls, |
261 | enum GNUNET_ARM_RequestStatus status, | 259 | enum GNUNET_ARM_RequestStatus status, |
262 | enum GNUNET_ARM_Result result) | 260 | enum GNUNET_ARM_Result result) |
263 | { | 261 | { |
264 | GNUNET_break (status == GNUNET_ARM_REQUEST_SENT_OK); | 262 | GNUNET_break(status == GNUNET_ARM_REQUEST_SENT_OK); |
265 | GNUNET_break (result == GNUNET_ARM_RESULT_STARTING); | 263 | GNUNET_break(result == GNUNET_ARM_RESULT_STARTING); |
266 | GNUNET_break (phase == 0); | 264 | GNUNET_break(phase == 0); |
267 | LOG ("Sent 'START' request for arm to ARM %s\n", | 265 | LOG("Sent 'START' request for arm to ARM %s\n", |
268 | (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully"); | 266 | (status == GNUNET_ARM_REQUEST_SENT_OK) ? "successfully" : "unsuccessfully"); |
269 | } | 267 | } |
270 | 268 | ||
271 | 269 | ||
272 | static void | 270 | static void |
273 | task (void *cls, | 271 | task(void *cls, |
274 | char *const *args, | 272 | char *const *args, |
275 | const char *cfgfile, | 273 | const char *cfgfile, |
276 | const struct GNUNET_CONFIGURATION_Handle *c) | 274 | const struct GNUNET_CONFIGURATION_Handle *c) |
277 | { | 275 | { |
278 | cfg = c; | 276 | cfg = c; |
279 | arm = GNUNET_ARM_connect (cfg, NULL, NULL); | 277 | arm = GNUNET_ARM_connect(cfg, NULL, NULL); |
280 | if (NULL == arm) | 278 | if (NULL == arm) |
281 | { | 279 | { |
282 | GNUNET_break (0); | 280 | GNUNET_break(0); |
283 | return; | 281 | return; |
284 | } | 282 | } |
285 | mon = GNUNET_ARM_monitor_start (cfg, | 283 | mon = GNUNET_ARM_monitor_start(cfg, |
286 | &srv_status, | 284 | &srv_status, |
287 | NULL); | ||
288 | if (NULL == mon) | ||
289 | { | ||
290 | GNUNET_break (0); | ||
291 | GNUNET_ARM_disconnect (arm); | ||
292 | arm = NULL; | ||
293 | return; | ||
294 | } | ||
295 | GNUNET_ARM_request_service_start (arm, | ||
296 | "arm", | ||
297 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | ||
298 | &arm_start_cb, | ||
299 | NULL); | ||
300 | GNUNET_SCHEDULER_add_shutdown (&trigger_disconnect, | ||
301 | NULL); | 285 | NULL); |
286 | if (NULL == mon) | ||
287 | { | ||
288 | GNUNET_break(0); | ||
289 | GNUNET_ARM_disconnect(arm); | ||
290 | arm = NULL; | ||
291 | return; | ||
292 | } | ||
293 | GNUNET_ARM_request_service_start(arm, | ||
294 | "arm", | ||
295 | GNUNET_OS_INHERIT_STD_OUT_AND_ERR, | ||
296 | &arm_start_cb, | ||
297 | NULL); | ||
298 | GNUNET_SCHEDULER_add_shutdown(&trigger_disconnect, | ||
299 | NULL); | ||
302 | } | 300 | } |
303 | 301 | ||
304 | 302 | ||
305 | static int | 303 | static int |
306 | check () | 304 | check() |
307 | { | 305 | { |
308 | char *const argv[] = { | 306 | char *const argv[] = { |
309 | "test-exponential-backoff", | 307 | "test-exponential-backoff", |
@@ -315,14 +313,14 @@ check () | |||
315 | }; | 313 | }; |
316 | 314 | ||
317 | /* Running ARM and running the do_nothing task */ | 315 | /* Running ARM and running the do_nothing task */ |
318 | GNUNET_assert (GNUNET_OK == | 316 | GNUNET_assert(GNUNET_OK == |
319 | GNUNET_PROGRAM_run ((sizeof (argv) / sizeof (char *)) - 1, | 317 | GNUNET_PROGRAM_run((sizeof(argv) / sizeof(char *)) - 1, |
320 | argv, | 318 | argv, |
321 | "test-exponential-backoff", | 319 | "test-exponential-backoff", |
322 | "nohelp", | 320 | "nohelp", |
323 | options, | 321 | options, |
324 | &task, | 322 | &task, |
325 | NULL)); | 323 | NULL)); |
326 | return ok; | 324 | return ok; |
327 | } | 325 | } |
328 | 326 | ||
@@ -336,47 +334,47 @@ check () | |||
336 | 334 | ||
337 | 335 | ||
338 | static int | 336 | static int |
339 | init () | 337 | init() |
340 | { | 338 | { |
341 | struct GNUNET_CONFIGURATION_Handle *cfg; | 339 | struct GNUNET_CONFIGURATION_Handle *cfg; |
342 | char pwd[PATH_MAX]; | 340 | char pwd[PATH_MAX]; |
343 | char *binary; | 341 | char *binary; |
344 | 342 | ||
345 | cfg = GNUNET_CONFIGURATION_create (); | 343 | cfg = GNUNET_CONFIGURATION_create(); |
346 | if (GNUNET_OK != GNUNET_CONFIGURATION_parse (cfg, | 344 | if (GNUNET_OK != GNUNET_CONFIGURATION_parse(cfg, |
347 | "test_arm_api_data.conf")) | 345 | "test_arm_api_data.conf")) |
348 | { | 346 | { |
349 | GNUNET_CONFIGURATION_destroy (cfg); | 347 | GNUNET_CONFIGURATION_destroy(cfg); |
350 | return GNUNET_SYSERR; | 348 | return GNUNET_SYSERR; |
351 | } | 349 | } |
352 | if (NULL == getcwd (pwd, PATH_MAX)) | 350 | if (NULL == getcwd(pwd, PATH_MAX)) |
353 | return GNUNET_SYSERR; | ||
354 | GNUNET_assert (0 < GNUNET_asprintf (&binary, | ||
355 | "%s/%s", | ||
356 | pwd, | ||
357 | BINARY)); | ||
358 | GNUNET_CONFIGURATION_set_value_string (cfg, | ||
359 | SERVICE, | ||
360 | "BINARY", | ||
361 | binary); | ||
362 | GNUNET_free (binary); | ||
363 | if (GNUNET_OK != GNUNET_CONFIGURATION_write (cfg, | ||
364 | CFGFILENAME)) | ||
365 | { | ||
366 | GNUNET_CONFIGURATION_destroy (cfg); | ||
367 | return GNUNET_SYSERR; | 351 | return GNUNET_SYSERR; |
368 | } | 352 | GNUNET_assert(0 < GNUNET_asprintf(&binary, |
369 | GNUNET_CONFIGURATION_destroy (cfg); | 353 | "%s/%s", |
354 | pwd, | ||
355 | BINARY)); | ||
356 | GNUNET_CONFIGURATION_set_value_string(cfg, | ||
357 | SERVICE, | ||
358 | "BINARY", | ||
359 | binary); | ||
360 | GNUNET_free(binary); | ||
361 | if (GNUNET_OK != GNUNET_CONFIGURATION_write(cfg, | ||
362 | CFGFILENAME)) | ||
363 | { | ||
364 | GNUNET_CONFIGURATION_destroy(cfg); | ||
365 | return GNUNET_SYSERR; | ||
366 | } | ||
367 | GNUNET_CONFIGURATION_destroy(cfg); | ||
370 | 368 | ||
371 | #if LOG_BACKOFF | 369 | #if LOG_BACKOFF |
372 | killLogFileName = GNUNET_DISK_mktemp ("exponential-backoff-waiting.log"); | 370 | killLogFileName = GNUNET_DISK_mktemp("exponential-backoff-waiting.log"); |
373 | if (NULL == (killLogFilePtr = fopen (killLogFileName, | 371 | if (NULL == (killLogFilePtr = fopen(killLogFileName, |
374 | "w"))) | 372 | "w"))) |
375 | { | 373 | { |
376 | GNUNET_log_strerror_file (GNUNET_ERROR_TYPE_WARNING, | 374 | GNUNET_log_strerror_file(GNUNET_ERROR_TYPE_WARNING, |
377 | "fopen", | 375 | "fopen", |
378 | killLogFileName); | 376 | killLogFileName); |
379 | GNUNET_free (killLogFileName); | 377 | GNUNET_free(killLogFileName); |
380 | return GNUNET_SYSERR; | 378 | return GNUNET_SYSERR; |
381 | } | 379 | } |
382 | #endif | 380 | #endif |
@@ -385,29 +383,29 @@ init () | |||
385 | 383 | ||
386 | 384 | ||
387 | static void | 385 | static void |
388 | houseKeep () | 386 | houseKeep() |
389 | { | 387 | { |
390 | #if LOG_BACKOFF | 388 | #if LOG_BACKOFF |
391 | GNUNET_assert (0 == fclose (killLogFilePtr)); | 389 | GNUNET_assert(0 == fclose(killLogFilePtr)); |
392 | GNUNET_free (killLogFileName); | 390 | GNUNET_free(killLogFileName); |
393 | #endif | 391 | #endif |
394 | (void) unlink (CFGFILENAME); | 392 | (void)unlink(CFGFILENAME); |
395 | } | 393 | } |
396 | 394 | ||
397 | 395 | ||
398 | int | 396 | int |
399 | main (int argc, char *argv[]) | 397 | main(int argc, char *argv[]) |
400 | { | 398 | { |
401 | int ret; | 399 | int ret; |
402 | 400 | ||
403 | GNUNET_log_setup ("test-exponential-backoff", | 401 | GNUNET_log_setup("test-exponential-backoff", |
404 | "WARNING", | 402 | "WARNING", |
405 | NULL); | 403 | NULL); |
406 | 404 | ||
407 | if (GNUNET_OK != init ()) | 405 | if (GNUNET_OK != init()) |
408 | return 1; | 406 | return 1; |
409 | ret = check (); | 407 | ret = check(); |
410 | houseKeep (); | 408 | houseKeep(); |
411 | return ret; | 409 | return ret; |
412 | } | 410 | } |
413 | 411 | ||