diff options
author | rl1987 <rl1987@sdf.lonestar.org> | 2019-02-09 16:06:32 +0200 |
---|---|---|
committer | teor <teor@torproject.org> | 2019-03-29 17:25:43 +1000 |
commit | 6ab1929f00e625a0056eb29c5308ae9f3155a049 (patch) | |
tree | d33f92807ccc46597c25e6fa318f3ad11ebcc041 /src/core/mainloop | |
parent | 6d188fb4cc026668502c0fb28e9bffaa098f84dc (diff) | |
download | tor-6ab1929f00e625a0056eb29c5308ae9f3155a049.tar.gz tor-6ab1929f00e625a0056eb29c5308ae9f3155a049.zip |
Add connection_dir_buf_add() helper function
Diffstat (limited to 'src/core/mainloop')
-rw-r--r-- | src/core/mainloop/connection.c | 17 | ||||
-rw-r--r-- | src/core/mainloop/connection.h | 2 |
2 files changed, 19 insertions, 0 deletions
diff --git a/src/core/mainloop/connection.c b/src/core/mainloop/connection.c index c8b19344bd..7f2e96b4d1 100644 --- a/src/core/mainloop/connection.c +++ b/src/core/mainloop/connection.c @@ -4341,6 +4341,23 @@ connection_write_to_buf_impl_,(const char *string, size_t len, connection_write_to_buf_commit(conn, written); } +/** + * Write a <b>string</b> (of size <b>len</b> to directory connection + * <b>dir_conn</b>. Apply compression if connection is configured to use + * it and finalize it if <b>done</b> is true. + */ +void +connection_dir_buf_add(const char *string, size_t len, + dir_connection_t *dir_conn, int done) +{ + if (dir_conn->compress_state != NULL) { + connection_buf_add_compress(string, len, dir_conn, done); + return; + } + + connection_buf_add(string, len, TO_CONN(dir_conn)); +} + void connection_buf_add_compress(const char *string, size_t len, dir_connection_t *conn, int done) diff --git a/src/core/mainloop/connection.h b/src/core/mainloop/connection.h index 411f13a8b8..c93f1ef8e8 100644 --- a/src/core/mainloop/connection.h +++ b/src/core/mainloop/connection.h @@ -226,6 +226,8 @@ MOCK_DECL(void, connection_write_to_buf_impl_, /* DOCDOC connection_write_to_buf */ static void connection_buf_add(const char *string, size_t len, connection_t *conn); +void connection_dir_buf_add(const char *string, size_t len, + dir_connection_t *dir_conn, int done); static inline void connection_buf_add(const char *string, size_t len, connection_t *conn) { |