diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-06-29 13:53:27 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2020-06-29 13:53:27 -0400 |
commit | a692b87f82152c01a9991f11a60f36d3b6f1bddd (patch) | |
tree | 78f112525d57fbad203605532b59d5f70d2fecc5 /src/feature | |
parent | 0575a182a633429e755dc4366eced76656461d9b (diff) | |
parent | b2c3cb1b26c41969776ed1fd1b20588430346e45 (diff) | |
download | tor-a692b87f82152c01a9991f11a60f36d3b6f1bddd.tar.gz tor-a692b87f82152c01a9991f11a60f36d3b6f1bddd.zip |
Merge remote-tracking branch 'tor-github/pr/1696/head' into maint-0.4.2
Diffstat (limited to 'src/feature')
-rw-r--r-- | src/feature/control/control.c | 4 | ||||
-rw-r--r-- | src/feature/control/control_events.c | 32 |
2 files changed, 14 insertions, 22 deletions
diff --git a/src/feature/control/control.c b/src/feature/control/control.c index d6581808c0..ece5616907 100644 --- a/src/feature/control/control.c +++ b/src/feature/control/control.c @@ -158,6 +158,10 @@ control_ports_write_to_file(void) } const struct signal_name_t signal_table[] = { + /* NOTE: this table is used for handling SIGNAL commands and generating + * SIGNAL events. Order is significant: if there are two entries for the + * same numeric signal, the first one is the canonical name generated + * for the events. */ { SIGHUP, "RELOAD" }, { SIGHUP, "HUP" }, { SIGINT, "SHUTDOWN" }, diff --git a/src/feature/control/control_events.c b/src/feature/control/control_events.c index 82ea943999..8cf6d6de0b 100644 --- a/src/feature/control/control_events.c +++ b/src/feature/control/control_events.c @@ -1552,29 +1552,17 @@ control_event_signal(uintptr_t signal_num) if (!control_event_is_interesting(EVENT_GOT_SIGNAL)) return 0; - switch (signal_num) { - case SIGHUP: - signal_string = "RELOAD"; + for (unsigned i = 0; signal_table[i].signal_name != NULL; ++i) { + if ((int)signal_num == signal_table[i].sig) { + signal_string = signal_table[i].signal_name; 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; - case SIGHEARTBEAT: - signal_string = "HEARTBEAT"; - break; - default: - log_warn(LD_BUG, "Unrecognized signal %lu in control_event_signal", - (unsigned long)signal_num); - return -1; + } + } + + if (signal_string == NULL) { + log_warn(LD_BUG, "Unrecognized signal %lu in control_event_signal", + (unsigned long)signal_num); + return -1; } send_control_event(EVENT_GOT_SIGNAL, "650 SIGNAL %s\r\n", |