You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@trafficserver.apache.org by jp...@apache.org on 2012/11/26 01:15:05 UTC
[1/2] git commit: TS-1594: ProxyMutexPtr and Ptr are
identical
Updated Branches:
refs/heads/master 6e8e65f40 -> 4704d3a5a
TS-1594: ProxyMutexPtr and Ptr<ProxyMutex> are identical
Project: http://git-wip-us.apache.org/repos/asf/trafficserver/repo
Commit: http://git-wip-us.apache.org/repos/asf/trafficserver/commit/4704d3a5
Tree: http://git-wip-us.apache.org/repos/asf/trafficserver/tree/4704d3a5
Diff: http://git-wip-us.apache.org/repos/asf/trafficserver/diff/4704d3a5
Branch: refs/heads/master
Commit: 4704d3a5a9584e9c98e657a4dde1f0d3c973bf10
Parents: 2017190
Author: James Peach <jp...@apache.org>
Authored: Sun Nov 25 16:14:44 2012 -0800
Committer: James Peach <jp...@apache.org>
Committed: Sun Nov 25 16:14:44 2012 -0800
----------------------------------------------------------------------
CHANGES | 2 +
iocore/cache/Cache.cc | 2 +-
iocore/eventsystem/I_Continuation.h | 2 +-
iocore/eventsystem/I_Lock.h | 229 +-----------------------------
proxy/ICP.h | 2 +-
proxy/MuxVC.cc | 4 +-
proxy/ParentSelection.cc | 2 +-
proxy/Prefetch.h | 2 +-
proxy/congest/Congestion.h | 2 +-
proxy/congest/CongestionTest.cc | 6 +-
proxy/congest/MT_hashtable.h | 2 +-
proxy/http/HttpClientSession.cc | 2 +-
12 files changed, 20 insertions(+), 237 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4704d3a5/CHANGES
----------------------------------------------------------------------
diff --git a/CHANGES b/CHANGES
index 0921ea9..72c8b3c 100644
--- a/CHANGES
+++ b/CHANGES
@@ -1,6 +1,8 @@
-*- coding: utf-8 -*-
Changes with Apache Traffic Server 3.3.1
+ *) [TS-1594] ProxyMutexPtr and Ptr<ProxyMutex> are identical
+
*) [TS-1591] gzip plugin should load relative config file
*) [TS-1582] C++11 requires space between strings and format specifiers
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4704d3a5/iocore/cache/Cache.cc
----------------------------------------------------------------------
diff --git a/iocore/cache/Cache.cc b/iocore/cache/Cache.cc
index 4cb67e9..019d8d0 100644
--- a/iocore/cache/Cache.cc
+++ b/iocore/cache/Cache.cc
@@ -2179,7 +2179,7 @@ Cache::remove(Continuation *cont, CacheKey *key, CacheFragType type,
ink_assert(this);
- ProxyMutexPtr mutex = NULL;
+ Ptr<ProxyMutex> mutex = NULL;
if (!cont)
cont = new_CacheRemoveCont();
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4704d3a5/iocore/eventsystem/I_Continuation.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/I_Continuation.h b/iocore/eventsystem/I_Continuation.h
index 247dc00..1de095b 100644
--- a/iocore/eventsystem/I_Continuation.h
+++ b/iocore/eventsystem/I_Continuation.h
@@ -118,7 +118,7 @@ public:
directly.
*/
- ProxyMutexPtr mutex;
+ Ptr<ProxyMutex> mutex;
/**
Link to other continuations.
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4704d3a5/iocore/eventsystem/I_Lock.h
----------------------------------------------------------------------
diff --git a/iocore/eventsystem/I_Lock.h b/iocore/eventsystem/I_Lock.h
index f99922f..7e91ec7 100644
--- a/iocore/eventsystem/I_Lock.h
+++ b/iocore/eventsystem/I_Lock.h
@@ -157,226 +157,6 @@ public:
// The ClassAlocator for ProxyMutexes
extern inkcoreapi ClassAllocator<ProxyMutex> mutexAllocator;
-/**
- Smart pointer to a ProxyMutex object.
-
- Given that the ProxyMutex object incorporates reference counting
- functionality, the ProxyMutexPtr provides a "smart pointer"
- interface for using references of the ProxyMutex class. Internally,
- it takes care of updating the object's reference count and to
- free it once that value drops to zero.
-
-*/
-class ProxyMutexPtr
-{
-public:
- /**
- Constructor of the ProxyMutexPtr class. You can provide a pointer
- to a ProxyMutex object or set it at a later time with the
- assignment operator.
-
- */
- ProxyMutexPtr(ProxyMutex * ptr = 0)
- : m_ptr(ptr)
- {
- if (m_ptr)
- REF_COUNT_OBJ_REFCOUNT_INC(m_ptr);
- }
-
- /**
- Copy constructor.
-
- Constructs a ProxyMutexPtr object from a constant reference to
- other. If the object to initialize from has a reference to a
- valid ProxyMutex object its reference count is incremented.
-
- @param src Constant ref to the ProxyMutexPtr to initialize from.
-
- */
- ProxyMutexPtr(const ProxyMutexPtr & src)
- : m_ptr(src.m_ptr)
- {
- if (m_ptr)
- REF_COUNT_OBJ_REFCOUNT_INC(m_ptr);
- }
-
- /**
- The destructor of a ProxyMutexPtr. It will free the ProxyMutex
- object pointed at by this instance only if this is the last
- reference to the object (reference count equal to zero).
-
- */
- ~ProxyMutexPtr()
- {
- if (m_ptr && !m_ptr->refcount_dec())
- m_ptr->free();
- }
-
- /**
- Assignment operator using a ProxyMutex object.
-
- Sets the ProxyMutex object to which this ProxyMutexPtr must
- point at. Since the reference to the ProxyMutex is replaced,
- the reference count for the previous object (if any) is decremented
- and the object is freed if it drops to zero.
-
- @param p The reference to the ProxyMutex object.
-
- */
- ProxyMutexPtr & operator =(ProxyMutex * p)
- {
- ProxyMutex *temp_ptr = m_ptr;
- if (m_ptr == p)
- return (*this);
- m_ptr = p;
- if (m_ptr)
- m_ptr->refcount_inc();
- if (temp_ptr && REF_COUNT_OBJ_REFCOUNT_DEC(((RefCountObj *) temp_ptr)) == 0)
- ((RefCountObj *) temp_ptr)->free();
- return (*this);
- }
-
- /**
- Assignment operator using another ProxyMutexPtr object.
-
- Sets the ProxyMutex object to which this ProxyMutexPtr must
- point at to that of the 'src'. Since the reference to the
- ProxyMutex is replaced, the reference count for the previous
- object (if any) is decremented and the object is freed if it
- drops to zero.
-
- @param src The ProxyMutexPtr to get the ProxyMutex reference from.
-
- */
- ProxyMutexPtr & operator =(const ProxyMutexPtr & src)
- {
- return (operator =(src.m_ptr));
- }
-
- /**
- Disassociates this object's reference to the ProxyMutex object
-
- This method verifies that the ProxyMutexPtr object no longer
- references a ProxyMutex object. If it does, the ProxyMutex's
- reference count is decremented and the object is freed if it
- drops to zero.
-
- */
- void clear()
- {
- if (m_ptr) {
- if (!((RefCountObj *) m_ptr)->refcount_dec())
- ((RefCountObj *) m_ptr)->free();
- m_ptr = NULL;
- }
- }
-
- // TODO eval if cast op needs to be removed
- // The casting operators do not fair well together with comparison
- // operators in many cases, gcc-3.4.x isn't too happy about it. It'd
- // probably be safer to get rid of them entirely.
- /**
- Cast operator.
-
- When the cast (ProxyMutex*) is applied to a ProxyMutexPtr object,
- a pointer to the managed ProxyMutex object is returned.
-
- */
- operator ProxyMutex *() const
- {
- return m_ptr;
- }
-
- /**
- Pointer member selection operator.
-
- When applied to a ProxyMutexPtr object, it is applied to the
- underlying ProxyMutex object. Make sure this ProxyMutexPtr
- object has a valid reference to a ProxyMutex before using it.
-
- */
- ProxyMutex *operator ->() const
- {
- return m_ptr;
- }
-
- /**
- Dereference operator.
-
- Provides access to the ProxyMutex object pointed at by this
- ProxyMutexPtr.
-
- */
- ProxyMutex & operator *() const
- {
- return (*m_ptr);
- }
-
- /**
- Equality operator.
-
- Returns true if the two pointers are equivalent (the rhs and
- the one stored inside the lhs ProxyMutexPtr object), otherwise
- false.
-
- */
- int operator ==(const ProxyMutex * p) const
- {
- return (m_ptr == p);
- }
-
- /**
- Equality operator.
-
- Returns true if the pointers managed by the rhs and lhs
- ProxyMutexPtr objects are equivalent.
-
- */
- int operator ==(const ProxyMutexPtr & p) const
- {
- return (m_ptr == p.m_ptr);
- }
-
- /**
- Inequality operator.
-
- Returns true if the two pointers are not equivalent (the rhs
- and the one stored inside the lhs ProxyMutexPtr object), otherwise
- false.
-
- */
- int operator !=(const ProxyMutex * p) const
- {
- return (m_ptr != p);
- }
-
- /**
- Inequality operator.
-
- Returns true if the pointers managed by the rhs and lhs
- ProxyMutexPtr objects are not equivalent.
-
- */
- int operator !=(const ProxyMutexPtr & p) const
- {
- return (m_ptr != p.m_ptr);
- }
-
- RefCountObj *_ptr()
- {
- return (RefCountObj *) m_ptr;
- }
-
- /**
- Pointer to the specified ProxyMutex.
-
- This is the pointer that stores the specified ProxyMutex. Do
- not set or modify its value directly.
-
- */
- ProxyMutex *m_ptr;
-};
-
inline bool
Mutex_trylock(
#ifdef DEBUG
@@ -535,8 +315,9 @@ Mutex_unlock(ProxyMutex * m, EThread * t)
struct MutexLock
{
- ProxyMutexPtr m;
- MutexLock():m(NULL)
+ Ptr<ProxyMutex> m;
+
+ MutexLock():m(NULL)
{
};
@@ -588,10 +369,10 @@ struct MutexLock
struct MutexTryLock
{
- ProxyMutexPtr m;
+ Ptr<ProxyMutex> m;
volatile bool lock_acquired;
- MutexTryLock(
+ MutexTryLock(
#ifdef DEBUG
const char *afile, int aline, const char *ahandler,
#endif //DEBUG
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4704d3a5/proxy/ICP.h
----------------------------------------------------------------------
diff --git a/proxy/ICP.h b/proxy/ICP.h
index 492dfb7..fe875f9 100644
--- a/proxy/ICP.h
+++ b/proxy/ICP.h
@@ -216,7 +216,7 @@ public:
void Unlock();
private:
- ProxyMutexPtr _mutex;
+ Ptr<ProxyMutex> _mutex;
};
#else // USE_CAS_FOR_ATOMICLOCK
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4704d3a5/proxy/MuxVC.cc
----------------------------------------------------------------------
diff --git a/proxy/MuxVC.cc b/proxy/MuxVC.cc
index 81f5656..799d8d2 100644
--- a/proxy/MuxVC.cc
+++ b/proxy/MuxVC.cc
@@ -1059,7 +1059,7 @@ MuxVC::do_connect(Continuation * c, unsigned int ip, int port)
// Keep our own mutex ref as we can get deallocted on the
// on the callback
- ProxyMutexPtr my_mutex_ref = mutex;
+ Ptr<ProxyMutex> my_mutex_ref = mutex;
// Fix Me: need to respect interface binding
MUTEX_TAKE_LOCK(my_mutex_ref, this_ethread());
@@ -2443,7 +2443,7 @@ MuxGetCont::init_for_new_mux(Continuation * c, unsigned int ip_arg, int port_arg
mux_vc->init();
// Using take lock since it's a brand new mutex
- ProxyMutexPtr mref = mux_vc->mutex;
+ Ptr<ProxyMutex> mref = mux_vc->mutex;
MUTEX_TAKE_LOCK(mref, c->mutex->thread_holding);
Action *tmp = mux_vc->do_connect(this, ip_arg, port_arg);
Mutex_unlock(mref, mref->thread_holding);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4704d3a5/proxy/ParentSelection.cc
----------------------------------------------------------------------
diff --git a/proxy/ParentSelection.cc b/proxy/ParentSelection.cc
index 2fd86b4..616e2e1 100644
--- a/proxy/ParentSelection.cc
+++ b/proxy/ParentSelection.cc
@@ -935,7 +935,7 @@ parentSelection_CB(const char *name, RecDataT data_type, RecData data, void *coo
//
int SocksServerConfig::m_id = 0;
-static ProxyMutexPtr socks_server_reconfig_mutex = NULL;
+static Ptr<ProxyMutex> socks_server_reconfig_mutex = NULL;
void
SocksServerConfig::startup()
{
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4704d3a5/proxy/Prefetch.h
----------------------------------------------------------------------
diff --git a/proxy/Prefetch.h b/proxy/Prefetch.h
index 914f551..34289fa 100644
--- a/proxy/Prefetch.h
+++ b/proxy/Prefetch.h
@@ -393,7 +393,7 @@ public:
typedef struct
{
KeepAliveConn *conn;
- ProxyMutexPtr mutex;
+ Ptr<ProxyMutex> mutex;
} conn_elem;
conn_elem *arr;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4704d3a5/proxy/congest/Congestion.h
----------------------------------------------------------------------
diff --git a/proxy/congest/Congestion.h b/proxy/congest/Congestion.h
index 3746f8e..6496601 100644
--- a/proxy/congest/Congestion.h
+++ b/proxy/congest/Congestion.h
@@ -211,7 +211,7 @@ struct CongestionEntry: public RequestData
// State -- connection failures
FailHistory m_history;
- ProxyMutexPtr m_hist_lock;
+ Ptr<ProxyMutex> m_hist_lock;
ink_hrtime m_last_congested;
volatile int m_congested; //0 | 1
int m_stat_congested_conn_failures;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4704d3a5/proxy/congest/CongestionTest.cc
----------------------------------------------------------------------
diff --git a/proxy/congest/CongestionTest.cc b/proxy/congest/CongestionTest.cc
index e93f4ad..9372f65 100644
--- a/proxy/congest/CongestionTest.cc
+++ b/proxy/congest/CongestionTest.cc
@@ -167,7 +167,7 @@ EXCLUSIVE_REGRESSION_TEST(Congestion_HashTable) (RegressionTest * t, int atype,
//-------------------------------------------------------------
// Test the FailHistory implementation
//-------------------------------------------------------------
-/* regesiter events into the FailHistory and the number of events
+/* register events into the FailHistory and the number of events
* should be correct
*/
struct CCFailHistoryTestCont: public Continuation
@@ -191,7 +191,7 @@ struct CCFailHistoryTestCont: public Continuation
{
}
- CCFailHistoryTestCont(ProxyMutexPtr _mutex, RegressionTest * _test)
+ CCFailHistoryTestCont(Ptr<ProxyMutex> _mutex, RegressionTest * _test)
: Continuation(_mutex),
test_mode(SIMPLE_TEST),
final_status(REGRESSION_TEST_PASSED), complete(false), test(_test), failEvents(NULL), pending_action(NULL)
@@ -386,7 +386,7 @@ struct CCCongestionDBTestCont: public Continuation
CongestionEntry *gen_CongestionEntry(sockaddr const* ip, int congested = 0);
- CCCongestionDBTestCont(ProxyMutexPtr _mutex, RegressionTest * _test):Continuation(_mutex),
+ CCCongestionDBTestCont(Ptr<ProxyMutex> _mutex, RegressionTest * _test):Continuation(_mutex),
final_status(REGRESSION_TEST_PASSED), complete(false), test(_test), rule(NULL), db(NULL), dbsize(1024)
{
SET_HANDLER(&CCCongestionDBTestCont::mainEvent);
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4704d3a5/proxy/congest/MT_hashtable.h
----------------------------------------------------------------------
diff --git a/proxy/congest/MT_hashtable.h b/proxy/congest/MT_hashtable.h
index cbe7084..2d0bc3b 100644
--- a/proxy/congest/MT_hashtable.h
+++ b/proxy/congest/MT_hashtable.h
@@ -396,7 +396,7 @@ public:
private:
IMTHashTable<key_t, data_t> *hashTables[MT_HASHTABLE_PARTITIONS];
- ProxyMutexPtr locks[MT_HASHTABLE_PARTITIONS];
+ Ptr<ProxyMutex> locks[MT_HASHTABLE_PARTITIONS];
// MT_ListEntry chain_heads[MT_HASHTABLE_PARTITIONS];
// int last_GC_time[MT_HASHTABLE_PARTITIONS];
// int32_t cur_items;
http://git-wip-us.apache.org/repos/asf/trafficserver/blob/4704d3a5/proxy/http/HttpClientSession.cc
----------------------------------------------------------------------
diff --git a/proxy/http/HttpClientSession.cc b/proxy/http/HttpClientSession.cc
index 6e5dd1e..b214482 100644
--- a/proxy/http/HttpClientSession.cc
+++ b/proxy/http/HttpClientSession.cc
@@ -239,7 +239,7 @@ HttpClientSession::new_connection(NetVConnection * new_vc, bool backdoor)
// when we return from do_api_callout, the ClientSession may
// have already been deallocated.
EThread *ethis = this_ethread();
- ProxyMutexPtr lmutex = this->mutex;
+ Ptr<ProxyMutex> lmutex = this->mutex;
MUTEX_TAKE_LOCK(lmutex, ethis);
do_api_callout(TS_HTTP_SSN_START_HOOK);
MUTEX_UNTAKE_LOCK(lmutex, ethis);