Permalink
Browse files

TS-1594: ProxyMutexPtr and Ptr<ProxyMutex> are identical

  • Loading branch information...
jpeach committed Nov 26, 2012
1 parent 2017190 commit 4704d3a5a9584e9c98e657a4dde1f0d3c973bf10
View
@@ -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
View
@@ -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();
@@ -118,7 +118,7 @@ class Continuation: private force_VFPT_to_top
directly.
*/
- ProxyMutexPtr mutex;
+ Ptr<ProxyMutex> mutex;
/**
Link to other continuations.
View
@@ -157,226 +157,6 @@ class ProxyMutex: public RefCountObj
// 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
View
@@ -216,7 +216,7 @@ class AtomicLock
void Unlock();
private:
- ProxyMutexPtr _mutex;
+ Ptr<ProxyMutex> _mutex;
};
#else // USE_CAS_FOR_ATOMICLOCK
View
@@ -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);
View
@@ -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()
{
View
@@ -393,7 +393,7 @@ class KeepAliveConnTable
typedef struct
{
KeepAliveConn *conn;
- ProxyMutexPtr mutex;
+ Ptr<ProxyMutex> mutex;
} conn_elem;
conn_elem *arr;
@@ -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;
@@ -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);
@@ -396,7 +396,7 @@ template<class key_t, class data_t> class MTHashTable {
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;
@@ -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);

0 comments on commit 4704d3a

Please sign in to comment.