trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zw...@apache.org
Subject svn commit: r1042404 - in /trafficserver/traffic/trunk/proxy: ICP.cc InkAPI.cc hdrs/HdrHeap.h hdrs/Makefile.am hdrs/SDKAllocator.cc hdrs/SDKAllocator.h http2/HttpTransact.cc http2/HttpTransact.h
Date Sun, 05 Dec 2010 19:02:28 GMT
Author: zwoop
Date: Sun Dec  5 19:02:27 2010
New Revision: 1042404

URL: http://svn.apache.org/viewvc?rev=1042404&view=rev
Log:
TS-577 Replace the SDKAllocator with a ClassAllocator.

This reduces the amount of memory allocation for plugins,
but requires that plugins now religiously release the
handles that they are expected to release (i.e. no automatic
gc is done for lazy developers).

Removed:
    trafficserver/traffic/trunk/proxy/hdrs/SDKAllocator.cc
    trafficserver/traffic/trunk/proxy/hdrs/SDKAllocator.h
Modified:
    trafficserver/traffic/trunk/proxy/ICP.cc
    trafficserver/traffic/trunk/proxy/InkAPI.cc
    trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.h
    trafficserver/traffic/trunk/proxy/hdrs/Makefile.am
    trafficserver/traffic/trunk/proxy/http2/HttpTransact.cc
    trafficserver/traffic/trunk/proxy/http2/HttpTransact.h

Modified: trafficserver/traffic/trunk/proxy/ICP.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/ICP.cc?rev=1042404&r1=1042403&r2=1042404&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/ICP.cc (original)
+++ trafficserver/traffic/trunk/proxy/ICP.cc Sun Dec  5 19:02:27 2010
@@ -339,12 +339,10 @@ ICPPeerReadCont::reset(int full_reset)
     PeerReadDataAllocator.free(this->_state);
   }
   if (_cache_req_hdr_heap_handle) {
-    _cache_req_hdr_heap_handle->m_sdk_alloc.free_all();
     xfree(_cache_req_hdr_heap_handle);
     _cache_req_hdr_heap_handle = NULL;
   }
   if (_cache_resp_hdr_heap_handle) {
-    _cache_resp_hdr_heap_handle->m_sdk_alloc.free_all();
     xfree(_cache_resp_hdr_heap_handle);
     _cache_resp_hdr_heap_handle = NULL;
   }

Modified: trafficserver/traffic/trunk/proxy/InkAPI.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/InkAPI.cc?rev=1042404&r1=1042403&r2=1042404&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/InkAPI.cc (original)
+++ trafficserver/traffic/trunk/proxy/InkAPI.cc Sun Dec  5 19:02:27 2010
@@ -358,6 +358,7 @@ static int ts_patch_version = 0;
 static ClassAllocator<APIHook> apiHookAllocator("apiHookAllocator");
 static ClassAllocator<INKContInternal> INKContAllocator("INKContAllocator");
 static ClassAllocator<INKVConnInternal> INKVConnAllocator("INKVConnAllocator");
+static ClassAllocator<MIMEFieldSDKHandle> mHandleAllocator("MIMEFieldSDKHandle");
 
 // Error Ptr.
 tsapi const void *TS_ERROR_PTR = (const void *) 0x00000bad;
