[or-cvs] Fix bug 44: on HUP, if descriptor building fails (say, beca...

Nick Mathewson nickm at seul.org
Wed Mar 23 20:28:48 UTC 2005


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

Modified Files:
	main.c 
Log Message:
Fix bug 44: on HUP, if descriptor building fails (say, because router_get_my_address() fails), use old descriptor and warn.

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.468
retrieving revision 1.469
diff -u -d -r1.468 -r1.469
--- main.c	22 Mar 2005 23:27:29 -0000	1.468
+++ main.c	23 Mar 2005 20:28:40 -0000	1.469
@@ -965,16 +965,23 @@
   /* Fetch a new directory. Even authdirservers do this. */
   directory_get_from_dirserver(DIR_PURPOSE_FETCH_DIR, NULL, 1);
   if (server_mode(options)) {
+    const char *descriptor;
     /* Restart cpuworker and dnsworker processes, so they get up-to-date
      * configuration options. */
     cpuworkers_rotate();
     dnsworkers_rotate();
-    /* Rebuild fresh descriptor. */
+    /* Rebuild fresh descriptor, but leave old one on failure. */
     router_rebuild_descriptor(1);
-    tor_snprintf(keydir,sizeof(keydir),"%s/router.desc", options->DataDirectory);
+    descriptor = router_get_my_descriptor();
+    if (!descriptor) {
+      log_fn(LOG_WARN,"No descriptor to save.");
+      return 0;
+    }
+    tor_snprintf(keydir,sizeof(keydir),"%s/router.desc",
+                 options->DataDirectory);
     log_fn(LOG_INFO,"Saving descriptor to %s...",keydir);
-    if (write_str_to_file(keydir, router_get_my_descriptor(), 0)) {
-      return -1;
+    if (write_str_to_file(keydir, descriptor, 0)) {
+      return 0;
     }
   }
   return 0;



More information about the tor-commits mailing list