[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] Start remembering *where* we are storing routerdescs. This ...
Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv27776/src/or
Modified Files:
or.h routerlist.c routerparse.c
Log Message:
Start remembering *where* we are storing routerdescs. This will make us easier to move from a RAM-mirrors-disk model to a RAM-caches-disk model, and save maybe around 10MB on a directory server.
Index: or.h
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/or.h,v
retrieving revision 1.830
retrieving revision 1.831
diff -u -p -d -r1.830 -r1.831
--- or.h 18 Apr 2006 03:51:18 -0000 1.830
+++ or.h 29 Apr 2006 18:42:26 -0000 1.831
@@ -755,6 +755,8 @@ typedef struct signed_descriptor_t {
char signed_descriptor_digest[DIGEST_LEN];
char identity_digest[DIGEST_LEN];
time_t published_on;
+ enum { SAVED_NOWHERE=0, SAVED_IN_CACHE, SAVED_IN_JOURNAL } saved_location;
+ off_t saved_offset;
} signed_descriptor_t;
/** Information about another onion router in the network. */
@@ -2402,7 +2404,8 @@ int router_append_dirobj_signature(char
const char *digest,
crypto_pk_env_t *private_key);
int router_parse_list_from_string(const char **s,
- smartlist_t *dest);
+ smartlist_t *dest,
+ int from_cache);
int router_parse_routerlist_from_directory(const char *s,
routerlist_t **dest,
crypto_pk_env_t *pkey,
Index: routerlist.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerlist.c,v
retrieving revision 1.509
retrieving revision 1.510
diff -u -p -d -r1.509 -r1.510
--- routerlist.c 29 Apr 2006 17:44:31 -0000 1.509
+++ routerlist.c 29 Apr 2006 18:42:26 -0000 1.510
@@ -186,6 +186,8 @@ router_append_to_journal(signed_descript
tor_free(fname);
return -1;
}
+ desc->saved_location = SAVED_IN_JOURNAL;
+ desc->saved_offset = router_journal_len;
tor_free(fname);
router_journal_len += len;
@@ -243,6 +245,20 @@ router_rebuild_store(int force)
log_warn(LD_FS, "Error writing router store to disk.");
goto done;
}
+ for (i = 0; i < 2; ++i) {
+ smartlist_t *lst = (i == 0) ? routerlist->old_routers :
+ routerlist->routers;
+ off_t offset = 0;
+ SMARTLIST_FOREACH(lst, void *, ptr,
+ {
+ signed_descriptor_t *sd = (i==0) ?
+ ((signed_descriptor_t*)ptr): &((routerinfo_t*)ptr)->cache_info;
+
+ sd->saved_location = SAVED_IN_CACHE;
+ sd->saved_offset = offset;
+ offset += sd->signed_descriptor_len;
+ });
+ }
tor_snprintf(fname, fname_len, "%s/cached-routers.new",
options->DataDirectory);
@@ -1920,7 +1936,7 @@ router_load_routers_from_string(const ch
char fp[HEX_DIGEST_LEN+1];
const char *msg;
- router_parse_list_from_string(&s, routers);
+ router_parse_list_from_string(&s, routers, from_cache);
routers_update_status_from_networkstatus(routers, !from_cache);
Index: routerparse.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/routerparse.c,v
retrieving revision 1.184
retrieving revision 1.185
diff -u -p -d -r1.184 -r1.185
--- routerparse.c 10 Apr 2006 21:22:59 -0000 1.184
+++ routerparse.c 29 Apr 2006 18:42:26 -0000 1.185
@@ -637,15 +637,17 @@ check_directory_signature(const char *di
* are not complete. Returns 0 on success and -1 on failure.
*/
int
-router_parse_list_from_string(const char **s, smartlist_t *dest)
+router_parse_list_from_string(const char **s, smartlist_t *dest,
+ int from_cache)
{
routerinfo_t *router;
- const char *end, *cp;
+ const char *end, *cp, *start;
tor_assert(s);
tor_assert(*s);
tor_assert(dest);
+ start = *s;
while (1) {
*s = eat_whitespace(*s);
/* Don't start parsing the rest of *s unless it contains a router. */
@@ -683,6 +685,10 @@ router_parse_list_from_string(const char
log_warn(LD_DIR, "Error reading router; skipping");
continue;
}
+ if (from_cache) {
+ router->cache_info.saved_location = SAVED_IN_CACHE;
+ router->cache_info.saved_offset = *s - start;
+ }
smartlist_add(dest, router);
}