diff options
author | Peter Palfrader <peter@palfrader.org> | 2006-09-15 05:20:16 +0000 |
---|---|---|
committer | Peter Palfrader <peter@palfrader.org> | 2006-09-15 05:20:16 +0000 |
commit | ba091ae5d73c7992ebd62fa5c2ce80922a3d97d8 (patch) | |
tree | 8c63f3c27a392cab5ac42c588ae4e7a7c762dcf2 /src/or/directory.c | |
parent | 5beb114744272879ec05f9eb4cb499cd8eb9af98 (diff) | |
download | tor-ba091ae5d73c7992ebd62fa5c2ce80922a3d97d8.tar.gz tor-ba091ae5d73c7992ebd62fa5c2ce80922a3d97d8.zip |
r9770@danube: weasel | 2006-09-15 07:20:05 +0200
router_set_networkstatus() gets a list of status documents we asked for from
connection_dir_client_reached_eof(). However, as a cache we (sometimes?) just
ask for "all". router_set_networkstatus() would freak out over that, meaning
it would log a warning and drop the status document instead of caching it
as it is supposed to. Now we let router_set_networkstatus() know if the
data comes from an all-request so it can do the right thing.
svn:r8398
Diffstat (limited to 'src/or/directory.c')
-rw-r--r-- | src/or/directory.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/or/directory.c b/src/or/directory.c index dfbd075e60..91b5322bcf 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -990,6 +990,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn) if (conn->_base.purpose == DIR_PURPOSE_FETCH_NETWORKSTATUS) { smartlist_t *which = NULL; + int source; char *cp; log_info(LD_DIR,"Received networkstatus objects (size %d) from server " "'%s:%d'",(int) body_len, conn->_base.address, conn->_base.port); @@ -1006,11 +1007,13 @@ connection_dir_client_reached_eof(dir_connection_t *conn) note_request(was_compressed?"dl/status.z":"dl/status", orig_len); if (conn->requested_resource && !strcmpstart(conn->requested_resource,"fp/")) { + source = NS_FROM_DIR_BY_FP; which = smartlist_create(); dir_split_resource_into_fingerprints(conn->requested_resource+3, which, NULL, 0, 0); } else if (conn->requested_resource && !strcmpstart(conn->requested_resource, "all")) { + source = NS_FROM_DIR_ALL; which = smartlist_create(); SMARTLIST_FOREACH(router_get_trusted_dir_servers(), trusted_dir_server_t *, ds, @@ -1019,6 +1022,11 @@ connection_dir_client_reached_eof(dir_connection_t *conn) base16_encode(cp, HEX_DIGEST_LEN+1, ds->digest, DIGEST_LEN); smartlist_add(which, cp); }); + } else { + /* Can we even end up here? -- weasel*/ + source = NS_FROM_DIR_BY_FP; + log_warn(LD_BUG, "we received a networkstatus but we did neither ask" + "for it by fp/ nor did we ask for all."); } cp = body; while (*cp) { @@ -1026,7 +1034,7 @@ connection_dir_client_reached_eof(dir_connection_t *conn) if (next) next[1] = '\0'; /* learn from it, and then remove it from 'which' */ - if (router_set_networkstatus(cp, time(NULL), NS_FROM_DIR, which)<0) + if (router_set_networkstatus(cp, time(NULL), source, which)<0) break; if (next) { next[1] = 'n'; |