|
@@ -50,6 +50,7 @@ static int nfds=0;
|
|
|
|
|
|
#ifndef MS_WINDOWS
|
|
|
static int please_dumpstats=0;
|
|
|
+static int please_debug=0;
|
|
|
static int please_reset=0;
|
|
|
static int please_reap_children=0;
|
|
|
static int please_sigpipe=0;
|
|
@@ -815,7 +816,7 @@ static int do_main_loop(void) {
|
|
|
}
|
|
|
#endif
|
|
|
#ifndef MS_WINDOWS
|
|
|
- if(please_shutdown) {
|
|
|
+ if (please_shutdown) {
|
|
|
if(!server_mode(get_options())) {
|
|
|
log(LOG_NOTICE,"Interrupt: exiting cleanly.");
|
|
|
tor_cleanup();
|
|
@@ -824,16 +825,20 @@ static int do_main_loop(void) {
|
|
|
hibernate_begin_shutdown();
|
|
|
please_shutdown = 0;
|
|
|
}
|
|
|
- if(please_sigpipe) {
|
|
|
+ if (please_sigpipe) {
|
|
|
log(LOG_NOTICE,"Caught sigpipe. Ignoring.");
|
|
|
please_sigpipe = 0;
|
|
|
}
|
|
|
- if(please_dumpstats) {
|
|
|
+ if (please_dumpstats) {
|
|
|
|
|
|
dumpstats(get_min_log_level()<LOG_INFO ? get_min_log_level() : LOG_INFO);
|
|
|
please_dumpstats = 0;
|
|
|
}
|
|
|
- if(please_reset) {
|
|
|
+ if (please_debug) {
|
|
|
+ switch_logs_debug();
|
|
|
+ please_debug = 0;
|
|
|
+ }
|
|
|
+ if (please_reset) {
|
|
|
if (do_hup() < 0) {
|
|
|
log_fn(LOG_WARN,"Restart failed (config error?). Exiting.");
|
|
|
tor_cleanup();
|
|
@@ -841,7 +846,7 @@ static int do_main_loop(void) {
|
|
|
}
|
|
|
please_reset = 0;
|
|
|
}
|
|
|
- if(please_reap_children) {
|
|
|
+ if (please_reap_children) {
|
|
|
while(waitpid(-1,NULL,WNOHANG) > 0) ;
|
|
|
please_reap_children = 0;
|
|
|
}
|
|
@@ -853,7 +858,7 @@ static int do_main_loop(void) {
|
|
|
poll_result = tor_poll(poll_array, nfds, timeout);
|
|
|
|
|
|
|
|
|
- if(poll_result < 0) {
|
|
|
+ if (poll_result < 0) {
|
|
|
|
|
|
if(tor_socket_errno(-1) != EINTR) {
|
|
|
log_fn(LOG_ERR,"poll failed: %s [%d]",
|
|
@@ -869,15 +874,15 @@ static int do_main_loop(void) {
|
|
|
}
|
|
|
|
|
|
|
|
|
- for(i=0;i<nfds;i++)
|
|
|
+ for (i=0;i<nfds;i++)
|
|
|
conn_read(i);
|
|
|
|
|
|
|
|
|
- for(i=0;i<nfds;i++)
|
|
|
+ for (i=0;i<nfds;i++)
|
|
|
conn_write(i);
|
|
|
|
|
|
|
|
|
- for(i=0;i<nfds;i++)
|
|
|
+ for (i=0;i<nfds;i++)
|
|
|
conn_close_if_marked(i);
|
|
|
|
|
|
|
|
@@ -910,6 +915,9 @@ static void catch(int the_signal) {
|
|
|
case SIGUSR1:
|
|
|
please_dumpstats = 1;
|
|
|
break;
|
|
|
+ case SIGUSR2:
|
|
|
+ please_debug = 1;
|
|
|
+ break;
|
|
|
case SIGCHLD:
|
|
|
please_reap_children = 1;
|
|
|
break;
|