mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-12-06 19:41:15 +01:00
Rename zlib_state to compress_state in dir_connection_t.
This patch renames the `zlib_state` field in `dir_connection_t` to `compress_state`. See https://bugs.torproject.org/21663
This commit is contained in:
@@ -1990,10 +1990,10 @@ single_conn_free_bytes(connection_t *conn)
|
||||
}
|
||||
if (conn->type == CONN_TYPE_DIR) {
|
||||
dir_connection_t *dir_conn = TO_DIR_CONN(conn);
|
||||
if (dir_conn->zlib_state) {
|
||||
result += tor_compress_state_size(dir_conn->zlib_state);
|
||||
tor_compress_free(dir_conn->zlib_state);
|
||||
dir_conn->zlib_state = NULL;
|
||||
if (dir_conn->compress_state) {
|
||||
result += tor_compress_state_size(dir_conn->compress_state);
|
||||
tor_compress_free(dir_conn->compress_state);
|
||||
dir_conn->compress_state = NULL;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
+2
-2
@@ -628,7 +628,7 @@ connection_free_(connection_t *conn)
|
||||
dir_connection_t *dir_conn = TO_DIR_CONN(conn);
|
||||
tor_free(dir_conn->requested_resource);
|
||||
|
||||
tor_compress_free(dir_conn->zlib_state);
|
||||
tor_compress_free(dir_conn->compress_state);
|
||||
if (dir_conn->spool) {
|
||||
SMARTLIST_FOREACH(dir_conn->spool, spooled_resource_t *, spooled,
|
||||
spooled_resource_free(spooled));
|
||||
@@ -4061,7 +4061,7 @@ connection_write_to_buf_impl_,(const char *string, size_t len,
|
||||
dir_connection_t *dir_conn = TO_DIR_CONN(conn);
|
||||
int done = zlib < 0;
|
||||
CONN_LOG_PROTECT(conn, r = write_to_buf_zlib(conn->outbuf,
|
||||
dir_conn->zlib_state,
|
||||
dir_conn->compress_state,
|
||||
string, len, done));
|
||||
} else {
|
||||
CONN_LOG_PROTECT(conn, r = write_to_buf(string, len, conn->outbuf));
|
||||
|
||||
+7
-6
@@ -3178,7 +3178,8 @@ handle_get_current_consensus(dir_connection_t *conn,
|
||||
write_http_response_header(conn, -1, compressed,
|
||||
smartlist_len(conn->spool) == 1 ? lifetime : 0);
|
||||
if (! compressed)
|
||||
conn->zlib_state = tor_compress_new(0, ZLIB_METHOD, HIGH_COMPRESSION);
|
||||
conn->compress_state = tor_compress_new(0, ZLIB_METHOD,
|
||||
HIGH_COMPRESSION);
|
||||
|
||||
/* Prime the connection with some data. */
|
||||
const int initial_flush_result = connection_dirserv_flushed_some(conn);
|
||||
@@ -3276,7 +3277,7 @@ handle_get_status_vote(dir_connection_t *conn, const get_handler_args_t *args)
|
||||
|
||||
if (smartlist_len(items)) {
|
||||
if (compressed) {
|
||||
conn->zlib_state = tor_compress_new(1, ZLIB_METHOD,
|
||||
conn->compress_state = tor_compress_new(1, ZLIB_METHOD,
|
||||
choose_compression_level(estimated_len));
|
||||
SMARTLIST_FOREACH(items, const char *, c,
|
||||
connection_write_to_buf_zlib(c, strlen(c), conn, 0));
|
||||
@@ -3335,7 +3336,7 @@ handle_get_microdesc(dir_connection_t *conn, const get_handler_args_t *args)
|
||||
write_http_response_header(conn, -1, compressed, MICRODESC_CACHE_LIFETIME);
|
||||
|
||||
if (compressed)
|
||||
conn->zlib_state = tor_compress_new(1, ZLIB_METHOD,
|
||||
conn->compress_state = tor_compress_new(1, ZLIB_METHOD,
|
||||
choose_compression_level(size_guess));
|
||||
|
||||
const int initial_flush_result = connection_dirserv_flushed_some(conn);
|
||||
@@ -3428,7 +3429,7 @@ handle_get_descriptor(dir_connection_t *conn, const get_handler_args_t *args)
|
||||
}
|
||||
write_http_response_header(conn, -1, compressed, cache_lifetime);
|
||||
if (compressed)
|
||||
conn->zlib_state = tor_compress_new(1, ZLIB_METHOD,
|
||||
conn->compress_state = tor_compress_new(1, ZLIB_METHOD,
|
||||
choose_compression_level(size_guess));
|
||||
clear_spool = 0;
|
||||
/* Prime the connection with some data. */
|
||||
@@ -3519,8 +3520,8 @@ handle_get_keys(dir_connection_t *conn, const get_handler_args_t *args)
|
||||
|
||||
write_http_response_header(conn, compressed?-1:len, compressed, 60*60);
|
||||
if (compressed) {
|
||||
conn->zlib_state = tor_compress_new(1, ZLIB_METHOD,
|
||||
choose_compression_level(len));
|
||||
conn->compress_state = tor_compress_new(1, ZLIB_METHOD,
|
||||
choose_compression_level(len));
|
||||
SMARTLIST_FOREACH(certs, authority_cert_t *, c,
|
||||
connection_write_to_buf_zlib(c->cache_info.signed_descriptor_body,
|
||||
c->cache_info.signed_descriptor_len,
|
||||
|
||||
+5
-5
@@ -3497,7 +3497,7 @@ spooled_resource_flush_some(spooled_resource_t *spooled,
|
||||
/* Absent objects count as "done". */
|
||||
return SRFS_DONE;
|
||||
}
|
||||
if (conn->zlib_state) {
|
||||
if (conn->compress_state) {
|
||||
connection_write_to_buf_zlib((const char*)body, bodylen, conn, 0);
|
||||
} else {
|
||||
connection_write_to_buf((const char*)body, bodylen, TO_CONN(conn));
|
||||
@@ -3523,7 +3523,7 @@ spooled_resource_flush_some(spooled_resource_t *spooled,
|
||||
if (BUG(remaining < 0))
|
||||
return SRFS_ERR;
|
||||
ssize_t bytes = (ssize_t) MIN(DIRSERV_CACHED_DIR_CHUNK_SIZE, remaining);
|
||||
if (conn->zlib_state) {
|
||||
if (conn->compress_state) {
|
||||
connection_write_to_buf_zlib(cached->dir_z + spooled->cached_dir_offset,
|
||||
bytes, conn, 0);
|
||||
} else {
|
||||
@@ -3788,12 +3788,12 @@ connection_dirserv_flushed_some(dir_connection_t *conn)
|
||||
/* If we get here, we're done. */
|
||||
smartlist_free(conn->spool);
|
||||
conn->spool = NULL;
|
||||
if (conn->zlib_state) {
|
||||
if (conn->compress_state) {
|
||||
/* Flush the zlib state: there could be more bytes pending in there, and
|
||||
* we don't want to omit bytes. */
|
||||
connection_write_to_buf_zlib("", 0, conn, 1);
|
||||
tor_compress_free(conn->zlib_state);
|
||||
conn->zlib_state = NULL;
|
||||
tor_compress_free(conn->compress_state);
|
||||
conn->compress_state = NULL;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
+1
-1
@@ -1774,7 +1774,7 @@ typedef struct dir_connection_t {
|
||||
* it from back to front. */
|
||||
smartlist_t *spool;
|
||||
/** The compression object doing on-the-fly compression for spooled data. */
|
||||
tor_compress_state_t *zlib_state;
|
||||
tor_compress_state_t *compress_state;
|
||||
|
||||
/** What rendezvous service are we querying for? */
|
||||
rend_data_t *rend_data;
|
||||
|
||||
Reference in New Issue
Block a user