summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorRichard Linden <none@none>2013-01-08 00:25:07 -0800
committerRichard Linden <none@none>2013-01-08 00:25:07 -0800
commit3c341a11ab7b8f3fd18afcf3f50af6dfafa632c2 (patch)
treec937cdcd5368a2b4665d06a1af047eebddd31737 /indra/llcommon
parent68413515029f50713c70e4adec3ce6fd1022d59f (diff)
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 straight
Diffstat (limited to 'indra/llcommon')
-rw-r--r--indra/llcommon/llapr.cpp19
-rw-r--r--indra/llcommon/llapr.h5
-rw-r--r--indra/llcommon/llmutex.cpp11
3 files changed, 26 insertions, 9 deletions
diff --git a/indra/llcommon/llapr.cpp b/indra/llcommon/llapr.cpp
index 8a87911315..0556fadb26 100644
--- a/indra/llcommon/llapr.cpp
+++ b/indra/llcommon/llapr.cpp
@@ -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;
diff --git a/indra/llcommon/llapr.h b/indra/llcommon/llapr.h
index 424ddc6505..3b65c0dc34 100644
--- a/indra/llcommon/llapr.h
+++ b/indra/llcommon/llapr.h
@@ -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
diff --git a/indra/llcommon/llmutex.cpp b/indra/llcommon/llmutex.cpp
index b685bb4d60..ad0287c6d5 100644
--- a/indra/llcommon/llmutex.cpp
+++ b/indra/llcommon/llmutex.cpp
@@ -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;
}