summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoger Dingledine <arma@torproject.org>2006-07-17 06:54:28 +0000
committerRoger Dingledine <arma@torproject.org>2006-07-17 06:54:28 +0000
commit31e11a2cb000e1ae47fad5898492d1e67a63e5da (patch)
tree1d66c0b460d32f6fe764d6fb1be1a6213b00a809
parentf53cbeeb68b97438145067ca418e1ab35d867471 (diff)
downloadtor-31e11a2cb000e1ae47fad5898492d1e67a63e5da.tar.gz
tor-31e11a2cb000e1ae47fad5898492d1e67a63e5da.zip
fix some more places where we shouldn't crash if we can't build
our own descriptor yet. svn:r6775
-rw-r--r--trunk/src/or/circuitbuild.c3
-rw-r--r--trunk/src/or/main.c2
-rw-r--r--trunk/src/or/router.c25
3 files changed, 11 insertions, 19 deletions
diff --git a/trunk/src/or/circuitbuild.c b/trunk/src/or/circuitbuild.c
index e6d13d6673..5eebf0b10b 100644
--- a/trunk/src/or/circuitbuild.c
+++ b/trunk/src/or/circuitbuild.c
@@ -181,7 +181,8 @@ circuit_rep_hist_note_result(circuit_t *circ)
}
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 {
diff --git a/trunk/src/or/main.c b/trunk/src/or/main.c
index 7b2364a4f9..f6f314c4a1 100644
--- a/trunk/src/or/main.c
+++ b/trunk/src/or/main.c
@@ -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);
diff --git a/trunk/src/or/router.c b/trunk/src/or/router.c
index 0e577a8031..987a707984 100644
--- a/trunk/src/or/router.c
+++ b/trunk/src/or/router.c
@@ -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 force)
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)