[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] stop using atexit() to remove our pid, since it"s called



Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home2/arma/work/onion/cvs/src/or

Modified Files:
	cpuworker.c directory.c dirserv.c dns.c main.c or.h 
	rendservice.c routerparse.c test.c 
Log Message:
stop using atexit() to remove our pid, since it's called
immediately when we daemonize.

also drop our retry period for hidserv desc uploads from 10m to 5m


Index: cpuworker.c
===================================================================
RCS file: /home/or/cvsroot/src/or/cpuworker.c,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -d -r1.47 -r1.48
--- cpuworker.c	16 Jul 2004 21:47:18 -0000	1.47
+++ cpuworker.c	22 Jul 2004 22:15:36 -0000	1.48
@@ -268,6 +268,7 @@
   if(tor_socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) {
     log(LOG_ERR, "Couldn't construct socketpair: %s",
         tor_socket_strerror(tor_socket_errno(-1)));
+    tor_cleanup();
     exit(1);
   }
 

Index: directory.c
===================================================================
RCS file: /home/or/cvsroot/src/or/directory.c,v
retrieving revision 1.119
retrieving revision 1.120
diff -u -d -r1.119 -r1.120
--- directory.c	21 Jul 2004 08:40:57 -0000	1.119
+++ directory.c	22 Jul 2004 22:15:36 -0000	1.120
@@ -66,6 +66,8 @@
 
   for(i=0; i < smartlist_len(rl->routers); i++) {
     router = smartlist_get(rl->routers, i);
+    /* Note: this posts our descriptor to ourselves, if we're an
+     * authdirserver. But I think that's ok. */
     if(router->is_trusted_dir)
       directory_initiate_command(router, purpose, payload, payload_len);
   }

Index: dirserv.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dirserv.c,v
retrieving revision 1.67
retrieving revision 1.68
diff -u -d -r1.67 -r1.68
--- dirserv.c	22 Jul 2004 21:31:04 -0000	1.67
+++ dirserv.c	22 Jul 2004 22:15:36 -0000	1.68
@@ -670,6 +670,7 @@
     /* use a new copy of the dir, since get_dir_from_string scribbles on it */
     if (router_load_routerlist_from_directory(new_directory, get_identity_key())) {
       log_fn(LOG_ERR, "We just generated a directory we can't parse. Dying.");
+      tor_cleanup();
       exit(0);
     }
     free(new_directory);

Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.102
retrieving revision 1.103
diff -u -d -r1.102 -r1.103
--- dns.c	6 Jul 2004 23:25:21 -0000	1.102
+++ dns.c	22 Jul 2004 22:15:36 -0000	1.103
@@ -691,6 +691,7 @@
   if(tor_socketpair(AF_UNIX, SOCK_STREAM, 0, fd) < 0) {
     log(LOG_ERR, "Couldn't construct socketpair: %s",
         tor_socket_strerror(tor_socket_errno(-1)));
+    tor_cleanup();
     exit(1);
   }
 

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.305
retrieving revision 1.306
diff -u -d -r1.305 -r1.306
--- main.c	22 Jul 2004 04:20:26 -0000	1.305
+++ main.c	22 Jul 2004 22:15:36 -0000	1.306
@@ -496,6 +496,7 @@
    */
   if(shutting_down && shutting_down <= now) {
     log(LOG_NOTICE,"Clean shutdown finished. Exiting.");
+    tor_cleanup();
     exit(0);
   }
 
