trafficserver-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jpe...@apache.org
Subject [trafficserver] 01/33: TS-4425: Make the RefCountObj refcount private.
Date Wed, 11 May 2016 20:31:25 GMT
This is an automated email from the ASF dual-hosted git repository.

jpeach pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/trafficserver.git

commit 090a0685a61a24392a05423d7749fd8315fd6d4f
Author: James Peach <jpeach@apache.org>
AuthorDate: Wed May 4 21:34:25 2016 -0700

    TS-4425: Make the RefCountObj refcount private.
---
 lib/ts/Ptr.h          | 1 +
 proxy/InkIOCoreAPI.cc | 4 ++--
 proxy/hdrs/HdrHeap.cc | 7 ++++---
 proxy/hdrs/HdrTest.cc | 5 ++++-
 proxy/logging/Log.cc  | 2 +-
 5 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/lib/ts/Ptr.h b/lib/ts/Ptr.h
index a8d130a..edefcf2 100644
--- a/lib/ts/Ptr.h
+++ b/lib/ts/Ptr.h
@@ -69,6 +69,7 @@ public:
     delete this;
   }
 
+private:
   volatile int m_refcount;
 };
 
diff --git a/proxy/InkIOCoreAPI.cc b/proxy/InkIOCoreAPI.cc
index d8b462f..d8bbc36 100644
--- a/proxy/InkIOCoreAPI.cc
+++ b/proxy/InkIOCoreAPI.cc
@@ -54,7 +54,7 @@ sdk_sanity_check_mutex(TSMutex mutex)
 
   ProxyMutex *mutexp = (ProxyMutex *)mutex;
 
-  if (mutexp->m_refcount < 0)
+  if (mutexp->refcount() < 0)
     return TS_ERROR;
   if (mutexp->nthread_holding < 0)
     return TS_ERROR;
@@ -210,7 +210,7 @@ TSMutexCheck(TSMutex mutex)
 {
   ProxyMutex *mutexp = (ProxyMutex *)mutex;
 
-  if (mutexp->m_refcount < 0)
+  if (mutexp->refcount() < 0)
     return -1;
   if (mutexp->nthread_holding < 0)
     return -1;
diff --git a/proxy/hdrs/HdrHeap.cc b/proxy/hdrs/HdrHeap.cc
index 4fe3c69..28dd399 100644
--- a/proxy/hdrs/HdrHeap.cc
+++ b/proxy/hdrs/HdrHeap.cc
@@ -155,13 +155,14 @@ new_HdrStrHeap(int requested_size)
 
   //    Debug("hdrs", "Allocated string heap in size %d", alloc_size);
 
-  // Patch virtual function table ptr
-  *((void **)sh) = *((void **)&str_proto_heap);
+  // Placement new the HdrStrHeap.
+  sh = new (sh) HdrStrHeap();
 
   sh->m_heap_size = alloc_size;
   sh->m_free_size = alloc_size - STR_HEAP_HDR_SIZE;
   sh->m_free_start = ((char *)sh) + STR_HEAP_HDR_SIZE;
-  sh->m_refcount = 0;
+
+  ink_assert(sh->refcount() == 0);
 
   ink_assert(sh->m_free_size > 0);
 
diff --git a/proxy/hdrs/HdrTest.cc b/proxy/hdrs/HdrTest.cc
index 5ec020c..71fc29f 100644
--- a/proxy/hdrs/HdrTest.cc
+++ b/proxy/hdrs/HdrTest.cc
@@ -1257,7 +1257,10 @@ HdrTest::test_http_hdr_print_and_copy_aux(int testnum, const char *request,
cons
   /*** (2) copy the request header ***/
   HTTPHdr new_hdr, marshal_hdr;
   RefCountObj ref;
-  ref.m_refcount = 100;
+
+  // Pretend to pin this object with a refcount.
+  ref.refcount_inc();
+
   int marshal_len = hdr.m_heap->marshal(marshal_buf, marshal_bufsize);
   marshal_hdr.create(HTTP_TYPE_REQUEST);
   marshal_hdr.unmarshal(marshal_buf, marshal_len, &ref);
diff --git a/proxy/logging/Log.cc b/proxy/logging/Log.cc
index c71e373..6e481ca 100644
--- a/proxy/logging/Log.cc
+++ b/proxy/logging/Log.cc
@@ -1164,7 +1164,7 @@ Log::preproc_thread_main(void *args)
       // TODO: the bytes_to_disk should be set to Log
 
       Debug("log-preproc", "%zu buffers preprocessed from LogConfig %p (refcount=%d) this
round", buffers_preproced, current,
-            current->m_refcount);
+            current->refcount());
 
       configProcessor.release(log_configid, current);
     }

-- 
To stop receiving notification emails like this one, please contact
"commits@trafficserver.apache.org" <commits@trafficserver.apache.org>.

Mime
View raw message