Removed obsolete code related to cached-routers

This commit is contained in:
Akshay Hebbar Y S 2013-04-01 20:43:00 +05:30 committed by Nick Mathewson
parent c1a2be9ffe
commit 36acde6b4e
2 changed files with 2 additions and 30 deletions

View File

@ -2488,10 +2488,6 @@ typedef struct desc_store_t {
* filename for a temporary file when rebuilding the store, and .new to this * filename for a temporary file when rebuilding the store, and .new to this
* filename for the journal. */ * filename for the journal. */
const char *fname_base; const char *fname_base;
/** Alternative (obsolete) value for fname_base: if the file named by
* fname_base isn't present, we read from here instead, but we never write
* here. */
const char *fname_alt_base;
/** Human-readable description of what this store contains. */ /** Human-readable description of what this store contains. */
const char *description; const char *description;

View File

@ -831,32 +831,18 @@ router_rebuild_store(int flags, desc_store_t *store)
static int static int
router_reload_router_list_impl(desc_store_t *store) router_reload_router_list_impl(desc_store_t *store)
{ {
char *fname = NULL, *altname = NULL, *contents = NULL; char *fname = NULL, *contents = NULL;
struct stat st; struct stat st;
int read_from_old_location = 0;
int extrainfo = (store->type == EXTRAINFO_STORE); int extrainfo = (store->type == EXTRAINFO_STORE);
time_t now = time(NULL);
store->journal_len = store->store_len = 0; store->journal_len = store->store_len = 0;
fname = get_datadir_fname(store->fname_base); fname = get_datadir_fname(store->fname_base);
if (store->fname_alt_base)
altname = get_datadir_fname(store->fname_alt_base);
if (store->mmap) /* get rid of it first */ if (store->mmap) /* get rid of it first */
tor_munmap_file(store->mmap); tor_munmap_file(store->mmap);
store->mmap = NULL; store->mmap = NULL;
store->mmap = tor_mmap_file(fname); store->mmap = tor_mmap_file(fname);
if (!store->mmap && altname && file_status(altname) == FN_FILE) {
read_from_old_location = 1;
log_notice(LD_DIR, "Couldn't read %s; trying to load routers from old "
"location %s.", fname, altname);
if ((store->mmap = tor_mmap_file(altname)))
read_from_old_location = 1;
}
if (altname && !read_from_old_location) {
remove_file_if_very_old(altname, now);
}
if (store->mmap) { if (store->mmap) {
store->store_len = store->mmap->size; store->store_len = store->mmap->size;
if (extrainfo) if (extrainfo)
@ -873,14 +859,6 @@ router_reload_router_list_impl(desc_store_t *store)
fname = get_datadir_fname_suffix(store->fname_base, ".new"); fname = get_datadir_fname_suffix(store->fname_base, ".new");
if (file_status(fname) == FN_FILE) if (file_status(fname) == FN_FILE)
contents = read_file_to_str(fname, RFTS_BIN|RFTS_IGNORE_MISSING, &st); contents = read_file_to_str(fname, RFTS_BIN|RFTS_IGNORE_MISSING, &st);
if (read_from_old_location) {
tor_free(altname);
altname = get_datadir_fname_suffix(store->fname_alt_base, ".new");
if (!contents)
contents = read_file_to_str(altname, RFTS_BIN|RFTS_IGNORE_MISSING, &st);
else
remove_file_if_very_old(altname, now);
}
if (contents) { if (contents) {
if (extrainfo) if (extrainfo)
router_load_extrainfo_from_string(contents, NULL,SAVED_IN_JOURNAL, router_load_extrainfo_from_string(contents, NULL,SAVED_IN_JOURNAL,
@ -893,9 +871,8 @@ router_reload_router_list_impl(desc_store_t *store)
} }
tor_free(fname); tor_free(fname);
tor_free(altname);
if (store->journal_len || read_from_old_location) { if (store->journal_len) {
/* Always clear the journal on startup.*/ /* Always clear the journal on startup.*/
router_rebuild_store(RRS_FORCE, store); router_rebuild_store(RRS_FORCE, store);
} else if (!extrainfo) { } else if (!extrainfo) {
@ -2469,7 +2446,6 @@ router_get_routerlist(void)
routerlist->extra_info_map = eimap_new(); routerlist->extra_info_map = eimap_new();
routerlist->desc_store.fname_base = "cached-descriptors"; routerlist->desc_store.fname_base = "cached-descriptors";
routerlist->desc_store.fname_alt_base = "cached-routers";
routerlist->extrainfo_store.fname_base = "cached-extrainfo"; routerlist->extrainfo_store.fname_base = "cached-extrainfo";
routerlist->desc_store.type = ROUTER_STORE; routerlist->desc_store.type = ROUTER_STORE;