diff options
author | Nick Mathewson <nickm@torproject.org> | 2005-05-02 23:36:13 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2005-05-02 23:36:13 +0000 |
commit | ad547cbb8cf0c0e3d6e8ca85c1362a6891590841 (patch) | |
tree | b36e2bbd209b2ec436a66761bdd3dfcf1f5027e6 /src | |
parent | d6a6c8785bb8b126d0b87aa900623fb9d019ab60 (diff) | |
download | tor-ad547cbb8cf0c0e3d6e8ca85c1362a6891590841.tar.gz tor-ad547cbb8cf0c0e3d6e8ca85c1362a6891590841.zip |
Correct and simplify buf_shrink logic
svn:r4167
Diffstat (limited to 'src')
-rw-r--r-- | src/or/buffers.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/or/buffers.c b/src/or/buffers.c index 8648c30786..8f81eb2267 100644 --- a/src/or/buffers.c +++ b/src/or/buffers.c @@ -249,13 +249,13 @@ buf_shrink(buf_t *buf) { size_t new_len; - if (buf->highwater >= (buf->len<<2) && buf->len > MIN_LAZY_SHRINK_SIZE*2) - return; - - new_len = (buf->len>>1); + new_len = buf->len; while (buf->highwater < (new_len>>2) && new_len > MIN_LAZY_SHRINK_SIZE*2) new_len >>= 1; + if (new_len == buf->len) + return; + log_fn(LOG_DEBUG,"Shrinking buffer from %d to %d bytes.", (int)buf->len, (int)new_len); buf_resize(buf, new_len); |