Browse Source

r15710@tombo: nickm | 2007-12-25 19:36:03 -0500
Fix in flush_buf_tls: it is okay to flush an empty buffer, since we may have a partial TLS record pending.


svn:r12984

Nick Mathewson 16 years ago
parent
commit
fb8cbc8642
1 changed files with 9 additions and 5 deletions
  1. 9 5
      src/or/buffers.c

+ 9 - 5
src/or/buffers.c

@@ -113,6 +113,7 @@ typedef struct chunk_freelist_t {
 
 /** Static array of freelists, sorted by alloc_len, terminated by an entry
  * with alloc_size of 0. */
+/**XXXX020 tune these values. */
 static chunk_freelist_t freelists[] = {
   FL(256, 1024, 16), FL(512, 1024, 16), FL(1024, 512, 8), FL(4096, 256, 8),
   FL(8192, 128, 4), FL(16384, 64, 4), FL(0, 0, 0)
@@ -735,11 +736,14 @@ flush_buf_tls(tor_tls_t *tls, buf_t *buf, size_t sz, size_t *buf_flushlen)
   check();
   while (sz) {
     size_t flushlen0;
-    tor_assert(buf->head);
-    if (buf->head->datalen >= sz)
-      flushlen0 = sz;
-    else
-      flushlen0 = buf->head->datalen;
+    if (buf->head) {
+      if (buf->head->datalen >= sz)
+        flushlen0 = sz;
+      else
+        flushlen0 = buf->head->datalen;
+    } else {
+      flushlen0 = 0;
+    }
 
     r = flush_chunk_tls(tls, buf, buf->head, flushlen0, buf_flushlen);
     check();