fix some more places where we shouldn't crash if we can't build

our own descriptor yet.


svn:r6775
This commit is contained in:
Roger Dingledine 2006-07-17 06:54:28 +00:00
parent 9db7b2c068
commit 42e2057d67
3 changed files with 11 additions and 19 deletions

View File

@ -181,7 +181,8 @@ circuit_rep_hist_note_result(circuit_t *circ)
} }
if (server_mode(get_options())) { if (server_mode(get_options())) {
routerinfo_t *me = router_get_my_routerinfo(); routerinfo_t *me = router_get_my_routerinfo();
tor_assert(me); if (!me)
return;
prev_digest = me->cache_info.identity_digest; prev_digest = me->cache_info.identity_digest;
} }
do { do {

View File

@ -731,7 +731,7 @@ run_scheduled_events(time_t now)
rotate_onion_key(); rotate_onion_key();
cpuworkers_rotate(); cpuworkers_rotate();
if (router_rebuild_descriptor(1)<0) { 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()) if (advertised_server_mode())
router_upload_dir_desc_to_dirservers(0); router_upload_dir_desc_to_dirservers(0);

View File

@ -232,7 +232,8 @@ init_key_from_file(const char *fname)
} }
/** Initialize all OR private keys, and the TLS context, as necessary. /** 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 int
init_keys(void) init_keys(void)
@ -310,10 +311,6 @@ init_keys(void)
/* 4. Build our router descriptor. */ /* 4. Build our router descriptor. */
/* Must be called after keys are initialized. */ /* Must be called after keys are initialized. */
mydesc = router_get_my_descriptor(); mydesc = router_get_my_descriptor();
if (!mydesc) {
log_err(LD_GENERAL,"Error initializing descriptor.");
return -1;
}
if (authdir_mode(options)) { if (authdir_mode(options)) {
const char *m; const char *m;
/* We need to add our own fingerprint so it gets recognized. */ /* 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"); log_err(LD_GENERAL,"Error adding own fingerprint to approved set");
return -1; return -1;
} }
if (!mydesc) {
log_err(LD_GENERAL,"Error initializing descriptor.");
return -1;
}
if (dirserv_add_descriptor(mydesc, &m) < 0) { if (dirserv_add_descriptor(mydesc, &m) < 0) {
log_err(LD_GENERAL,"Unable to add own descriptor to directory: %s", log_err(LD_GENERAL,"Unable to add own descriptor to directory: %s",
m?m:"<unknown error>"); 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' */ /* 5. Dump fingerprint to 'fingerprint' */
tor_snprintf(keydir,sizeof(keydir),"%s/fingerprint", datadir); tor_snprintf(keydir,sizeof(keydir),"%s/fingerprint", datadir);
log_info(LD_GENERAL,"Dumping fingerprint to \"%s\"...",keydir); log_info(LD_GENERAL,"Dumping fingerprint to \"%s\"...",keydir);
@ -447,11 +441,8 @@ void
consider_testing_reachability(void) consider_testing_reachability(void)
{ {
routerinfo_t *me = router_get_my_routerinfo(); routerinfo_t *me = router_get_my_routerinfo();
if (!me) { if (!me)
log_warn(LD_BUG,
"Bug: router_get_my_routerinfo() did not find my routerinfo?");
return; return;
}
if (!check_whether_orport_reachable()) { if (!check_whether_orport_reachable()) {
log_info(LD_CIRC, "Testing reachability of my ORPort: %s:%d.", 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(); s = router_get_my_descriptor();
if (!s) { if (!s) {
log_warn(LD_GENERAL, "No descriptor; skipping upload"); log_info(LD_GENERAL, "No descriptor; skipping upload");
return; return;
} }
if (!get_options()->PublishServerDescriptor) if (!get_options()->PublishServerDescriptor)