[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] r11678: Remove annotated_desc_store store (which we never used). Ins (in tor/trunk: . doc src/or)
Author: nickm
Date: 2007-09-27 16:46:24 -0400 (Thu, 27 Sep 2007)
New Revision: 11678
Modified:
tor/trunk/
tor/trunk/ChangeLog
tor/trunk/doc/TODO
tor/trunk/src/or/or.h
tor/trunk/src/or/routerlist.c
Log:
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
Property changes on: tor/trunk
___________________________________________________________________
svk:merge ticket from /tor/trunk [r15420] on 8246c3cf-6607-4228-993b-4d95d33730f1
Modified: tor/trunk/ChangeLog
===================================================================
--- tor/trunk/ChangeLog 2007-09-27 20:27:34 UTC (rev 11677)
+++ tor/trunk/ChangeLog 2007-09-27 20:46:24 UTC (rev 11678)
@@ -3,6 +3,12 @@
- 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
Modified: tor/trunk/doc/TODO
===================================================================
--- tor/trunk/doc/TODO 2007-09-27 20:27:34 UTC (rev 11677)
+++ tor/trunk/doc/TODO 2007-09-27 20:46:24 UTC (rev 11678)
@@ -138,8 +138,8 @@
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
Modified: tor/trunk/src/or/or.h
===================================================================
--- tor/trunk/src/or/or.h 2007-09-27 20:27:34 UTC (rev 11677)
+++ tor/trunk/src/or/or.h 2007-09-27 20:46:24 UTC (rev 11678)
@@ -1379,6 +1379,7 @@
/** 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 @@
* 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;
Modified: tor/trunk/src/or/routerlist.c
===================================================================
--- tor/trunk/src/or/routerlist.c 2007-09-27 20:27:34 UTC (rev 11677)
+++ tor/trunk/src/or/routerlist.c 2007-09-27 20:46:24 UTC (rev 11678)
@@ -471,13 +471,13 @@
/* 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 @@
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 @@
{
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 @@
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 @@
}
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 @@
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 @@
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 @@
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 @@
routerlist_assert_ok(routerlist);
- // annotated. XXXX NM
router_rebuild_store(0, &routerlist->desc_store);
smartlist_free(routers);