You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by zw...@apache.org on 2012/03/23 23:40:42 UTC

git commit: TS-827 Use the new ProtectHeaps class. William, can you make sure this looks good to you?

Updated Branches:
  refs/heads/master 1ffea7941 -> 793f3cfc0


TS-827 Use the new ProtectHeaps class. William, can you make sure this looks good to you?


Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/793f3cfc
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/793f3cfc
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/793f3cfc

Branch: refs/heads/master
Commit: 793f3cfc0ccd01a4dae551af3aa3aa1a5ea77856
Parents: 1ffea79
Author: Leif Hedstrom <le...@ogre.com>
Authored: Fri Mar 23 16:40:34 2012 -0600
Committer: Leif Hedstrom <le...@ogre.com>
Committed: Fri Mar 23 16:40:34 2012 -0600

----------------------------------------------------------------------
 proxy/hdrs/MIME.cc |   21 +--------------------
 1 files changed, 1 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/trafficserver/blob/793f3cfc/proxy/hdrs/MIME.cc
----------------------------------------------------------------------
diff --git a/proxy/hdrs/MIME.cc b/proxy/hdrs/MIME.cc
index 2fa5f66..2242ef3 100644
--- a/proxy/hdrs/MIME.cc
+++ b/proxy/hdrs/MIME.cc
@@ -1762,6 +1762,7 @@ mime_field_value_str_from_strlist(HdrHeap *heap, int *new_str_len_return, StrLis
   Str *cell;
   char *new_value, *dest;
   int i, new_value_len;
+  HdrHeap::ProtectHeaps protect(heap);
 
   new_value_len = 0;
 
@@ -1796,19 +1797,6 @@ mime_field_value_str_from_strlist(HdrHeap *heap, int *new_str_len_return, StrLis
   return new_value;
 }
 
-// Make sure that there is enough space for a header value string with out calling coalesce_str_heaps()
-// when we have pointers into the heap. TODO: This might need to attention for a future release, but
-// ok for now. /leif
-static void verify_heap_prealloc(HdrHeap *heap, size_t prealloc_len)
-{
-    // If there just isn't enough free space in the read-write heap.
-    if (heap->m_read_write_heap && heap->m_read_write_heap->m_free_size <= prealloc_len) {
-        // Allocate enough space, 'free' it, and then coalesce it so it will actually be free not just lost.
-        heap->free_string(heap->allocate_str(prealloc_len), prealloc_len);
-        heap->coalesce_str_heaps();
-    }
-}
-
 void
 mime_field_value_set_comma_val(HdrHeap *heap, MIMEHdrImpl *mh,
                                MIMEField *field, int idx, const char *new_piece_str, int new_piece_len)
@@ -1817,8 +1805,6 @@ mime_field_value_set_comma_val(HdrHeap *heap, MIMEHdrImpl *mh,
   Str *cell;
   StrList list(false);
 
-  verify_heap_prealloc(heap, field->m_len_value + 2 + new_piece_len);
-
   // (1) rip the value into tokens, keeping surrounding quotes, but not whitespace
   HttpCompat::parse_tok_list(&list, 0, field->m_ptr_value, field->m_len_value, ',');
 
@@ -1849,8 +1835,6 @@ mime_field_value_delete_comma_val(HdrHeap *heap, MIMEHdrImpl *mh, MIMEField *fie
   Str *cell;
   StrList list(false);
 
-  verify_heap_prealloc(heap, field->m_len_value);
-
   // (1) rip the value into tokens, keeping surrounding quotes, but not whitespace
   HttpCompat::parse_tok_list(&list, 0, field->m_ptr_value, field->m_len_value, ',');
 
@@ -1897,7 +1881,6 @@ mime_field_value_insert_comma_val(HdrHeap *heap, MIMEHdrImpl *mh, MIMEField *fie
   Str *cell, *prev;
   StrList list(false);
 
-  verify_heap_prealloc(heap, field->m_len_value + 2 + new_piece_len);
   // (1) rip the value into tokens, keeping surrounding quotes, but not whitespace
   HttpCompat::parse_tok_list(&list, 0, field->m_ptr_value, field->m_len_value, ',');
 
@@ -1938,8 +1921,6 @@ mime_field_value_extend_comma_val(HdrHeap *heap, MIMEHdrImpl *mh, MIMEField *fie
   size_t extended_len;
   char *dest, *temp_ptr, temp_buf[128];
 
-  verify_heap_prealloc(heap, field->m_len_value + 2 + new_piece_len);
-
   // (1) rip the value into tokens, keeping surrounding quotes, but not whitespace
   HttpCompat::parse_tok_list(&list, 0, field->m_ptr_value, field->m_len_value, ',');