From fe384d97cdfcb47c10a05f56f983f24619115a19 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 24 Apr 2015 07:04:18 +0000 Subject: [PATCH] move ARM/config logic to util/ where it doesn't need to cast away a 'const' and is _slightly_ less likely to be forgotten, also add big fat comment to hopefully clarify why it is there --- src/arm/test_arm_api.c | 15 --------------- src/arm/test_exponential_backoff.c | 14 -------------- src/gns/gnunet-gns-proxy.c | 4 ++-- src/util/program.c | 16 ++++++++++++++++ 4 files changed, 18 insertions(+), 31 deletions(-) diff --git a/src/arm/test_arm_api.c b/src/arm/test_arm_api.c index 67bf45871..6bd5132ee 100644 --- a/src/arm/test_arm_api.c +++ b/src/arm/test_arm_api.c @@ -185,22 +185,7 @@ static void task (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { - char *armconfig; cfg = c; - if (NULL != cfgfile) - { - if (GNUNET_OK != - GNUNET_CONFIGURATION_get_value_filename (cfg, - "arm", "CONFIG", - &armconfig)) - { - GNUNET_CONFIGURATION_set_value_string ((struct GNUNET_CONFIGURATION_Handle - *) cfg, "arm", "CONFIG", - cfgfile); - } - else - GNUNET_free (armconfig); - } arm = GNUNET_ARM_connect (cfg, &arm_conn, NULL); if (NULL == arm) return; diff --git a/src/arm/test_exponential_backoff.c b/src/arm/test_exponential_backoff.c index a14103be0..d0277523b 100644 --- a/src/arm/test_exponential_backoff.c +++ b/src/arm/test_exponential_backoff.c @@ -356,21 +356,7 @@ static void task (void *cls, char *const *args, const char *cfgfile, const struct GNUNET_CONFIGURATION_Handle *c) { - char *armconfig; cfg = c; - if (NULL != cfgfile) - { - if (GNUNET_OK != GNUNET_CONFIGURATION_get_value_filename (cfg, "arm", - "CONFIG", &armconfig)) - { - GNUNET_CONFIGURATION_set_value_string ((struct GNUNET_CONFIGURATION_Handle - *) cfg, "arm", "CONFIG", - cfgfile); - } - else - GNUNET_free (armconfig); - } - arm = GNUNET_ARM_connect (cfg, NULL, NULL); if (NULL != arm) { diff --git a/src/gns/gnunet-gns-proxy.c b/src/gns/gnunet-gns-proxy.c index d52b3b57f..08cfdf4df 100644 --- a/src/gns/gnunet-gns-proxy.c +++ b/src/gns/gnunet-gns-proxy.c @@ -522,7 +522,7 @@ struct Socks5Request * HTTP request headers for the curl request. */ struct curl_slist *headers; - + /** * DNS->IP mappings resolved through GNS */ @@ -1032,7 +1032,7 @@ curl_check_hdr (void *buffer, size_t size, size_t nmemb, void *cls) GNUNET_free (cors_hdr); } /* force connection to be closed after each request, as we - do not support HTTP pipelining */ + do not support HTTP pipelining (yet, FIXME!) */ GNUNET_break (MHD_YES == MHD_add_response_header (s5r->response, MHD_HTTP_HEADER_CONNECTION, diff --git a/src/util/program.c b/src/util/program.c index 865d9c690..08858af37 100644 --- a/src/util/program.c +++ b/src/util/program.c @@ -279,6 +279,22 @@ GNUNET_PROGRAM_run2 (int argc, char *const *argv, const char *binaryName, clock_offset = skew_offset - skew_variance; GNUNET_TIME_set_offset (clock_offset); } + /* ARM needs to know which configuration file to use when starting + services. If we got a command-line option *and* if nothing is + specified in the configuration, remember the command-line option + in "cfg". This is typically really only having an effect if we + are running code in src/arm/, as obviously the rest of the code + has little business with ARM-specific options. */ + if (GNUNET_YES != + GNUNET_CONFIGURATION_have_value (cfg, + "arm", + "CONFIG")) + { + GNUNET_CONFIGURATION_set_value_string (cfg, + "arm", "CONFIG", + cc.cfgfile); + } + /* run */ cc.args = &argv[ret]; if (GNUNET_NO == run_without_scheduler) -- 2.25.1