@@ -722,11 +723,13 @@
   /* first, reload config variables, in case they've changed */
   /* no need to provide argc/v, they've been cached inside init_from_config */
   if (init_from_config(0, NULL) < 0) {
+    tor_cleanup();
     exit(1);
   }
   /* reload keys as needed for rendezvous services. */
   if (rend_service_load_keys()<0) {
     log_fn(LOG_ERR,"Error reloading rendezvous service keys");
+    tor_cleanup();
     exit(1);
   }
   if(retry_all_listeners() < 0) {
@@ -815,10 +818,12 @@
     if(please_shutdown) {
       if(!server_mode()) { /* do it now */
         log(LOG_NOTICE,"Interrupt: exiting cleanly.");
+        tor_cleanup();
         exit(0);
       }
       if(shutting_down) { /* we've already been asked. do it now. */
         log(LOG_NOTICE,"Second sigint received; exiting now.");
+        tor_cleanup();
         exit(0);
       } else {
         log(LOG_NOTICE,"Interrupt: will shut down in %d seconds. Interrupt again to exit now.", SHUTDOWN_WAIT_LENGTH);
@@ -885,6 +890,7 @@
 //    case SIGABRT:
     case SIGTERM:
       log(LOG_ERR,"Catching signal %d, exiting cleanly.", the_signal);
+      tor_cleanup();
       exit(0);
     case SIGINT:
       please_shutdown = 1;
@@ -966,7 +972,7 @@
 /** Called before we make any calls to network-related functions.
  * (Some operating systems require their network libraries to be
  * initialized.) */
-int network_init(void)
+static int network_init(void)
 {
 #ifdef MS_WINDOWS
   /* This silly exercise is necessary before windows will allow gethostbyname to work.
@@ -987,10 +993,7 @@
  */
 void exit_function(void)
 {
-  /* Remove our pid file. We don't care if there was an error when we
-   * unlink, nothing we could do about it anyways. */
-  if(options.PidFile)
-    unlink(options.PidFile);
+/* XXX if we ever daemonize, this gets called immediately */
 #ifdef MS_WINDOWS
   WSACleanup();
 #endif
@@ -998,7 +1001,7 @@
 
 /** Main entry point for the Tor command-line client.
  */
-int tor_init(int argc, char *argv[]) {
+static int tor_init(int argc, char *argv[]) {
 
   /* give it somewhere to log to initially */
   add_temp_log();
@@ -1046,7 +1049,12 @@
   return 0;
 }
 
+/** Do whatever cleanup is necessary before shutting Tor down. */
 void tor_cleanup(void) {
+  /* Remove our pid file. We don't care if there was an error when we
+   * unlink, nothing we could do about it anyways. */
+  if(options.PidFile)
+    unlink(options.PidFile);
   crypto_global_cleanup();
 }
 
@@ -1061,7 +1069,7 @@
           service_status.dwCurrentState = SERVICE_STOPPED;
           return;
   }
-  SetServiceStatus(hStatus, &service_status);     
+  SetServiceStatus(hStatus, &service_status);
 }
 
 void nt_service_body(int argc, char **argv)

Index: or.h
===================================================================
RCS file: /home/or/cvsroot/src/or/or.h,v
retrieving revision 1.393
retrieving revision 1.394
diff -u -d -r1.393 -r1.394
--- or.h	22 Jul 2004 21:31:04 -0000	1.393
+++ or.h	22 Jul 2004 22:15:36 -0000	1.394
@@ -1202,7 +1202,7 @@
 int advertised_server_mode(void);
 int proxy_mode(void);
 
-int main(int argc, char *argv[]);
+void tor_cleanup(void);
 
 /********************************* onion.c ***************************/
 

Index: rendservice.c
===================================================================
RCS file: /home/or/cvsroot/src/or/rendservice.c,v
retrieving revision 1.74
retrieving revision 1.75
diff -u -d -r1.74 -r1.75
--- rendservice.c	22 Jul 2004 08:30:06 -0000	1.74
+++ rendservice.c	22 Jul 2004 22:15:36 -0000	1.75
@@ -24,7 +24,7 @@
 #define NUM_INTRO_POINTS 3
 
 /** If we can't build our intro circuits, don't retry for this long. */
-#define INTRO_CIRC_RETRY_PERIOD 60*10
+#define INTRO_CIRC_RETRY_PERIOD 60*5
 /** Don't try to build more than this many circuits before giving up
  * for a while.*/
 #define MAX_INTRO_CIRCS_PER_PERIOD 10

Index: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/src/or/routerparse.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- routerparse.c	22 Jul 2004 20:30:02 -0000	1.18
+++ routerparse.c	22 Jul 2004 22:15:36 -0000	1.19
@@ -302,12 +302,13 @@
     return -1;
   } else {
     fflush(0);
+    tor_cleanup();
     exit(0);
     return -1; /* never reached */
   }
 }
 
-/** Parse a directory from <b>s</b> and, when done, store the
+/** Parse a directory from <b>str</b> and, when done, store the
  * resulting routerlist in *<b>dest</b>, freeing the old value if necessary.
  * If <b>pkey</b> is provided, we check the directory signature with pkey.
  */

Index: test.c
===================================================================
RCS file: /home/or/cvsroot/src/or/test.c,v
retrieving revision 1.104
retrieving revision 1.105
diff -u -d -r1.104 -r1.105
--- test.c	22 Jul 2004 20:34:55 -0000	1.104
+++ test.c	22 Jul 2004 22:15:36 -0000	1.105
@@ -858,6 +858,8 @@
   test_eq(1, is_obsolete_version("0.0.2", "Tor 0.0.2pre1,Tor 0.0.3"));
   test_eq(0, is_obsolete_version("0.1.0", "Tor 0.0.2,Tor 0.0.3"));
   test_eq(0, is_obsolete_version("0.0.7rc2", "0.0.7,Tor 0.0.7rc2,Tor 0.0.8"));
+  test_eq(0, is_obsolete_version("0.0.5", "0.0.5-cvs"));
+  test_eq(0, is_obsolete_version("0.0.5.1-cvs", "0.0.5"));
 }
 
 void test_rend_fns()