[or-cvs] Correct and simplify buf_shrink logic

Nick Mathewson nickm at seul.org
Mon May 2 23:36:15 UTC 2005


Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv26548/src/or

Modified Files:
	buffers.c 
Log Message:
Correct and simplify buf_shrink logic

Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/buffers.c,v
retrieving revision 1.147
retrieving revision 1.148
diff -u -d -r1.147 -r1.148
--- buffers.c	2 May 2005 23:32:23 -0000	1.147
+++ buffers.c	2 May 2005 23:36:13 -0000	1.148
@@ -249,13 +249,13 @@
 {
   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);



More information about the tor-commits mailing list