[or-cvs] Break tor_main into startup/loop/shutdown portions, to make...

Nick Mathewson nickm at seul.org
Sat Jun 12 19:45:48 UTC 2004


Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/tmp/cvs-serv25191/src/or

Modified Files:
	main.c 
Log Message:
Break tor_main into startup/loop/shutdown portions, to make NT service refactoring possible.

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.281
retrieving revision 1.282
diff -u -d -r1.281 -r1.282
--- main.c	6 Jun 2004 03:38:31 -0000	1.281
+++ main.c	12 Jun 2004 19:45:46 -0000	1.282
@@ -870,7 +870,7 @@
 
 /** 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 @@
 
   if (network_init()<0) {
     log_fn(LOG_ERR,"Error initializing network; exiting.");
-    return 1;
+    return -1;
   }
   atexit(exit_function);
 
@@ -915,8 +915,18 @@
 
   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;
 }
 



More information about the tor-commits mailing list