diff options
author | Karsten Loesing <karsten.loesing@gmx.net> | 2009-06-19 16:26:02 +0200 |
---|---|---|
committer | Karsten Loesing <karsten.loesing@gmx.net> | 2009-06-19 17:29:32 +0200 |
commit | 2bcf2cb099e05cc7d8f44794039da8d3fed0ba65 (patch) | |
tree | 165baf1d44028afd15c166a2e45a5d2017505b7c | |
parent | 2378e37a5d88bed8dfc27406a258f6ee00521e8e (diff) | |
download | tor-2bcf2cb099e05cc7d8f44794039da8d3fed0ba65.tar.gz tor-2bcf2cb099e05cc7d8f44794039da8d3fed0ba65.zip |
Better fix for 997.
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | src/or/connection_edge.c | 3 | ||||
-rw-r--r-- | src/or/or.h | 4 | ||||
-rw-r--r-- | src/or/rendclient.c | 9 |
4 files changed, 15 insertions, 6 deletions
@@ -22,6 +22,11 @@ Changes in version 0.2.0.35 - 2009-??-?? - When starting with a cache over a few days old, do not leak memory for the obsolete router descriptors in it. Bugfix on 0.2.0.33; fixes bug 672. + - Hidden service clients didn't use a cached service descriptor that + was older than 15 minutes, but wouldn't fetch a new one either, + because there was already one in the cache. Now, fetch a v2 + descriptor unless the same descriptor was added to the cache within + the last 15 minutes. Fixes bug 997; reported by Marcus Griep. Changes in version 0.2.0.34 - 2009-02-08 diff --git a/src/or/connection_edge.c b/src/or/connection_edge.c index 0474a469d7..72bdfff7df 100644 --- a/src/or/connection_edge.c +++ b/src/or/connection_edge.c @@ -1610,9 +1610,6 @@ connection_ap_handshake_rewrite_and_attach(edge_connection_t *conn, rend_client_refetch_v2_renddesc(conn->rend_query); rend_client_refetch_renddesc(conn->rend_query); } else { /* r > 0 */ -/** How long after we receive a hidden service descriptor do we consider - * it valid? */ -#define NUM_SECONDS_BEFORE_HS_REFETCH (60*15) if (now - entry->received < NUM_SECONDS_BEFORE_HS_REFETCH) { conn->_base.state = AP_CONN_STATE_CIRCUIT_WAIT; log_info(LD_REND, "Descriptor is here and fresh enough. Great."); diff --git a/src/or/or.h b/src/or/or.h index 15db3be038..54c515c915 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -613,6 +613,10 @@ typedef enum { /** Length of a binary-encoded rendezvous service ID. */ #define REND_SERVICE_ID_LEN 10 +/** How long after we receive a hidden service descriptor do we consider + * it fresh? */ +#define NUM_SECONDS_BEFORE_HS_REFETCH (60*15) + /** Time period for which a v2 descriptor will be valid. */ #define REND_TIME_PERIOD_V2_DESC_VALIDITY (24*60*60) diff --git a/src/or/rendclient.c b/src/or/rendclient.c index 81e5c69d9d..9f97d66443 100644 --- a/src/or/rendclient.c +++ b/src/or/rendclient.c @@ -421,8 +421,9 @@ rend_client_refetch_v2_renddesc(const char *query) { char descriptor_id[DIGEST_LEN]; int replicas_left_to_try[REND_NUMBER_OF_NON_CONSECUTIVE_REPLICAS]; - int i, tries_left; + int i, tries_left, r; rend_cache_entry_t *e = NULL; + time_t now = time(NULL); tor_assert(query); tor_assert(strlen(query) == REND_SERVICE_ID_LEN_BASE32); /* Are we configured to fetch descriptors? */ @@ -432,9 +433,11 @@ rend_client_refetch_v2_renddesc(const char *query) return; } /* Before fetching, check if we already have the descriptor here. */ - if (rend_cache_lookup_entry(query, -1, &e) > 0) { + r = rend_cache_lookup_entry(query, -1, &e); + if (r > 0 && now - e->received < NUM_SECONDS_BEFORE_HS_REFETCH) { log_info(LD_REND, "We would fetch a v2 rendezvous descriptor, but we " - "already have that descriptor here. Not fetching."); + "already have a fresh copy of that descriptor here. " + "Not fetching."); return; } log_debug(LD_REND, "Fetching v2 rendezvous descriptor for service %s", |