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

[or-cvs] fix some more places where we shouldn"t crash if we can"t b...



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

Modified Files:
	circuitbuild.c main.c router.c 
Log Message:
fix some more places where we shouldn't crash if we can't build
our own descriptor yet.


Index: circuitbuild.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/circuitbuild.c,v
retrieving revision 1.254
retrieving revision 1.255
diff -u -p -d -r1.254 -r1.255
--- circuitbuild.c	5 Jul 2006 18:19:42 -0000	1.254
+++ circuitbuild.c	17 Jul 2006 06:54:28 -0000	1.255
@@ -181,7 +181,8 @@ circuit_rep_hist_note_result(circuit_t *
   }
   if (server_mode(get_options())) {
     routerinfo_t *me = router_get_my_routerinfo();
-    tor_assert(me);
+    if (!me)
+      return;
     prev_digest = me->cache_info.identity_digest;
   }
   do {

Index: main.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.650
retrieving revision 1.651
diff -u -p -d -r1.650 -r1.651
--- main.c	17 Jul 2006 00:39:05 -0000	1.650
+++ main.c	17 Jul 2006 06:54:28 -0000	1.651
@@ -731,7 +731,7 @@ run_scheduled_events(time_t now)
     rotate_onion_key();
     cpuworkers_rotate();
     if (router_rebuild_descriptor(1)<0) {
-      log_warn(LD_BUG, "Couldn't rebuild router descriptor");
+      log_info(LD_CONFIG, "Couldn't rebuild router descriptor");
     }
     if (advertised_server_mode())
       router_upload_dir_desc_to_dirservers(0);

Index: router.c
===================================================================
RCS file: /home2/or/cvsroot/tor/src/or/router.c,v
retrieving revision 1.270
retrieving revision 1.271
diff -u -p -d -r1.270 -r1.271
--- router.c	17 Jul 2006 06:35:06 -0000	1.270
+++ router.c	17 Jul 2006 06:54:28 -0000	1.271
@@ -232,7 +232,8 @@ init_key_from_file(const char *fname)
 }
 
 /** Initialize all OR private keys, and the TLS context, as necessary.
- * On OPs, this only initializes the tls context.
+ * On OPs, this only initializes the tls context. Return 0 on success,
+ * or -1 if Tor should die.
  */
 int
 init_keys(void)
@@ -310,10 +311,6 @@ init_keys(void)
   /* 4. Build our router descriptor. */
   /* Must be called after keys are initialized. */
   mydesc = router_get_my_descriptor();
-  if (!mydesc) {
-    log_err(LD_GENERAL,"Error initializing descriptor.");
-    return -1;
-  }
   if (authdir_mode(options)) {
     const char *m;
     /* We need to add our own fingerprint so it gets recognized. */
@@ -321,6 +318,10 @@ init_keys(void)
       log_err(LD_GENERAL,"Error adding own fingerprint to approved set");
       return -1;
     }
+    if (!mydesc) {
+      log_err(LD_GENERAL,"Error initializing descriptor.");
+      return -1;
+    }
     if (dirserv_add_descriptor(mydesc, &m) < 0) {
       log_err(LD_GENERAL,"Unable to add own descriptor to directory: %s",
               m?m:"<unknown error>");
@@ -328,13 +329,6 @@ init_keys(void)
     }
   }
 
-#if 0
-  tor_snprintf(keydir,sizeof(keydir),"%s/router.desc", datadir);
-  log_info(LD_GENERAL,"Dumping descriptor to \"%s\"...",keydir);
-  if (write_str_to_file(keydir, mydesc,0)) {
-    return -1;
-  }
-#endif
   /* 5. Dump fingerprint to 'fingerprint' */
   tor_snprintf(keydir,sizeof(keydir),"%s/fingerprint", datadir);
   log_info(LD_GENERAL,"Dumping fingerprint to \"%s\"...",keydir);
@@ -447,11 +441,8 @@ void
 consider_testing_reachability(void)
 {
   routerinfo_t *me = router_get_my_routerinfo();
-  if (!me) {
-    log_warn(LD_BUG,
-             "Bug: router_get_my_routerinfo() did not find my routerinfo?");
+  if (!me)
     return;
-  }
 
   if (!check_whether_orport_reachable()) {
     log_info(LD_CIRC, "Testing reachability of my ORPort: %s:%d.",
@@ -644,7 +635,7 @@ router_upload_dir_desc_to_dirservers(int
 
   s = router_get_my_descriptor();
   if (!s) {
-    log_warn(LD_GENERAL, "No descriptor; skipping upload");
+    log_info(LD_GENERAL, "No descriptor; skipping upload");
     return;
   }
   if (!get_options()->PublishServerDescriptor)