diff options
author | Roger Dingledine <arma@torproject.org> | 2004-11-09 07:05:53 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2004-11-09 07:05:53 +0000 |
commit | 6521c2ce51b3b808dd8ef5c47dc9995acce149e5 (patch) | |
tree | 4957b0a02b4e397c146f9b2f4c462acf8fb02b54 /src/or/routerlist.c | |
parent | 48a0b6c476dee067685a66a955cdffc8a37ea9d3 (diff) | |
download | tor-6521c2ce51b3b808dd8ef5c47dc9995acce149e5.tar.gz tor-6521c2ce51b3b808dd8ef5c47dc9995acce149e5.zip |
Stop using the wrong DataDirectory when we're validating.
Also validate/normalize the DataDirectory better.
svn:r2732
Diffstat (limited to 'src/or/routerlist.c')
-rw-r--r-- | src/or/routerlist.c | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/src/or/routerlist.c b/src/or/routerlist.c index 2c4b044f8e..ac62b4528d 100644 --- a/src/or/routerlist.c +++ b/src/or/routerlist.c @@ -48,30 +48,31 @@ int router_reload_router_list(void) char filename[512]; int is_recent; struct stat st; - if (get_data_directory()) { - char *s; - tor_snprintf(filename,sizeof(filename),"%s/cached-directory", get_data_directory()); - if (stat(filename, &st)) { - log_fn(LOG_WARN, "Unable to check status for '%s': %s", filename, - strerror(errno)); - return 0; + char *s; + tor_assert(get_options()->DataDirectory); + + tor_snprintf(filename,sizeof(filename),"%s/cached-directory", + get_options()->DataDirectory); + if (stat(filename, &st)) { + log_fn(LOG_WARN, "Unable to check status for '%s': %s", filename, + strerror(errno)); + return 0; + } + s = read_file_to_str(filename,0); + if (s) { + tor_strstrip(s,"\r"); /* XXXX This is a bug workaround for win32. */ + log_fn(LOG_INFO, "Loading cached directory from %s", filename); + is_recent = st.st_mtime > time(NULL) - 60*15; + if (router_load_routerlist_from_directory(s, NULL, is_recent) < 0) { + log_fn(LOG_WARN, "Cached directory '%s' was unparseable; ignoring.", filename); } - s = read_file_to_str(filename,0); - if (s) { - tor_strstrip(s,"\r"); /* XXXX This is a bug workaround for win32. */ - log_fn(LOG_INFO, "Loading cached directory from %s", filename); - is_recent = st.st_mtime > time(NULL) - 60*15; - if (router_load_routerlist_from_directory(s, NULL, is_recent) < 0) { - log_fn(LOG_WARN, "Cached directory '%s' was unparseable; ignoring.", filename); - } - if(routerlist && - ((routerlist->published_on > time(NULL) - OLD_MIN_ONION_KEY_LIFETIME/2) - || is_recent)) { - /* XXX use new onion key lifetime when 0.0.8 servers are obsolete */ - directory_has_arrived(st.st_mtime); /* do things we've been waiting to do */ - } - tor_free(s); + if(routerlist && + ((routerlist->published_on > time(NULL) - OLD_MIN_ONION_KEY_LIFETIME/2) + || is_recent)) { + /* XXX use new onion key lifetime when 0.0.8 servers are obsolete */ + directory_has_arrived(st.st_mtime); /* do things we've been waiting to do */ } + tor_free(s); } return 0; } |