From f810a1afe990788cd8f944a515a493902df84ed1 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Tue, 26 Apr 2011 15:20:08 -0400 Subject: [PATCH] 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. --- src/or/control.c | 3 ++- src/or/main.c | 10 +++++++++- src/or/main.h | 2 +- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/or/control.c b/src/or/control.c index bb1c3307af..9f7739a402 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); - signal_callback(0,0,(void*)(uintptr_t)sig); + + process_signal(sig); return 0; } diff --git a/src/or/main.c b/src/or/main.c index 5e4d88cf96..169956849c 100644 --- a/src/or/main.c +++ b/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 sig */ +void +process_signal(uintptr_t sig) +{ switch (sig) { case SIGTERM: diff --git a/src/or/main.h b/src/or/main.h index 626bf1c43b..0551f7aaf9 100644 --- a/src/or/main.h +++ b/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);