trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From shinr...@apache.org
Subject [trafficserver] branch master updated: Clone the url object into the new heap
Date Fri, 22 Jun 2018 17:08:59 GMT
This is an automated email from the ASF dual-hosted git repository.

shinrich pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git


The following commit(s) were added to refs/heads/master by this push:
     new f6cb212  Clone the url object into the new heap
f6cb212 is described below

commit f6cb212e0133894e4e3a883a6497ce645ebce7b7
Author: Susan Hinrichs <shinrich@apache.org>
AuthorDate: Thu Jun 21 18:25:16 2018 +0000

    Clone the url object into the new heap
---
 proxy/hdrs/HTTP.cc   | 14 +++++++++++++-
 proxy/hdrs/HdrHeap.h |  1 +
 2 files changed, 14 insertions(+), 1 deletion(-)

diff --git a/proxy/hdrs/HTTP.cc b/proxy/hdrs/HTTP.cc
index dad3210..907f6da 100644
--- a/proxy/hdrs/HTTP.cc
+++ b/proxy/hdrs/HTTP.cc
@@ -699,7 +699,19 @@ http_hdr_url_set(HdrHeap *heap, HTTPHdrImpl *hh, URLImpl *url)
     if (hh->u.req.m_url_impl != nullptr) {
       heap->deallocate_obj(hh->u.req.m_url_impl);
     }
-    hh->u.req.m_url_impl = url;
+    // Clone into new heap if the URL was allocated against a different heap
+    if ((char *)url < heap->m_data_start || (char *)url >= heap->m_free_start)
{
+      hh->u.req.m_url_impl = static_cast<URLImpl *>(heap->allocate_obj(url->m_length,
url->m_type));
+      memcpy(hh->u.req.m_url_impl, url, url->m_length);
+      // Make sure there is a read_write heap
+      if (heap->m_read_write_heap.get() == nullptr) {
+        int url_string_length   = url->strings_length();
+        heap->m_read_write_heap = new_HdrStrHeap(url_string_length);
+      }
+      hh->u.req.m_url_impl->move_strings(heap->m_read_write_heap.get());
+    } else {
+      hh->u.req.m_url_impl = url;
+    }
   }
 }
 
diff --git a/proxy/hdrs/HdrHeap.h b/proxy/hdrs/HdrHeap.h
index 8b0b669..9fb2e00 100644
--- a/proxy/hdrs/HdrHeap.h
+++ b/proxy/hdrs/HdrHeap.h
@@ -476,6 +476,7 @@ HdrHeapSDKHandle::set(const HdrHeapSDKHandle *from)
   m_heap = from->m_heap;
 }
 
+HdrStrHeap *new_HdrStrHeap(int requested_size);
 inkcoreapi HdrHeap *new_HdrHeap(int size = HDR_HEAP_DEFAULT_SIZE);
 
 void hdr_heap_test();


Mime
View raw message