aboutsummaryrefslogtreecommitdiff
path: root/src/or/config.c
diff options
context:
space:
mode:
authorPeter Palfrader <peter@palfrader.org>2008-03-10 12:41:40 +0000
committerPeter Palfrader <peter@palfrader.org>2008-03-10 12:41:40 +0000
commit947fd064a35d7c713b837f5ab23c5adb8fed9525 (patch)
treed69f3e3fb72b206ad5d3762dd4c10a87ff78f12c /src/or/config.c
parent00d64fd2136e5e51abedced3801fb4be3cffc021 (diff)
downloadtor-947fd064a35d7c713b837f5ab23c5adb8fed9525.tar
tor-947fd064a35d7c713b837f5ab23c5adb8fed9525.tar.gz
Store options we got from commandline seperately from bare argv/argc
svn:r13945
Diffstat (limited to 'src/or/config.c')
-rw-r--r--src/or/config.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/or/config.c b/src/or/config.c
index 6570c83c0..137704508 100644
--- a/src/or/config.c
+++ b/src/or/config.c
@@ -705,6 +705,8 @@ static or_options_t *global_options = NULL;
static char *torrc_fname = NULL;
/** Persistent serialized state. */
static or_state_t *global_state = NULL;
+/** Configuration Options set by command line. */
+static config_line_t *global_cmdline_options = NULL;
/** Allocate an empty configuration object of a given format type. */
static void *
@@ -784,6 +786,10 @@ config_free_all(void)
config_free(&state_format, global_state);
global_state = NULL;
}
+ if (global_cmdline_options) {
+ config_free_lines(global_cmdline_options);
+ global_cmdline_options = NULL;
+ }
tor_free(torrc_fname);
tor_free(_version);
}
@@ -3621,7 +3627,7 @@ load_torrc_from_disk(int argc, char **argv)
int
options_init_from_torrc(int argc, char **argv)
{
- or_options_t *oldoptions, *newoptions;
+ or_options_t *oldoptions, *newoptions = NULL;
config_line_t *cl;
char *cf=NULL, *errmsg=NULL;
int i, retval;
@@ -3655,6 +3661,15 @@ options_init_from_torrc(int argc, char **argv)
exit(0);
}
+ /* Go through command-line variables */
+ if (!global_cmdline_options) {
+ /* Or we could redo the list every time we pass this place.
+ * It does not really matter */
+ if (config_get_commandlines(argc, argv, &global_cmdline_options) < 0) {
+ goto err;
+ }
+ }
+
newoptions = tor_malloc_zero(sizeof(or_options_t));
newoptions->_magic = OR_OPTIONS_MAGIC;
options_init(newoptions);
@@ -3687,10 +3702,8 @@ options_init_from_torrc(int argc, char **argv)
goto err;
/* Go through command-line variables too */
- if (config_get_commandlines(argc, argv, &cl) < 0)
- goto err;
- retval = config_assign(&options_format, newoptions, cl, 0, 0, &errmsg);
- config_free_lines(cl);
+ retval = config_assign(&options_format, newoptions,
+ global_cmdline_options, 0, 0, &errmsg);
if (retval < 0)
goto err;