diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-03-23 20:28:40 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-03-23 20:28:40 +0000 |
commit | 4ee6addf570ba8df2b72b096d32448dd403bd4c0 (patch) | |
tree | dacc143e6de9c5eedc0860340e5c3051aab82c5a /src | |
parent | 6e4bccc4acb2acdc180ecd129d0bdc928049bcf2 (diff) | |
download | tor-4ee6addf570ba8df2b72b096d32448dd403bd4c0.tar.gz tor-4ee6addf570ba8df2b72b096d32448dd403bd4c0.zip |
Fix bug 44: on HUP, if descriptor building fails (say, because router_get_my_address() fails), use old descriptor and warn.
svn:r3839
Diffstat (limited to 'src')
-rw-r--r-- | src/or/main.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/or/main.c b/src/or/main.c index e2176d4233..b06fc552f0 100644 --- a/src/or/main.c +++ b/src/or/main.c @@ -965,16 +965,23 @@ static int do_hup(void) { /* 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; |