diff options
author | Nathan S. Evans <evans@in.tum.de> | 2011-07-27 14:57:28 +0000 |
---|---|---|
committer | Nathan S. Evans <evans@in.tum.de> | 2011-07-27 14:57:28 +0000 |
commit | 95daec0a418692408dadb9d0071b717295dde047 (patch) | |
tree | 64a8109f2d32a6b66723ceba8f15be94c97dfd56 /src | |
parent | a45670c7be283300e3a6906462a1a6a07a420694 (diff) | |
download | gnunet-95daec0a418692408dadb9d0071b717295dde047.tar.gz gnunet-95daec0a418692408dadb9d0071b717295dde047.zip |
command line timeout option
Diffstat (limited to 'src')
-rw-r--r-- | src/arm/gnunet-arm.c | 22 |
1 files changed, 17 insertions, 5 deletions
diff --git a/src/arm/gnunet-arm.c b/src/arm/gnunet-arm.c index 47b173858..4e54a490c 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c | |||
@@ -125,6 +125,11 @@ const struct GNUNET_CONFIGURATION_Handle *cfg; | |||
125 | */ | 125 | */ |
126 | static unsigned int phase; | 126 | static unsigned int phase; |
127 | 127 | ||
128 | /** | ||
129 | * User defined timestamp for completing operations. | ||
130 | */ | ||
131 | static struct GNUNET_TIME_Relative timeout; | ||
132 | |||
128 | 133 | ||
129 | /** | 134 | /** |
130 | * Main continuation-passing-style loop. Runs the various | 135 | * Main continuation-passing-style loop. Runs the various |
@@ -291,35 +296,35 @@ cps_loop (void *cls, | |||
291 | case 0: | 296 | case 0: |
292 | if (term != NULL) | 297 | if (term != NULL) |
293 | { | 298 | { |
294 | GNUNET_ARM_stop_service (h, term, STOP_TIMEOUT, &confirm_cb, term); | 299 | GNUNET_ARM_stop_service (h, term, (0 == timeout.rel_value) ? STOP_TIMEOUT : timeout, &confirm_cb, term); |
295 | return; | 300 | return; |
296 | } | 301 | } |
297 | break; | 302 | break; |
298 | case 1: | 303 | case 1: |
299 | if ((end) || (restart)) | 304 | if ((end) || (restart)) |
300 | { | 305 | { |
301 | GNUNET_ARM_stop_service (h, "arm", STOP_TIMEOUT_ARM, &confirm_cb, "arm"); | 306 | GNUNET_ARM_stop_service (h, "arm", (0 == timeout.rel_value) ? STOP_TIMEOUT_ARM : timeout, &confirm_cb, "arm"); |
302 | return; | 307 | return; |
303 | } | 308 | } |
304 | break; | 309 | break; |
305 | case 2: | 310 | case 2: |
306 | if (start) | 311 | if (start) |
307 | { | 312 | { |
308 | GNUNET_ARM_start_service (h, "arm", START_TIMEOUT, &confirm_cb, "arm"); | 313 | GNUNET_ARM_start_service (h, "arm", (0 == timeout.rel_value) ? START_TIMEOUT : timeout, &confirm_cb, "arm"); |
309 | return; | 314 | return; |
310 | } | 315 | } |
311 | break; | 316 | break; |
312 | case 3: | 317 | case 3: |
313 | if (init != NULL) | 318 | if (init != NULL) |
314 | { | 319 | { |
315 | GNUNET_ARM_start_service (h, init, START_TIMEOUT, &confirm_cb, init); | 320 | GNUNET_ARM_start_service (h, init, (0 == timeout.rel_value) ? START_TIMEOUT : timeout, &confirm_cb, init); |
316 | return; | 321 | return; |
317 | } | 322 | } |
318 | break; | 323 | break; |
319 | case 4: | 324 | case 4: |
320 | if (test != NULL) | 325 | if (test != NULL) |
321 | { | 326 | { |
322 | GNUNET_CLIENT_service_test (test, cfg, TEST_TIMEOUT, &confirm_task, test); | 327 | GNUNET_CLIENT_service_test (test, cfg, (0 == timeout.rel_value) ? TEST_TIMEOUT : timeout, &confirm_task, test); |
323 | return; | 328 | return; |
324 | } | 329 | } |
325 | break; | 330 | break; |
@@ -363,6 +368,8 @@ cps_loop (void *cls, | |||
363 | int | 368 | int |
364 | main (int argc, char *const *argv) | 369 | main (int argc, char *const *argv) |
365 | { | 370 | { |
371 | static unsigned long long temp_timeout_ms; | ||
372 | |||
366 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { | 373 | static const struct GNUNET_GETOPT_CommandLineOption options[] = { |
367 | {'e', "end", NULL, gettext_noop ("stop all GNUnet services"), | 374 | {'e', "end", NULL, gettext_noop ("stop all GNUnet services"), |
368 | GNUNET_NO, &GNUNET_GETOPT_set_one, &end}, | 375 | GNUNET_NO, &GNUNET_GETOPT_set_one, &end}, |
@@ -381,9 +388,14 @@ main (int argc, char *const *argv) | |||
381 | GNUNET_NO, &GNUNET_GETOPT_set_one, &delete}, | 388 | GNUNET_NO, &GNUNET_GETOPT_set_one, &delete}, |
382 | {'q', "quiet", NULL, gettext_noop ("don't print status messages"), | 389 | {'q', "quiet", NULL, gettext_noop ("don't print status messages"), |
383 | GNUNET_NO, &GNUNET_GETOPT_set_one, &quiet}, | 390 | GNUNET_NO, &GNUNET_GETOPT_set_one, &quiet}, |
391 | {'T', "timeout", NULL, gettext_noop ("timeout for completing current operation"), | ||
392 | GNUNET_NO, &GNUNET_GETOPT_set_one, &temp_timeout_ms}, | ||
384 | GNUNET_GETOPT_OPTION_END | 393 | GNUNET_GETOPT_OPTION_END |
385 | }; | 394 | }; |
386 | 395 | ||
396 | if (temp_timeout_ms > 0) | ||
397 | timeout.rel_value = temp_timeout_ms; | ||
398 | |||
387 | if (GNUNET_OK == GNUNET_PROGRAM_run (argc, | 399 | if (GNUNET_OK == GNUNET_PROGRAM_run (argc, |
388 | argv, | 400 | argv, |
389 | "gnunet-arm", | 401 | "gnunet-arm", |