-Changes in version 0.2.0.15-alpha - 2008-01-??
+Changes in version 0.2.0.15-alpha - 2007-12-??
+ o Major bugfixes:
+ - Fix several remotely triggerable asserts based on DirPort requests
+ for a v2 or v3 networkstatus object before we were prepared. This
+ was particularly bad for 0.2.0.13 and later bridge relays, who
+ would never have a v2 networkstatus and would thus always crash
+ when used. Bugfixes on 0.2.0.x.
+ - Estimate the v3 networkstatus size more accurately, rather than
+ estimating it at zero bytes and giving it artificially high priority
+ compared to other directory requests. Bugfix on 0.2.0.x.
+
o Minor bugfixes:
- Fix configure.in logic for cross-compilation.
- When we load a bridge descriptor from the cache, and it was
ctr = (ctr + 1) % 128;
}
+
+/** Given a fingerprint <b>fp</b> which is either set if we're looking
+ * for a v2 status, or zeroes if we're looking for a v3 status, return
+ * a pointer to the appropriate cached dir object, or NULL if there isn't
+ * one available. */
+static cached_dir_t *
+lookup_cached_dir_by_fp(const char *fp)
+{
+ cached_dir_t *d = NULL;
+ if (tor_digest_is_zero(fp) && cached_v3_networkstatus)
+ d = cached_v3_networkstatus;
+ else if (router_digest_is_me(fp) && the_v2_networkstatus)
+ d = the_v2_networkstatus;
+ else if (cached_v2_networkstatus)
+ d = digestmap_get(cached_v2_networkstatus, fp);
+ return d;
+}
+
/** Remove from <b>fps</b> every networkstatus key where both
* a) we have a networkstatus document and
* b) it is not newer than <b>cutoff</b>.
int found_any = 0;
SMARTLIST_FOREACH(fps, char *, digest,
{
- cached_dir_t *d;
- if (router_digest_is_me(digest) && the_v2_networkstatus)
- d = the_v2_networkstatus;
- else if (tor_digest_is_zero(digest) && cached_v3_networkstatus)
- d = cached_v3_networkstatus;
- else
- d = digestmap_get(cached_v2_networkstatus, digest);
+ cached_dir_t *d = lookup_cached_dir_by_fp(digest);
if (!d)
continue;
found_any = 1;
result /= 2; /* observed compressability is between 35 and 55%. */
} else {
result = 0;
- SMARTLIST_FOREACH(fps, const char *, d, {
- cached_dir_t *dir = digestmap_get(cached_v2_networkstatus, d);
+ SMARTLIST_FOREACH(fps, const char *, digest, {
+ cached_dir_t *dir = lookup_cached_dir_by_fp(digest);
if (dir)
result += compressed ? dir->dir_z_len : dir->dir_len;
});
smartlist_len(conn->fingerprint_stack)) {
/* Add another networkstatus; start serving it. */
char *fp = smartlist_pop_last(conn->fingerprint_stack);
- cached_dir_t *d;
- if (tor_digest_is_zero(fp))
- d = cached_v3_networkstatus;
- else if (router_digest_is_me(fp))
- d = the_v2_networkstatus;
- else
- d = digestmap_get(cached_v2_networkstatus, fp);
+ cached_dir_t *d = lookup_cached_dir_by_fp(fp);
tor_free(fp);
if (d) {
++d->refcnt;