diff options
author | John Brooks <john.brooks@dereferenced.net> | 2010-11-14 14:33:55 -0800 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2010-11-19 15:49:54 -0500 |
commit | 7441999738e7c1b0ea94a39dd6e1f8a48043ff7d (patch) | |
tree | 7dc6314277e4f9cd412de4946663a3e259c56bca /src/or/control.c | |
parent | 4f66bf4fe7ec4c52ba97a81c40cf824a8ccb6cbb (diff) | |
download | tor-7441999738e7c1b0ea94a39dd6e1f8a48043ff7d.tar.gz tor-7441999738e7c1b0ea94a39dd6e1f8a48043ff7d.zip |
Add a SIGNAL event for control connections
Implements ticket #1955
Diffstat (limited to 'src/or/control.c')
-rw-r--r-- | src/or/control.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/src/or/control.c b/src/or/control.c index a2c9e467f5..6cb986e2b5 100644 --- a/src/or/control.c +++ b/src/or/control.c @@ -65,7 +65,8 @@ #define EVENT_CLIENTS_SEEN 0x0015 #define EVENT_NEWCONSENSUS 0x0016 #define EVENT_BUILDTIMEOUT_SET 0x0017 -#define _EVENT_MAX 0x0017 +#define EVENT_SIGNAL 0x0018 +#define _EVENT_MAX 0x0018 /* If _EVENT_MAX ever hits 0x0020, we need to make the mask wider. */ /** Bitfield: The bit 1<<e is set if <b>any</b> open control @@ -946,6 +947,8 @@ handle_control_setevents(control_connection_t *conn, uint32_t len, event_code = EVENT_NEWCONSENSUS; else if (!strcasecmp(ev, "BUILDTIMEOUT_SET")) event_code = EVENT_BUILDTIMEOUT_SET; + else if (!strcasecmp(ev, "SIGNAL")) + event_code = EVENT_SIGNAL; else { connection_printf_to_buf(conn, "552 Unrecognized event \"%s\"\r\n", ev); @@ -3589,6 +3592,40 @@ control_event_buildtimeout_set(const circuit_build_times_t *cbt, return 0; } +/** Called when a signal has been processed from signal_callback */ +int +control_event_signal(uintptr_t signal) +{ + const char *signal_string = NULL; + + if (!control_event_is_interesting(EVENT_SIGNAL)) + return 0; + + switch (signal) { + case SIGHUP: + signal_string = "RELOAD"; + break; + case SIGUSR1: + signal_string = "DUMP"; + break; + case SIGUSR2: + signal_string = "DEBUG"; + break; + case SIGNEWNYM: + signal_string = "NEWNYM"; + break; + case SIGCLEARDNSCACHE: + signal_string = "CLEARDNSCACHE"; + break; + default: + log_warn(LD_BUG, "Unrecognized signal %lu in control_event_signal", signal); + return -1; + } + + send_control_event(EVENT_SIGNAL, ALL_FORMATS, "650 SIGNAL %s\r\n", signal_string); + return 0; +} + /** Called when a single local_routerstatus_t has changed: Sends an NS event * to any controller that cares. */ int |