diff options
author | Nick Mathewson <nickm@torproject.org> | 2017-12-11 10:57:00 -0500 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2018-01-19 09:52:05 -0500 |
commit | 97d9ba2380e0c894a1b611bdb4f35d0fe98a837a (patch) | |
tree | d1a9593e143ad0e5aa78cca0e876c03baad29aa9 /src/or/tor_main.c | |
parent | ea929e8456d065a25d7eb5e2e0e41e0f303ebe9d (diff) | |
download | tor-97d9ba2380e0c894a1b611bdb4f35d0fe98a837a.tar.gz tor-97d9ba2380e0c894a1b611bdb4f35d0fe98a837a.zip |
Add a mostly disabled feature to debug restarting in-process
For 23847, we want Tor to be able to shut down and then restart in
the same process. Here's a patch to make the Tor binary do that.
To test it, you need to build with --enable-restart-debugging, and
then you need to set the environment variable TOR_DEBUG_RESTART.
With this option, Tor will then run for 5 seconds, then restart
itself in-process without exiting. This only happens once.
You can change the 5-second interval using
TOR_DEBUG_RESTART_AFTER_SECONDS.
Implements ticket 24583.
Diffstat (limited to 'src/or/tor_main.c')
-rw-r--r-- | src/or/tor_main.c | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/or/tor_main.c b/src/or/tor_main.c index c203d8248f..703669ac99 100644 --- a/src/or/tor_main.c +++ b/src/or/tor_main.c @@ -3,6 +3,11 @@ * Copyright (c) 2007-2017, The Tor Project, Inc. */ /* See LICENSE for licensing information */ +#include "orconfig.h" +#ifdef ENABLE_RESTART_DEBUGGING +#include <stdlib.h> +#endif + /** * \file tor_main.c * \brief Stub module containing a main() function. @@ -19,9 +24,18 @@ int tor_main(int argc, char *argv[]); int main(int argc, char *argv[]) { - int r = tor_main(argc, argv); + int r; +#ifdef ENABLE_RESTART_DEBUGGING + int restart_count = getenv("TOR_DEBUG_RESTART") ? 1 : 0; + again: +#endif + r = tor_main(argc, argv); if (r < 0 || r > 255) return 1; +#ifdef ENABLE_RESTART_DEBUGGING + else if (r == 0 && restart_count--) + goto again; +#endif else return r; } |