[or-cvs] Backport fix to bug 44

Nick Mathewson nickm at seul.org
Wed Mar 23 20:33:56 UTC 2005


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

Modified Files:
      Tag: tor-0_0_9-patches
	main.c 
Log Message:
Backport fix to bug 44

Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.407.2.14
retrieving revision 1.407.2.15
diff -u -d -r1.407.2.14 -r1.407.2.15
--- main.c	23 Feb 2005 04:58:17 -0000	1.407.2.14
+++ main.c	23 Mar 2005 20:33:53 -0000	1.407.2.15
@@ -791,16 +791,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