]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
When ReloadTorrcOnSIGHUP=1, do non-reload activities anyway
authorNick Mathewson <nickm@torproject.org>
Wed, 11 Apr 2012 18:47:42 +0000 (14:47 -0400)
committerNick Mathewson <nickm@torproject.org>
Wed, 16 May 2012 14:36:21 +0000 (10:36 -0400)
Previously, we skipped everything that got invoked from
options_init_from_torrc.  But some of the stuff in
options_act_reversible and options_act is actually important, like
reopening the logs.

Now, a SIGHUP always makes the effects of an options_set() happen,
even though the options haven't changed.

Fix for bug 5095; bugfix on 0.2.1.9-alpha, which introduced
__ReloadTorrcOnSIGHUP.

changes/bug5095 [new file with mode: 0644]
src/or/config.c
src/or/main.c

diff --git a/changes/bug5095 b/changes/bug5095
new file mode 100644 (file)
index 0000000..81801ec
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes:
+    - When we receive a SIGHUP and the controller-use __ReloadTorrcOnSIGHUP
+      option is set to 0, perform other actions that SIGHUP usually causes
+      (like reopening the logs). Fixes bug 5095; bugfix on 0.2.1.9-alpha.
index dcc57f8e774a2b016eb747d0debecedb7ace8390..27aa8a2f2380bb57030e30d6d8688d0b5f32f800 100644 (file)
@@ -748,7 +748,7 @@ set_options(or_options_t *new_val, char **msg)
   }
   /* Issues a CONF_CHANGED event to notify controller of the change. If Tor is
    * just starting up then the old_options will be undefined. */
-  if (old_options) {
+  if (old_options && old_options != global_options) {
     elements = smartlist_new();
     for (i=0; options_format.vars[i].name; ++i) {
       const config_var_t *var = &options_format.vars[i];
@@ -774,7 +774,9 @@ set_options(or_options_t *new_val, char **msg)
     control_event_conf_changed(elements);
     smartlist_free(elements);
   }
-  config_free(&options_format, old_options);
+
+  if (old_options != global_options)
+    config_free(&options_format, old_options);
 
   return 0;
 }
index 9022f2eb877456949ee93670fe2ffe1ad7977709..8308b3a238548559b707f2e01d551ef55f1d02d3 100644 (file)
@@ -1773,8 +1773,16 @@ do_hup(void)
     }
     options = get_options(); /* they have changed now */
   } else {
+    char *msg = NULL;
     log_notice(LD_GENERAL, "Not reloading config file: the controller told "
                "us not to.");
+    /* Make stuff get rescanned, reloaded, etc. */
+    if (set_options((or_options_t*)options, &msg) < 0) {
+      if (!msg)
+        msg = tor_strdup("Unknown error");
+      log_warn(LD_GENERAL, "Unable to re-set previous options: %s", msg);
+      tor_free(msg);
+    }
   }
   if (authdir_mode_handles_descs(options, -1)) {
     /* reload the approved-routers file */