summaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2006-06-22 07:01:54 +0000
committerNick Mathewson <nickm@torproject.org>2006-06-22 07:01:54 +0000
commitb7910202a306dbeb7b3ce024dc166ac9ea7de44f (patch)
tree77b1807eae66799a08938052d5024c7dc8a44c96 /src/or/routerparse.c
parentfb6d4855baf0cddc7ce4bff73b12822414013282 (diff)
downloadtor-b7910202a306dbeb7b3ce024dc166ac9ea7de44f.tar.gz
tor-b7910202a306dbeb7b3ce024dc166ac9ea7de44f.zip
Next batch of memory miserdom: mmap cached-routers file. This is sure to break somewhere.
svn:r6675
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index ab1a2ca3bf..608d156c40 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -635,10 +635,11 @@ check_directory_signature(const char *digest,
* are marked running and valid. Advances *s to a point immediately
* following the last router entry. Ignore any trailing router entries that
* are not complete. Returns 0 on success and -1 on failure.
+ * DOCDOC saved_location
*/
int
router_parse_list_from_string(const char **s, smartlist_t *dest,
- int from_cache)
+ saved_location_t saved_location)
{
routerinfo_t *router;
const char *end, *cp, *start;
@@ -678,15 +679,16 @@ router_parse_list_from_string(const char **s, smartlist_t *dest,
continue;
}
- router = router_parse_entry_from_string(*s, end);
+ router = router_parse_entry_from_string(*s, end,
+ saved_location != SAVED_IN_CACHE);
*s = end;
if (!router) {
log_warn(LD_DIR, "Error reading router; skipping");
continue;
}
- if (from_cache) {
- router->cache_info.saved_location = SAVED_IN_CACHE;
+ if (saved_location != SAVED_NOWHERE) {
+ router->cache_info.saved_location = saved_location;
router->cache_info.saved_offset = *s - start;
}
smartlist_add(dest, router);
@@ -698,9 +700,11 @@ router_parse_list_from_string(const char **s, smartlist_t *dest,
/** Helper function: reads a single router entry from *<b>s</b> ...
* *<b>end</b>. Mallocs a new router and returns it if all goes well, else
* returns NULL.
+ * DOCDOC cache_copy
*/
routerinfo_t *
-router_parse_entry_from_string(const char *s, const char *end)
+router_parse_entry_from_string(const char *s, const char *end,
+ int cache_copy)
{
routerinfo_t *router = NULL;
char signed_digest[128];
@@ -747,7 +751,8 @@ router_parse_entry_from_string(const char *s, const char *end)
}
router = tor_malloc_zero(sizeof(routerinfo_t));
- router->cache_info.signed_descriptor_body = tor_strndup(s, end-s);
+ if (cache_copy)
+ router->cache_info.signed_descriptor_body = tor_strndup(s, end-s);
router->cache_info.signed_descriptor_len = end-s;
memcpy(router->cache_info.signed_descriptor_digest, digest, DIGEST_LEN);