mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
r7411@Kushana: nickm | 2006-08-17 19:00:25 -0400
patch suggested by Karsten Loesing: respond to SIGNAL command before we execute the signal, in case the signal shuts us down. svn:r7072
This commit is contained in:
+5
-3
@@ -1152,15 +1152,17 @@ handle_control_signal(control_connection_t *conn, uint32_t len,
|
||||
if (sig<0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (control_signal_act(sig) < 0) {
|
||||
|
||||
if (!control_signal_check(sig)) {
|
||||
if (STATE_IS_V0(conn->_base.state))
|
||||
send_control0_error(conn, ERR_SYNTAX, "Unrecognized signal number.");
|
||||
else
|
||||
connection_write_str_to_buf("551 Internal error acting on signal\r\n",
|
||||
connection_write_str_to_buf("551 Unable to act on signal\r\n",
|
||||
conn);
|
||||
} else {
|
||||
/* Send DONE first, in case the signal makes us shut down. */
|
||||
send_control_done(conn);
|
||||
control_signal_act(sig);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+22
-5
@@ -1196,16 +1196,33 @@ do_main_loop(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* DOCDOC */
|
||||
int
|
||||
control_signal_check(int the_signal)
|
||||
{
|
||||
switch (the_signal)
|
||||
{
|
||||
case 1:
|
||||
case 2:
|
||||
case 10:
|
||||
case 12:
|
||||
case 15:
|
||||
case SIGNEWNYM:
|
||||
return 1;
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/** Used to implement the SIGNAL control command: if we accept
|
||||
* <b>the_signal</b> as a remote pseudo-signal, then act on it and
|
||||
* return 0. Else return -1. */
|
||||
* <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.
|
||||
*/
|
||||
int
|
||||
void
|
||||
control_signal_act(int the_signal)
|
||||
{
|
||||
switch (the_signal)
|
||||
@@ -1229,9 +1246,9 @@ control_signal_act(int the_signal)
|
||||
signal_callback(0,0,(void*)(uintptr_t)SIGNEWNYM);
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
log_warn(LD_BUG, "Unrecognized signal number %d.", the_signal);
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** Libevent callback: invoked when we get a signal.
|
||||
|
||||
+2
-1
@@ -2174,7 +2174,8 @@ void connection_start_writing(connection_t *conn);
|
||||
void directory_all_unreachable(time_t now);
|
||||
void directory_info_has_arrived(time_t now, int from_cache);
|
||||
|
||||
int control_signal_act(int the_signal);
|
||||
int control_signal_check(int the_signal);
|
||||
void control_signal_act(int the_signal);
|
||||
void handle_signals(int is_parent);
|
||||
void tor_cleanup(void);
|
||||
void tor_free_all(int postfork);
|
||||
|
||||
Reference in New Issue
Block a user