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/arm/gnunet-arm.c | |
parent | a45670c7be283300e3a6906462a1a6a07a420694 (diff) |
command line timeout option
Diffstat (limited to 'src/arm/gnunet-arm.c')
-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 47b1738586..4e54a490cb 100644 --- a/src/arm/gnunet-arm.c +++ b/src/arm/gnunet-arm.c @@ -125,6 +125,11 @@ const struct GNUNET_CONFIGURATION_Handle *cfg; */ static unsigned int phase; +/** + * User defined timestamp for completing operations. + */ +static struct GNUNET_TIME_Relative timeout; + /** * Main continuation-passing-style loop. Runs the various @@ -291,35 +296,35 @@ cps_loop (void *cls, case 0: if (term != NULL) { - GNUNET_ARM_stop_service (h, term, STOP_TIMEOUT, &confirm_cb, term); + GNUNET_ARM_stop_service (h, term, (0 == timeout.rel_value) ? STOP_TIMEOUT : timeout, &confirm_cb, term); return; } break; case 1: if ((end) || (restart)) { - GNUNET_ARM_stop_service (h, "arm", STOP_TIMEOUT_ARM, &confirm_cb, "arm"); + GNUNET_ARM_stop_service (h, "arm", (0 == timeout.rel_value) ? STOP_TIMEOUT_ARM : timeout, &confirm_cb, "arm"); return; } break; case 2: if (start) { - GNUNET_ARM_start_service (h, "arm", START_TIMEOUT, &confirm_cb, "arm"); + GNUNET_ARM_start_service (h, "arm", (0 == timeout.rel_value) ? START_TIMEOUT : timeout, &confirm_cb, "arm"); return; } break; case 3: if (init != NULL) { - GNUNET_ARM_start_service (h, init, START_TIMEOUT, &confirm_cb, init); + GNUNET_ARM_start_service (h, init, (0 == timeout.rel_value) ? START_TIMEOUT : timeout, &confirm_cb, init); return; } break; case 4: if (test != NULL) { - GNUNET_CLIENT_service_test (test, cfg, TEST_TIMEOUT, &confirm_task, test); + GNUNET_CLIENT_service_test (test, cfg, (0 == timeout.rel_value) ? TEST_TIMEOUT : timeout, &confirm_task, test); return; } break; @@ -363,6 +368,8 @@ cps_loop (void *cls, int main (int argc, char *const *argv) { + static unsigned long long temp_timeout_ms; + static const struct GNUNET_GETOPT_CommandLineOption options[] = { {'e', "end", NULL, gettext_noop ("stop all GNUnet services"), GNUNET_NO, &GNUNET_GETOPT_set_one, &end}, @@ -381,9 +388,14 @@ main (int argc, char *const *argv) GNUNET_NO, &GNUNET_GETOPT_set_one, &delete}, {'q', "quiet", NULL, gettext_noop ("don't print status messages"), GNUNET_NO, &GNUNET_GETOPT_set_one, &quiet}, + {'T', "timeout", NULL, gettext_noop ("timeout for completing current operation"), + GNUNET_NO, &GNUNET_GETOPT_set_one, &temp_timeout_ms}, GNUNET_GETOPT_OPTION_END }; + if (temp_timeout_ms > 0) + timeout.rel_value = temp_timeout_ms; + if (GNUNET_OK == GNUNET_PROGRAM_run (argc, argv, "gnunet-arm", |