SH-3468 WIP add memory tracking base class
more fixes for unit test crashes added llcommon initialization/teardown for unit tests that indirectly trigger lltrace changed access of atomic refcount to use preincrement/decrement operators to reflect desired semantics always call apr_initialize in LLCommon::initClass, even if already initialized...apr does internal reference counting to keep things straightmaster
parent
6841351502
commit
3c341a11ab
|
|
@ -38,12 +38,15 @@ apr_thread_mutex_t *gCallStacksLogMutexp = NULL;
|
|||
|
||||
const S32 FULL_VOLATILE_APR_POOL = 1024 ; //number of references to LLVolatileAPRPool
|
||||
|
||||
bool gAPRInitialized = false;
|
||||
|
||||
void ll_init_apr()
|
||||
{
|
||||
// Initialize APR and create the global pool
|
||||
apr_initialize();
|
||||
|
||||
if (!gAPRPoolp)
|
||||
{
|
||||
// Initialize APR and create the global pool
|
||||
apr_initialize();
|
||||
apr_pool_create(&gAPRPoolp, NULL);
|
||||
|
||||
// Initialize the logging mutex
|
||||
|
|
@ -57,11 +60,19 @@ void ll_init_apr()
|
|||
}
|
||||
|
||||
LLThreadLocalPointerBase::initAllThreadLocalStorage();
|
||||
gAPRInitialized = true;
|
||||
}
|
||||
|
||||
|
||||
void ll_cleanup_apr(bool destroy_pools)
|
||||
bool ll_apr_is_initialized()
|
||||
{
|
||||
return gAPRInitialized;
|
||||
}
|
||||
|
||||
void ll_cleanup_apr()
|
||||
{
|
||||
gAPRInitialized = false;
|
||||
|
||||
LL_INFOS("APR") << "Cleaning up APR" << LL_ENDL;
|
||||
|
||||
if (gLogMutexp)
|
||||
|
|
@ -83,7 +94,7 @@ void ll_cleanup_apr(bool destroy_pools)
|
|||
|
||||
LLThreadLocalPointerBase::destroyAllThreadLocalStorage();
|
||||
|
||||
if (gAPRPoolp && destroy_pools)
|
||||
if (gAPRPoolp)
|
||||
{
|
||||
apr_pool_destroy(gAPRPoolp);
|
||||
gAPRPoolp = NULL;
|
||||
|
|
|
|||
|
|
@ -70,7 +70,10 @@ void LL_COMMON_API ll_init_apr();
|
|||
/**
|
||||
* @brief Cleanup those common apr constructs.
|
||||
*/
|
||||
void LL_COMMON_API ll_cleanup_apr(bool destroy_pools = true);
|
||||
void LL_COMMON_API ll_cleanup_apr();
|
||||
|
||||
bool LL_COMMON_API ll_apr_is_initialized();
|
||||
|
||||
|
||||
//
|
||||
//LL apr_pool
|
||||
|
|
|
|||
|
|
@ -56,12 +56,15 @@ LLMutex::~LLMutex()
|
|||
//bad assertion, the subclass LLSignal might be "locked", and that's OK
|
||||
//llassert_always(!isLocked()); // better not be locked!
|
||||
#endif
|
||||
apr_thread_mutex_destroy(mAPRMutexp);
|
||||
mAPRMutexp = NULL;
|
||||
if (mIsLocalPool)
|
||||
if (ll_apr_is_initialized())
|
||||
{
|
||||
apr_pool_destroy(mAPRPoolp);
|
||||
apr_thread_mutex_destroy(mAPRMutexp);
|
||||
if (mIsLocalPool)
|
||||
{
|
||||
apr_pool_destroy(mAPRPoolp);
|
||||
}
|
||||
}
|
||||
mAPRMutexp = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ private:
|
|||
|
||||
inline void RefCounted::addRef() const
|
||||
{
|
||||
S32 count(mRefCount++);
|
||||
S32 count(++mRefCount);
|
||||
llassert_always(count >= 0);
|
||||
}
|
||||
|
||||
|
|
@ -82,7 +82,7 @@ inline void RefCounted::release() const
|
|||
S32 count(mRefCount);
|
||||
llassert_always(count != NOT_REF_COUNTED);
|
||||
llassert_always(count > 0);
|
||||
count = mRefCount--;
|
||||
count = --mRefCount;
|
||||
|
||||
// clean ourselves up if that was the last reference
|
||||
if (0 == count)
|
||||
|
|
|
|||
|
|
@ -61,8 +61,11 @@ LLProxy::LLProxy():
|
|||
|
||||
LLProxy::~LLProxy()
|
||||
{
|
||||
stopSOCKSProxy();
|
||||
disableHTTPProxy();
|
||||
if (ll_apr_is_initialized())
|
||||
{
|
||||
stopSOCKSProxy();
|
||||
disableHTTPProxy();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@
|
|||
#include "llsdrpcclient.h"
|
||||
#include "llsdrpcserver.h"
|
||||
#include "llsdserialize.h"
|
||||
#include "llcommon.h"
|
||||
#include "lluuid.h"
|
||||
#include "llinstantmessage.h"
|
||||
|
||||
|
|
@ -830,6 +831,7 @@ namespace tut
|
|||
public:
|
||||
PumpAndChainTestData()
|
||||
{
|
||||
LLCommon::initClass();
|
||||
apr_pool_create(&mPool, NULL);
|
||||
mPump = new LLPumpIO(mPool);
|
||||
}
|
||||
|
|
@ -839,6 +841,7 @@ namespace tut
|
|||
mChain.clear();
|
||||
delete mPump;
|
||||
apr_pool_destroy(mPool);
|
||||
LLCommon::cleanupClass();
|
||||
}
|
||||
};
|
||||
typedef test_group<PumpAndChainTestData> PumpAndChainTestGroup;
|
||||
|
|
@ -909,6 +912,7 @@ namespace tut
|
|||
|
||||
pipe_and_pump_fitness()
|
||||
{
|
||||
LLCommon::initClass();
|
||||
LLFrameTimer::updateFrameTime();
|
||||
apr_pool_create(&mPool, NULL);
|
||||
mPump = new LLPumpIO(mPool);
|
||||
|
|
@ -923,6 +927,7 @@ namespace tut
|
|||
mSocket.reset();
|
||||
delete mPump;
|
||||
apr_pool_destroy(mPool);
|
||||
LLCommon::cleanupClass();
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
@ -1186,8 +1191,12 @@ namespace tut
|
|||
LLSimpleRPCResponse(LLSD* response) :
|
||||
mResponsePtr(response)
|
||||
{
|
||||
LLCommon::initClass();
|
||||
}
|
||||
~LLSimpleRPCResponse()
|
||||
{
|
||||
LLCommon::cleanupClass();
|
||||
}
|
||||
~LLSimpleRPCResponse() {}
|
||||
virtual bool response(LLPumpIO* pump)
|
||||
{
|
||||
*mResponsePtr = mReturnValue;
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@
|
|||
#include "lltut.h"
|
||||
|
||||
#include "lldate.h"
|
||||
#include "llcommon.h"
|
||||
#include "llframetimer.h"
|
||||
|
||||
#include <time.h>
|
||||
|
|
@ -38,6 +39,14 @@ namespace tut
|
|||
{
|
||||
struct httpdate_data
|
||||
{
|
||||
httpdate_data()
|
||||
{
|
||||
LLCommon::initClass();
|
||||
}
|
||||
~httpdate_data()
|
||||
{
|
||||
LLCommon::cleanupClass();
|
||||
}
|
||||
LLDate some_date;
|
||||
};
|
||||
typedef test_group<httpdate_data> httpdate_test;
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@
|
|||
#include "lliohttpserver.h"
|
||||
#include "llsdhttpserver.h"
|
||||
#include "llsdserialize.h"
|
||||
#include "llcommon.h"
|
||||
|
||||
#include "llpipeutil.h"
|
||||
|
||||
|
|
@ -76,11 +77,17 @@ namespace tut
|
|||
HTTPServiceTestData()
|
||||
: mResponse(NULL)
|
||||
{
|
||||
LLCommon::initClass();
|
||||
LLHTTPStandardServices::useServices();
|
||||
LLHTTPRegistrar::buildAllServices(mRoot);
|
||||
mRoot.addNode("/delayed/echo", new DelayedEcho(this));
|
||||
mRoot.addNode("/wire/hello", new LLHTTPNodeForPipe<WireHello>);
|
||||
}
|
||||
|
||||
~HTTPServiceTestData()
|
||||
{
|
||||
LLCommon::cleanupClass();
|
||||
}
|
||||
|
||||
LLHTTPNode mRoot;
|
||||
LLHTTPNode::ResponsePtr mResponse;
|
||||
|
|
|
|||
|
|
@ -643,7 +643,7 @@ int main(int argc, char **argv)
|
|||
s.close();
|
||||
}
|
||||
|
||||
ll_cleanup_apr(false);
|
||||
ll_cleanup_apr();
|
||||
|
||||
int retval = (success ? 0 : 1);
|
||||
return retval;
|
||||
|
|
|
|||
Loading…
Reference in New Issue