[or-cvs] r13945: Store options we got from commandline seperately from bare a (tor/trunk/src/or)

weasel at seul.org weasel at seul.org
Mon Mar 10 12:41:40 UTC 2008


Author: weasel
Date: 2008-03-10 08:41:40 -0400 (Mon, 10 Mar 2008)
New Revision: 13945

Modified:
   tor/trunk/src/or/config.c
Log:
Store options we got from commandline seperately from bare argv/argc


Modified: tor/trunk/src/or/config.c
===================================================================
--- tor/trunk/src/or/config.c	2008-03-10 12:41:36 UTC (rev 13944)
+++ tor/trunk/src/or/config.c	2008-03-10 12:41:40 UTC (rev 13945)
@@ -705,6 +705,8 @@
 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(&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 @@
 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 @@
     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 @@
     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;
 



More information about the tor-commits mailing list