diff options
Diffstat (limited to 'indra/llcommon')
-rw-r--r-- | indra/llcommon/CMakeLists.txt | 2 | ||||
-rw-r--r-- | indra/llcommon/llapr.cpp | 19 | ||||
-rw-r--r-- | indra/llcommon/llapr.h | 5 | ||||
-rw-r--r-- | indra/llcommon/llmutex.cpp | 11 | ||||
-rw-r--r-- | indra/llcommon/lltrace.cpp | 17 | ||||
-rw-r--r-- | indra/llcommon/llwin32headers.h | 4 | ||||
-rw-r--r-- | indra/llcommon/llwin32headerslean.h | 4 |
7 files changed, 47 insertions, 15 deletions
diff --git a/indra/llcommon/CMakeLists.txt b/indra/llcommon/CMakeLists.txt index 28677b036d..7ed1671ca8 100644 --- a/indra/llcommon/CMakeLists.txt +++ b/indra/llcommon/CMakeLists.txt @@ -257,6 +257,8 @@ set(llcommon_HEADER_FILES lluuidhashmap.h llversionserver.h llversionviewer.h + llwin32headers.h + llwin32headerslean.h llworkerthread.h ll_template_cast.h metaclass.h 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; } diff --git a/indra/llcommon/lltrace.cpp b/indra/llcommon/lltrace.cpp index 9cadd70dd8..463048008f 100644 --- a/indra/llcommon/lltrace.cpp +++ b/indra/llcommon/lltrace.cpp @@ -30,7 +30,7 @@ #include "lltracethreadrecorder.h" #include "llfasttimer.h" -static bool sInitialized; +static S32 sInitializationCount = 0; namespace LLTrace { @@ -39,19 +39,24 @@ static MasterThreadRecorder* gMasterThreadRecorder = NULL; void init() { - gMasterThreadRecorder = new MasterThreadRecorder(); - sInitialized = true; + if (sInitializationCount++ == 0) + { + gMasterThreadRecorder = new MasterThreadRecorder(); + } } bool isInitialized() { - return sInitialized; + return sInitializationCount > 0; } void cleanup() { - delete gMasterThreadRecorder; - gMasterThreadRecorder = NULL; + if (--sInitializationCount == 0) + { + delete gMasterThreadRecorder; + gMasterThreadRecorder = NULL; + } } MasterThreadRecorder& getMasterThreadRecorder() diff --git a/indra/llcommon/llwin32headers.h b/indra/llcommon/llwin32headers.h index 9c89b6b280..8534ed6298 100644 --- a/indra/llcommon/llwin32headers.h +++ b/indra/llcommon/llwin32headers.h @@ -28,9 +28,13 @@ #define LL_LLWINDOWS_H #ifdef LL_WINDOWS +#ifndef NOMINMAX +#define NOMINMAX +#endif #undef WIN32_LEAN_AND_MEAN #include <winsock2.h> #include <windows.h> +#undef NOMINMAX #endif #endif diff --git a/indra/llcommon/llwin32headerslean.h b/indra/llcommon/llwin32headerslean.h index d3fb90d4b1..f7e71301a8 100644 --- a/indra/llcommon/llwin32headerslean.h +++ b/indra/llcommon/llwin32headerslean.h @@ -28,9 +28,13 @@ #define LL_LLWINDOWS_H #ifdef LL_WINDOWS +#ifndef NOMINMAX +#define NOMINMAX +#endif #define WIN32_LEAN_AND_MEAN #include <winsock2.h> #include <windows.h> +#undef NOMINMAX #endif #endif |