[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[or-cvs] Another _zlib fix.



Update of /home/or/cvsroot/tor/src/or
In directory moria:/tmp/cvs-serv12910/src/or

Modified Files:
	buffers.c 
Log Message:
Another _zlib fix.

Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/buffers.c,v
retrieving revision 1.194
retrieving revision 1.195
diff -u -p -d -r1.194 -r1.195
--- buffers.c	18 Jun 2006 08:44:34 -0000	1.194
+++ buffers.c	18 Jun 2006 09:03:48 -0000	1.195
@@ -1296,7 +1296,8 @@ write_to_buf_zlib(buf_t *buf, tor_zlib_s
 {
   char *next;
   size_t old_avail, avail;
-  while (1) {
+  int over = 0;
+  while (!over) {
     buf_ensure_capacity(buf, buf->datalen + 1024);
     next = _buf_end(buf);
     if (next < buf->cur)
@@ -1305,12 +1306,13 @@ write_to_buf_zlib(buf_t *buf, tor_zlib_s
       old_avail = avail = (buf->mem + buf->datalen) - buf->cur;
     switch (tor_zlib_process(state, &next, &avail, &data, &data_len, done)) {
       case TOR_ZLIB_DONE:
-        return 0;
+        over = 1;
+        break;
       case TOR_ZLIB_ERR:
         return -1;
       case TOR_ZLIB_OK:
         if (data_len == 0)
-          return 0;
+          over = 1;
         break;
       case TOR_ZLIB_BUF_FULL:
         if (avail && buf->len >= 1024 + buf->datalen) {
@@ -1335,6 +1337,8 @@ write_to_buf_zlib(buf_t *buf, tor_zlib_s
     if (buf->datalen > buf->highwater)
       buf->highwater = buf->datalen;
     buf_total_used += old_avail - avail;
+    if (over)
+      return 0;
   }
 }