Parcourir la source

Expose a new process_signal(uintptr_t), not signal_callback()

This is a tweak to the bug2917 fix.  Basically, if we want to simulate
a signal arriving in the controller, we shouldn't have to pretend that
we're Libevent, or depend on how Tor sets up its Libevent callbacks.
Nick Mathewson il y a 13 ans
Parent
commit
f810a1afe9
3 fichiers modifiés avec 12 ajouts et 3 suppressions
  1. 2 1
      src/or/control.c
  2. 9 1
      src/or/main.c
  3. 1 1
      src/or/main.h

+ 2 - 1
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);
-  signal_callback(0,0,(void*)(uintptr_t)sig);
+
+  process_signal(sig);
 
   return 0;
 }

+ 9 - 1
src/or/main.c

@@ -1578,12 +1578,20 @@ do_main_loop(void)
 
 /** Libevent callback: invoked when we get a signal.
  */
-void
+static void
 signal_callback(int fd, short events, void *arg)
 {
   uintptr_t sig = (uintptr_t)arg;
   (void)fd;
   (void)events;
+
+  process_signal(sig);
+}
+
+/** Do the work of acting on a signal received in <b>sig</b> */
+void
+process_signal(uintptr_t sig)
+{
   switch (sig)
     {
     case SIGTERM:

+ 1 - 1
src/or/main.h

@@ -47,7 +47,7 @@ void ip_address_changed(int at_interface);
 void dns_servers_relaunch_checks(void);
 
 void handle_signals(int is_parent);
-void signal_callback(int fd, short events, void *arg);
+void process_signal(uintptr_t sig);
 
 int try_locking(or_options_t *options, int err_if_locked);
 int have_lockfile(void);