commit ca632144e59304ce2e41a32ddd1cf302d651cc68 Author: Alexander Færøy ahf@torproject.org Date: Thu May 4 16:21:05 2017 +0200
Use dir_compressed(_len) instead of dir_z(_len).
This patch renames `dir_z` to `dir_compressed` and `dir_z_len` to `dir_compressed_len`.
See: https://bugs.torproject.org/21667 --- src/or/directory.c | 10 +++++++--- src/or/dirserv.c | 12 ++++++------ src/or/or.h | 4 ++-- 3 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/src/or/directory.c b/src/or/directory.c index da92e0f..83a2e6c 100644 --- a/src/or/directory.c +++ b/src/or/directory.c @@ -3885,7 +3885,9 @@ handle_get_status_vote(dir_connection_t *conn, const get_handler_args_t *args) goto vote_done; } SMARTLIST_FOREACH(dir_items, cached_dir_t *, d, - body_len += compressed ? d->dir_z_len : d->dir_len); + body_len += compressed + ? d->dir_compressed_len + : d->dir_len); estimated_len += body_len; SMARTLIST_FOREACH(items, const char *, item, { size_t ln = strlen(item); @@ -3917,8 +3919,10 @@ handle_get_status_vote(dir_connection_t *conn, const get_handler_args_t *args) } } else { SMARTLIST_FOREACH(dir_items, cached_dir_t *, d, - connection_write_to_buf(compressed ? d->dir_z : d->dir, - compressed ? d->dir_z_len : d->dir_len, + connection_write_to_buf(compressed + ? d->dir_compressed : d->dir, + compressed + ? d->dir_compressed_len : d->dir_len, TO_CONN(conn))); } vote_done: diff --git a/src/or/dirserv.c b/src/or/dirserv.c index c25dbf8..bbff13f 100644 --- a/src/or/dirserv.c +++ b/src/or/dirserv.c @@ -1179,8 +1179,8 @@ new_cached_dir(char *s, time_t published) d->dir = s; d->dir_len = strlen(s); d->published = published; - if (tor_compress(&(d->dir_z), &(d->dir_z_len), d->dir, d->dir_len, - ZLIB_METHOD)) { + if (tor_compress(&(d->dir_compressed), &(d->dir_compressed_len), + d->dir, d->dir_len, ZLIB_METHOD)) { log_warn(LD_BUG, "Error compressing directory"); } return d; @@ -1191,7 +1191,7 @@ static void clear_cached_dir(cached_dir_t *d) { tor_free(d->dir); - tor_free(d->dir_z); + tor_free(d->dir_compressed); memset(d, 0, sizeof(cached_dir_t)); }
@@ -3508,7 +3508,7 @@ spooled_resource_estimate_size(const spooled_resource_t *spooled, if (cached == NULL) { return 0; } - size_t result = compressed ? cached->dir_z_len : cached->dir_len; + size_t result = compressed ? cached->dir_compressed_len : cached->dir_len; return result; } } @@ -3567,8 +3567,8 @@ spooled_resource_flush_some(spooled_resource_t *spooled, int64_t total_len; const char *ptr; if (cached) { - total_len = cached->dir_z_len; - ptr = cached->dir_z; + total_len = cached->dir_compressed_len; + ptr = cached->dir_compressed; } else { total_len = spooled->cce_len; ptr = (const char *)spooled->cce_body; diff --git a/src/or/or.h b/src/or/or.h index 297ec47..acbf8ce 100644 --- a/src/or/or.h +++ b/src/or/or.h @@ -1934,9 +1934,9 @@ typedef struct addr_policy_t { * compressed form. */ typedef struct cached_dir_t { char *dir; /**< Contents of this object, NUL-terminated. */ - char *dir_z; /**< Compressed contents of this object. */ + char *dir_compressed; /**< Compressed contents of this object. */ size_t dir_len; /**< Length of <b>dir</b> (not counting its NUL). */ - size_t dir_z_len; /**< Length of <b>dir_z</b>. */ + size_t dir_compressed_len; /**< Length of <b>dir_compressed</b>. */ time_t published; /**< When was this object published. */ common_digests_t digests; /**< Digests of this object (networkstatus only) */ /** Sha3 digest (also ns only) */
tor-commits@lists.torproject.org