diff options
author | Nick Mathewson <nickm@torproject.org> | 2020-07-21 15:08:00 -0400 |
---|---|---|
committer | Alexander Færøy <ahf@torproject.org> | 2020-07-29 13:33:35 +0000 |
commit | 3cb9a9b8ce7aeff0931d2b3f57bb2de0ba793669 (patch) | |
tree | bd1fc5e74c78a051d1d9036fdfc786fa65a4c92d /src/lib/buf | |
parent | e8497bfaa70ef7ce8c48bc2c5464d6fddb8fcff1 (diff) | |
download | tor-3cb9a9b8ce7aeff0931d2b3f57bb2de0ba793669.tar.gz tor-3cb9a9b8ce7aeff0931d2b3f57bb2de0ba793669.zip |
Remove the connection_t.outbuf_flushlen field
This was once used for rate-limiting, but now it's only for
accounting. It hasn't served a useful purpose in a long time.
Closes ticket 33097.
Diffstat (limited to 'src/lib/buf')
-rw-r--r-- | src/lib/buf/buffers.c | 13 | ||||
-rw-r--r-- | src/lib/buf/buffers.h | 2 |
2 files changed, 10 insertions, 5 deletions
diff --git a/src/lib/buf/buffers.c b/src/lib/buf/buffers.c index 95b384bf06..aa0af69072 100644 --- a/src/lib/buf/buffers.c +++ b/src/lib/buf/buffers.c @@ -685,17 +685,20 @@ buf_move_to_buf(buf_t *buf_out, buf_t *buf_in, size_t *buf_flushlen) } /** Moves all data from <b>buf_in</b> to <b>buf_out</b>, without copying. + * Return the number of bytes that were moved. */ -void +size_t buf_move_all(buf_t *buf_out, buf_t *buf_in) { tor_assert(buf_out); if (!buf_in) - return; + return 0; if (BUG(buf_out->datalen > BUF_MAX_LEN || buf_in->datalen > BUF_MAX_LEN)) - return; + return 0; if (BUG(buf_out->datalen > BUF_MAX_LEN - buf_in->datalen)) - return; + return 0; + + size_t n_bytes_moved = buf_in->datalen; if (buf_out->head == NULL) { buf_out->head = buf_in->head; @@ -708,6 +711,8 @@ buf_move_all(buf_t *buf_out, buf_t *buf_in) buf_out->datalen += buf_in->datalen; buf_in->head = buf_in->tail = NULL; buf_in->datalen = 0; + + return n_bytes_moved; } /** Internal structure: represents a position in a buffer. */ diff --git a/src/lib/buf/buffers.h b/src/lib/buf/buffers.h index d8a77feb72..1361a02eba 100644 --- a/src/lib/buf/buffers.h +++ b/src/lib/buf/buffers.h @@ -46,7 +46,7 @@ void buf_add_printf(buf_t *buf, const char *format, ...) void buf_add_vprintf(buf_t *buf, const char *format, va_list args) CHECK_PRINTF(2, 0); int buf_move_to_buf(buf_t *buf_out, buf_t *buf_in, size_t *buf_flushlen); -void buf_move_all(buf_t *buf_out, buf_t *buf_in); +size_t buf_move_all(buf_t *buf_out, buf_t *buf_in); void buf_peek(const buf_t *buf, char *string, size_t string_len); void buf_drain(buf_t *buf, size_t n); int buf_get_bytes(buf_t *buf, char *string, size_t string_len); |