aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2004-06-12 19:45:46 +0000
committerNick Mathewson <nickm@torproject.org>2004-06-12 19:45:46 +0000
commit125b351970d52269553aeb460b418f668a63d6ce (patch)
tree488abcae0bce17b086c191ef5732aadebc08017e
parent23c1a72c4ca406e25dde5c38f1187de8666e94f0 (diff)
downloadtor-125b351970d52269553aeb460b418f668a63d6ce.tar
tor-125b351970d52269553aeb460b418f668a63d6ce.tar.gz
Break tor_main into startup/loop/shutdown portions, to make NT service refactoring possible.
svn:r1965
-rw-r--r--src/or/main.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/or/main.c b/src/or/main.c
index 7b29f1188..ce7da3cd2 100644
--- a/src/or/main.c
+++ b/src/or/main.c
@@ -870,7 +870,7 @@ void exit_function(void)
/** Main entry point for the Tor command-line client.
*/
-int tor_main(int argc, char *argv[]) {
+int tor_init(int argc, char *argv[]) {
/* give it somewhere to log to initially */
add_temp_log();
@@ -878,7 +878,7 @@ int tor_main(int argc, char *argv[]) {
if (network_init()<0) {
log_fn(LOG_ERR,"Error initializing network; exiting.");
- return 1;
+ return -1;
}
atexit(exit_function);
@@ -915,8 +915,18 @@ int tor_main(int argc, char *argv[]) {
crypto_global_init();
crypto_seed_rng();
- do_main_loop();
+ return 0;
+}
+
+void tor_cleanup(void) {
crypto_global_cleanup();
+}
+
+int tor_main(int argc, char *argv[]) {
+ if (tor_init(argc, argv)<0)
+ return -1;
+ do_main_loop();
+ tor_cleanup();
return -1;
}