mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-20 02:09:24 +01:00
r15420@catbus: nickm | 2007-09-27 15:40:25 -0400
Remove annotated_desc_store store (which we never used). Instead, shift name of router store to cached-descriptors, but initialize it from cached-routers as needed svn:r11678
This commit is contained in:
parent
5ba6fd9e7b
commit
60efd6b726
@ -3,6 +3,12 @@ Changes in version 0.2.0.8-alpha - 2007-??-??
|
||||
- When an authority is missing votes or signatures, it now tries to fetch
|
||||
them.
|
||||
|
||||
o Minor features (router descriptor cache):
|
||||
- Store routers in a file called cached-descriptors instead of in
|
||||
cached-routers. Initialize cached-descriptors from cached-routers
|
||||
if the old format is around. The new format allows us to store
|
||||
annotations along with descriptors.
|
||||
|
||||
o Minor bugfixes (controller):
|
||||
- When sending a status event to the controller telling it that an
|
||||
OR address is readable, set the port correctly. (Previously we
|
||||
|
4
doc/TODO
4
doc/TODO
@ -138,8 +138,8 @@ N . Cache for bridge descriptors
|
||||
o Mechanism to add annotations when we first add a descriptor
|
||||
o Don't serve annotations
|
||||
o Reject annotations that appear in things we've downloaded
|
||||
- Name the router store something different: cached-descriptors?
|
||||
- But load from cached-routers if no cached-descriptors is
|
||||
o Name the router store something different: cached-descriptors?
|
||||
o But load from cached-routers if no cached-descriptors is
|
||||
found.
|
||||
- Document this.
|
||||
- Use annotations to denote router purpose
|
||||
|
@ -1379,6 +1379,7 @@ typedef enum store_type_t {
|
||||
/** DOCDOC */
|
||||
typedef struct desc_store_t {
|
||||
const char *fname_base;
|
||||
const char *fname_alt_base;
|
||||
const char *description;
|
||||
|
||||
tor_mmap_t *mmap;
|
||||
@ -1417,8 +1418,6 @@ typedef struct {
|
||||
* whose cache_info.saved_location == SAVED_IN_CACHE is stored in this file
|
||||
* starting at cache_info.saved_offset */
|
||||
desc_store_t desc_store;
|
||||
/** DOCDOC */
|
||||
desc_store_t annotated_desc_store;
|
||||
/** Mmaped file holding extra-info documents. */
|
||||
desc_store_t extrainfo_store;
|
||||
} routerlist_t;
|
||||
|
@ -471,13 +471,13 @@ authority_certs_fetch_missing(networkstatus_vote_t *status)
|
||||
|
||||
/* Router descriptor storage.
|
||||
*
|
||||
* DOCDOC files annotated NM
|
||||
* Routerdescs are stored in a big file, named "cached-routers". As new
|
||||
* Routerdescs are stored in a big file, named "cached-descriptors". As new
|
||||
* routerdescs arrive, we append them to a journal file named
|
||||
* "cached-routers.new".
|
||||
* "cached-descriptors.new".
|
||||
*
|
||||
* From time to time, we replace "cached-routers" with a new file containing
|
||||
* only the live, non-superseded descriptors, and clear cached-routers.new.
|
||||
* From time to time, we replace "cached-descriptors" with a new file
|
||||
* containing only the live, non-superseded descriptors, and clear
|
||||
* cached-routers.new.
|
||||
*
|
||||
* On startup, we read both files.
|
||||
*/
|
||||
@ -497,7 +497,6 @@ router_should_rebuild_store(desc_store_t *store)
|
||||
static INLINE desc_store_t *
|
||||
desc_get_store(routerlist_t *rl, signed_descriptor_t *sd)
|
||||
{
|
||||
// XXXX NM annotated
|
||||
if (sd->is_extrainfo)
|
||||
return &rl->extrainfo_store;
|
||||
else
|
||||
@ -708,19 +707,33 @@ router_reload_router_list_impl(desc_store_t *store)
|
||||
{
|
||||
or_options_t *options = get_options();
|
||||
size_t fname_len = strlen(options->DataDirectory)+32;
|
||||
char *fname = tor_malloc(fname_len), *contents = NULL;
|
||||
char *fname = tor_malloc(fname_len), *altname = NULL,
|
||||
*contents = NULL;
|
||||
struct stat st;
|
||||
int read_from_old_location = 0;
|
||||
int extrainfo = (store->type == EXTRAINFO_STORE);
|
||||
store->journal_len = store->store_len = 0;
|
||||
|
||||
tor_snprintf(fname, fname_len, "%s"PATH_SEPARATOR"%s",
|
||||
options->DataDirectory, store->fname_base);
|
||||
if (store->fname_alt_base) {
|
||||
altname = tor_malloc(fname_len);
|
||||
tor_snprintf(altname, fname_len, "%s"PATH_SEPARATOR"%s",
|
||||
options->DataDirectory, store->fname_alt_base);
|
||||
}
|
||||
|
||||
if (store->mmap) /* get rid of it first */
|
||||
tor_munmap_file(store->mmap);
|
||||
store->mmap = NULL;
|
||||
|
||||
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 (store->mmap) {
|
||||
store->store_len = store->mmap->size;
|
||||
if (extrainfo)
|
||||
@ -738,6 +751,11 @@ router_reload_router_list_impl(desc_store_t *store)
|
||||
options->DataDirectory, store->fname_base);
|
||||
if (file_status(fname) == FN_FILE)
|
||||
contents = read_file_to_str(fname, RFTS_BIN|RFTS_IGNORE_MISSING, &st);
|
||||
if (!contents && read_from_old_location) {
|
||||
tor_snprintf(altname, fname_len, "%s"PATH_SEPARATOR"%s.new",
|
||||
options->DataDirectory, store->fname_alt_base);
|
||||
contents = read_file_to_str(altname, RFTS_BIN|RFTS_IGNORE_MISSING, &st);
|
||||
}
|
||||
if (contents) {
|
||||
if (extrainfo)
|
||||
router_load_extrainfo_from_string(contents, NULL,SAVED_IN_JOURNAL,
|
||||
@ -750,8 +768,9 @@ router_reload_router_list_impl(desc_store_t *store)
|
||||
}
|
||||
|
||||
tor_free(fname);
|
||||
tor_free(altname);
|
||||
|
||||
if (store->journal_len) {
|
||||
if (store->journal_len || read_from_old_location) {
|
||||
/* Always clear the journal on startup.*/
|
||||
router_rebuild_store(1, store);
|
||||
} else if (!extrainfo) {
|
||||
@ -770,7 +789,6 @@ int
|
||||
router_reload_router_list(void)
|
||||
{
|
||||
routerlist_t *rl = router_get_routerlist();
|
||||
// XXXX NM annotated
|
||||
if (router_reload_router_list_impl(&rl->desc_store))
|
||||
return -1;
|
||||
if (router_reload_router_list_impl(&rl->extrainfo_store))
|
||||
@ -2021,17 +2039,14 @@ router_get_routerlist(void)
|
||||
routerlist->desc_by_eid_map = sdmap_new();
|
||||
routerlist->extra_info_map = eimap_new();
|
||||
|
||||
routerlist->desc_store.fname_base = "cached-routers";
|
||||
routerlist->annotated_desc_store.fname_base = "annotated-routers";
|
||||
routerlist->desc_store.fname_base = "cached-descriptors";
|
||||
routerlist->desc_store.fname_alt_base = "cached-routers";
|
||||
routerlist->extrainfo_store.fname_base = "cached-extrainfo";
|
||||
|
||||
routerlist->desc_store.type = ROUTER_STORE;
|
||||
routerlist->annotated_desc_store.type = ANNOTATED_ROUTER_STORE;
|
||||
routerlist->extrainfo_store.type = EXTRAINFO_STORE;
|
||||
|
||||
routerlist->desc_store.description = "router descriptors";
|
||||
routerlist->annotated_desc_store.description
|
||||
= "annotated router descriptors";
|
||||
routerlist->extrainfo_store.description = "extra-info documents";
|
||||
}
|
||||
return routerlist;
|
||||
@ -2126,8 +2141,6 @@ routerlist_free(routerlist_t *rl)
|
||||
smartlist_free(rl->old_routers);
|
||||
if (routerlist->desc_store.mmap)
|
||||
tor_munmap_file(routerlist->desc_store.mmap);
|
||||
if (routerlist->annotated_desc_store.mmap)
|
||||
tor_munmap_file(routerlist->annotated_desc_store.mmap);
|
||||
if (routerlist->extrainfo_store.mmap)
|
||||
tor_munmap_file(routerlist->extrainfo_store.mmap);
|
||||
tor_free(rl);
|
||||
@ -3208,7 +3221,6 @@ router_load_routers_from_string(const char *s, const char *eos,
|
||||
|
||||
routerlist_assert_ok(routerlist);
|
||||
|
||||
// annotated. XXXX NM
|
||||
router_rebuild_store(0, &routerlist->desc_store);
|
||||
|
||||
smartlist_free(routers);
|
||||
|
Loading…
Reference in New Issue
Block a user