diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-10-20 10:25:55 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2017-10-20 11:39:17 -0400 |
commit | 9bafc3b1efd64b19695cd78fb51070ff8d3939f5 (patch) | |
tree | c18ef1fbd3e7c2884aa17fb1769378e7680b0a12 /src/or | |
parent | c82cc8acb5aa43b3d96490d927dcc622f2c825e3 (diff) | |
download | tor-9bafc3b1efd64b19695cd78fb51070ff8d3939f5.tar.gz tor-9bafc3b1efd64b19695cd78fb51070ff8d3939f5.zip |
Replace most bad exits in main.c, hibernate.c
This should make most of the reasons that we hibernate cleaner.
Diffstat (limited to 'src/or')
-rw-r--r-- | src/or/hibernate.c | 7 | ||||
-rw-r--r-- | src/or/main.c | 11 |
2 files changed, 8 insertions, 10 deletions
diff --git a/src/or/hibernate.c b/src/or/hibernate.c index be2bc7ce95..8f665a15a4 100644 --- a/src/or/hibernate.c +++ b/src/or/hibernate.c @@ -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 */ } diff --git a/src/or/main.c b/src/or/main.c index c3822dd94a..4d252faf20 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -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"); |