Replace most bad exits in main.c, hibernate.c

This should make most of the reasons that we hibernate cleaner.
This commit is contained in:
Nick Mathewson
2017-10-20 10:25:55 -04:00
parent c82cc8acb5
commit 9bafc3b1ef
2 changed files with 8 additions and 10 deletions
+3 -4
View File
@@ -818,8 +818,8 @@ hibernate_begin(hibernate_state_t new_state, time_t now)
log_notice(LD_GENERAL,"SIGINT received %s; exiting now.",
hibernate_state == HIBERNATE_STATE_EXITING ?
"a second time" : "while hibernating");
tor_cleanup();
exit(0); // XXXX bad exit
tor_shutdown_event_loop_and_exit(0);
return;
}
if (new_state == HIBERNATE_STATE_LOWBANDWIDTH &&
@@ -980,8 +980,7 @@ consider_hibernation(time_t now)
tor_assert(shutdown_time);
if (shutdown_time <= now) {
log_notice(LD_GENERAL, "Clean shutdown finished. Exiting.");
tor_cleanup();
exit(0); // XXXX bad exit
tor_shutdown_event_loop_and_exit(0);
}
return; /* if exiting soon, don't worry about bandwidth limits */
}
+5 -6
View File
@@ -2776,14 +2776,13 @@ process_signal(int sig)
{
case SIGTERM:
log_notice(LD_GENERAL,"Catching signal TERM, exiting cleanly.");
tor_cleanup();
exit(0); // XXXX bad exit
tor_shutdown_event_loop_and_exit(0);
break;
case SIGINT:
if (!server_mode(get_options())) { /* do it now */
log_notice(LD_GENERAL,"Interrupt: exiting cleanly.");
tor_cleanup();
exit(0); // XXXX bad exit
tor_shutdown_event_loop_and_exit(0);
return;
}
#ifdef HAVE_SYSTEMD
sd_notify(0, "STOPPING=1");
@@ -2812,8 +2811,8 @@ process_signal(int sig)
#endif
if (do_hup() < 0) {
log_warn(LD_CONFIG,"Restart failed (config error?). Exiting.");
tor_cleanup();
exit(1); // XXXX bad exit
tor_shutdown_event_loop_and_exit(1);
return;
}
#ifdef HAVE_SYSTEMD
sd_notify(0, "READY=1");