@@ -712,9 +713,8 @@ static MIMEFieldSDKHandle *
 sdk_alloc_field_handle(TSMBuffer bufp, MIMEHdrImpl *mh)
 {
   if (sdk_sanity_check_mbuffer(bufp) == TS_SUCCESS) {
-    HdrHeapSDKHandle *sdk_heap = (HdrHeapSDKHandle *) bufp;
+    MIMEFieldSDKHandle *handle = mHandleAllocator.alloc();
 
-    MIMEFieldSDKHandle *handle = sdk_heap->m_sdk_alloc.allocate_mhandle();
     obj_init_header(handle, HDR_HEAP_OBJ_FIELD_SDK_HANDLE, sizeof(MIMEFieldSDKHandle), 0);
     handle->mh = mh;
     return handle;
@@ -726,13 +726,7 @@ static void
 sdk_free_field_handle(TSMBuffer bufp, MIMEFieldSDKHandle *field_handle)
 {
   if (sdk_sanity_check_mbuffer(bufp) == TS_SUCCESS) {
-    HdrHeapSDKHandle *sdk_heap = (HdrHeapSDKHandle *) bufp;
-
-    field_handle->m_type = HDR_HEAP_OBJ_EMPTY;
-    field_handle->mh = NULL;
-    field_handle->field_ptr = NULL;
-
-    sdk_heap->m_sdk_alloc.free_mhandle(field_handle);
+    mHandleAllocator.free(field_handle);
   }
 }
 
@@ -4616,7 +4610,6 @@ TSHttpTxnCachedReqGet(TSHttpTxn txnp, TS
   if (*handle == NULL) {
     *handle = (HdrHeapSDKHandle *) sm->t_state.arena.alloc(sizeof(HdrHeapSDKHandle));
     (*handle)->m_heap = cached_hdr->m_heap;
-    (*handle)->m_sdk_alloc.init();
   }
 
   *bufp = *handle;
@@ -4656,7 +4649,6 @@ TSHttpTxnCachedRespGet(TSHttpTxn txnp, T
   if (*handle == NULL) {
     *handle = (HdrHeapSDKHandle *) sm->t_state.arena.alloc(sizeof(HdrHeapSDKHandle));
     (*handle)->m_heap = cached_hdr->m_heap;
-    (*handle)->m_sdk_alloc.init();
   }
 
   *bufp = *handle;
@@ -7082,7 +7074,6 @@ TSICPCachedReqGet(TSCont contp, TSMBuffe
   if (*handle == NULL) {
     *handle = (HdrHeapSDKHandle *) xmalloc(sizeof(HdrHeapSDKHandle));
     (*handle)->m_heap = cached_hdr->m_heap;
-    (*handle)->m_sdk_alloc.init();
   }
 
   *bufp = *handle;
@@ -7115,7 +7106,6 @@ TSICPCachedRespGet(TSCont contp, TSMBuff
   if (*handle == NULL) {
     *handle = (HdrHeapSDKHandle *) xmalloc(sizeof(HdrHeapSDKHandle));
     (*handle)->m_heap = cached_hdr->m_heap;
-    (*handle)->m_sdk_alloc.init();
   }
 
   *bufp = *handle;

Modified: trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.h?rev=1042404&r1=1042403&r2=1042404&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.h (original)
+++ trafficserver/traffic/trunk/proxy/hdrs/HdrHeap.h Sun Dec  5 19:02:27 2010
@@ -39,7 +39,6 @@
 #include "ink_assert.h"
 #include "Arena.h"
 #include "HdrToken.h"
-#include "SDKAllocator.h"
 
 // Objects in the heap must currently be aligned to 8 byte boundaries,
 // so their (address & HDR_PTR_ALIGNMENT_MASK) == 0
@@ -400,20 +399,11 @@ if (ptr) { \
 struct HdrHeapSDKHandle
 {
 public:
-  //  For the SDK, we need to copy strings to add
-  //    NULL termination, allocate standalone fields
-  //    and allocate field handles, we need an allocator.
-  //  To maintain compatibility with previous releases,
-  //    everything allocated should go away when the
-  //    hdr heap is deallocated so we need to keep
-  //    a list of the live objects
-  //  SDKAllocator accomplishes both these tasks
-  SDKAllocator m_sdk_alloc;
-  HdrHeap *m_heap;
+  HdrHeapSDKHandle()
+    : m_heap(NULL)
+  { }
 
-public:
-    HdrHeapSDKHandle();
-   ~HdrHeapSDKHandle();
+  ~HdrHeapSDKHandle() { clear(); }
 
   // clear() only deallocates chained SDK return values
   //   The underlying MBuffer is left untouched
@@ -426,6 +416,8 @@ public:
   void set(const HdrHeapSDKHandle * from);
   const char *make_sdk_string(const char *raw_str, int raw_str_len);
 
+  HdrHeap *m_heap;
+
 private:
   // In order to prevent gratitous refcounting,
   //  automatic C++ copies are disabled!
@@ -433,14 +425,6 @@ private:
     HdrHeapSDKHandle & operator =(const HdrHeapSDKHandle & r);
 };
 
-
-inline
-HdrHeapSDKHandle::HdrHeapSDKHandle():
-m_sdk_alloc(),
-m_heap(NULL)
-{
-}
-
 inline void
 HdrHeapSDKHandle::destroy()
 {
@@ -454,17 +438,6 @@ inline void
 HdrHeapSDKHandle::clear()
 {
   m_heap = NULL;
-
-  if (m_sdk_alloc.head) {
-    m_sdk_alloc.free_all();
-  }
-}
-
-inline
-HdrHeapSDKHandle::~
-HdrHeapSDKHandle()
-{
-  clear();
 }
 
 inline void

Modified: trafficserver/traffic/trunk/proxy/hdrs/Makefile.am
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/hdrs/Makefile.am?rev=1042404&r1=1042403&r2=1042404&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/hdrs/Makefile.am (original)
+++ trafficserver/traffic/trunk/proxy/hdrs/Makefile.am Sun Dec  5 19:02:27 2010
@@ -38,8 +38,6 @@ libhdrs_a_SOURCES = \
   HttpCompat.h \
   MIME.cc \
   MIME.h \
-  SDKAllocator.cc \
-  SDKAllocator.h \
   URL.cc \
   URL.h
 

Modified: trafficserver/traffic/trunk/proxy/http2/HttpTransact.cc
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/HttpTransact.cc?rev=1042404&r1=1042403&r2=1042404&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/HttpTransact.cc (original)
+++ trafficserver/traffic/trunk/proxy/http2/HttpTransact.cc Sun Dec  5 19:02:27 2010
@@ -2964,22 +2964,6 @@ HttpTransact::handle_cache_write_lock(St
 
   if (s->cache_info.write_lock_state == CACHE_WL_READ_RETRY) {
     s->hdr_info.server_request.destroy();
-
-    // We need to cleanup SDK handles to cached hdrs
-    //   since those headers are no longer good as we've closed
-    //   the orginal cache read vc and replaced it with a new cache
-    //   read vc on the write lock read retry loop
-    if (s->cache_req_hdr_heap_handle) {
-      s->cache_req_hdr_heap_handle->m_sdk_alloc.free_all();
-      s->arena.free(s->cache_req_hdr_heap_handle, sizeof(HdrHeapSDKHandle));
-      s->cache_req_hdr_heap_handle = NULL;
-    }
-    if (s->cache_resp_hdr_heap_handle) {
-      s->cache_resp_hdr_heap_handle->m_sdk_alloc.free_all();
-      s->arena.free(s->cache_resp_hdr_heap_handle, sizeof(HdrHeapSDKHandle));
-      s->cache_resp_hdr_heap_handle = NULL;
-    }
-
     HandleCacheOpenReadHitFreshness(s);
   } else {
     StateMachineAction_t next;

Modified: trafficserver/traffic/trunk/proxy/http2/HttpTransact.h
URL: http://svn.apache.org/viewvc/trafficserver/traffic/trunk/proxy/http2/HttpTransact.h?rev=1042404&r1=1042403&r2=1042404&view=diff
==============================================================================
--- trafficserver/traffic/trunk/proxy/http2/HttpTransact.h (original)
+++ trafficserver/traffic/trunk/proxy/http2/HttpTransact.h Sun Dec  5 19:02:27 2010
@@ -1237,14 +1237,6 @@ public:
         }
         pCongestionEntry->put(), pCongestionEntry = NULL;
       }
-      // if cache_*_hdr_heap_handles have been allocated by the SDK functions
-      // INKHttpTxnCachedReqGet and INKHttpTxnCachedRespGet, let's free their data.
-      if (cache_req_hdr_heap_handle) {
-        cache_req_hdr_heap_handle->m_sdk_alloc.free_all();
-      }
-      if (cache_resp_hdr_heap_handle) {
-        cache_resp_hdr_heap_handle->m_sdk_alloc.free_all();
-      }
 
       url_map.clear();
       arena.reset();



Mime
View raw message