[tor-commits] [tor/master] Make SIGNAL DUMP work on FreeBSD

nickm at torproject.org nickm at torproject.org
Tue Apr 26 19:30:08 UTC 2011


commit 5114e3e44235ea39447eea37213c65413cdb1a2c
Author: Sebastian Hahn <sebastian at torproject.org>
Date:   Thu Apr 14 20:04:39 2011 -0700

    Make SIGNAL DUMP work on FreeBSD
    
    While doing so, get rid of the now unnecessary function
    control_signal_act().
    
    Fixes bug 2917, reported by Robert Ransom. Bugfix on commit
    9b4aa8d2abbce71398e58188209a1b1d04885b96. This patch is loosely based on
    a patch by Robert (Changelog entry).
---
 changes/bug2917  |    4 ++++
 src/or/control.c |    3 ++-
 src/or/main.c    |   43 +------------------------------------------
 src/or/main.h    |    2 +-
 src/or/or.h      |    2 +-
 5 files changed, 9 insertions(+), 45 deletions(-)

diff --git a/changes/bug2917 b/changes/bug2917
new file mode 100644
index 0000000..6b1e643
--- /dev/null
+++ b/changes/bug2917
@@ -0,0 +1,4 @@
+  o Minor bugfixes
+    - Make the SIGNAL DUMP control-port command work on FreeBSD.  Fixes
+      bug 2917.  Bugfix on 0.1.1.1-alpha.
+
diff --git a/src/or/control.c b/src/or/control.c
index 8f3af0b..bb1c330 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -1222,7 +1222,8 @@ handle_control_signal(control_connection_t *conn, uint32_t len,
   /* Flush the "done" first if the signal might make us shut down. */
   if (sig == SIGTERM || sig == SIGINT)
     connection_handle_write(TO_CONN(conn), 1);
-  control_signal_act(sig);
+  signal_callback(0,0,(void*)(uintptr_t)sig);
+
   return 0;
 }
 
diff --git a/src/or/main.c b/src/or/main.c
index 83d1e1e..5e4d88c 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -64,7 +64,6 @@ static void dumpmemusage(int severity);
 static void dumpstats(int severity); /* log stats */
 static void conn_read_callback(int fd, short event, void *_conn);
 static void conn_write_callback(int fd, short event, void *_conn);
-static void signal_callback(int fd, short events, void *arg);
 static void second_elapsed_callback(periodic_timer_t *timer, void *args);
 static int conn_close_if_marked(int i);
 static void connection_start_reading_from_linked_conn(connection_t *conn);
@@ -1577,49 +1576,9 @@ do_main_loop(void)
   }
 }
 
-/** Used to implement the SIGNAL control command: if we accept
- * <b>the_signal</b> as a remote pseudo-signal, act on it. */
-/* We don't re-use catch() here because:
- *   1. We handle a different set of signals than those allowed in catch.
- *   2. Platforms without signal() are unlikely to define SIGfoo.
- *   3. The control spec is defined to use fixed numeric signal values
- *      which just happen to match the Unix values.
- */
-void
-control_signal_act(int the_signal)
-{
-  switch (the_signal)
-    {
-    case 1:
-      signal_callback(0,0,(void*)(uintptr_t)SIGHUP);
-      break;
-    case 2:
-      signal_callback(0,0,(void*)(uintptr_t)SIGINT);
-      break;
-    case 10:
-      signal_callback(0,0,(void*)(uintptr_t)SIGUSR1);
-      break;
-    case 12:
-      signal_callback(0,0,(void*)(uintptr_t)SIGUSR2);
-      break;
-    case 15:
-      signal_callback(0,0,(void*)(uintptr_t)SIGTERM);
-      break;
-    case SIGNEWNYM:
-      signal_callback(0,0,(void*)(uintptr_t)SIGNEWNYM);
-      break;
-    case SIGCLEARDNSCACHE:
-      signal_callback(0,0,(void*)(uintptr_t)SIGCLEARDNSCACHE);
-      break;
-    default:
-      log_warn(LD_BUG, "Unrecognized signal number %d.", the_signal);
-      break;
-    }
-}
-
 /** Libevent callback: invoked when we get a signal.
  */
-static void
+void
 signal_callback(int fd, short events, void *arg)
 {
   uintptr_t sig = (uintptr_t)arg;
diff --git a/src/or/main.h b/src/or/main.h
index ed0fb97..626bf1c 100644
--- a/src/or/main.h
+++ b/src/or/main.h
@@ -46,8 +46,8 @@ void directory_info_has_arrived(time_t now, int from_cache);
 void ip_address_changed(int at_interface);
 void dns_servers_relaunch_checks(void);
 
-void control_signal_act(int the_signal);
 void handle_signals(int is_parent);
+void signal_callback(int fd, short events, void *arg);
 
 int try_locking(or_options_t *options, int err_if_locked);
 int have_lockfile(void);
diff --git a/src/or/or.h b/src/or/or.h
index 1688a08..06e6d7f 100644
--- a/src/or/or.h
+++ b/src/or/or.h
@@ -91,7 +91,7 @@
 #include "compat_libevent.h"
 #include "ht.h"
 
-/* These signals are defined to help control_signal_act work.
+/* These signals are defined to help handle_control_signal work.
  */
 #ifndef SIGHUP
 #define SIGHUP 1





More information about the tor-commits mailing list