This is an automated email from the ASF dual-hosted git repository. swebb2066 pushed a commit to branch reduce_apr_influence2 in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
commit a95efaa483033daa351eefca61f8b9abcb9ec691 Author: Stephen Webb <[email protected]> AuthorDate: Tue Nov 21 18:21:30 2023 +1100 MDC and NDC availablity no longer depend on APR thread support --- src/main/cpp/threadspecificdata.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/cpp/threadspecificdata.cpp b/src/main/cpp/threadspecificdata.cpp index 8ae1ec54..4e1d3672 100644 --- a/src/main/cpp/threadspecificdata.cpp +++ b/src/main/cpp/threadspecificdata.cpp @@ -60,13 +60,16 @@ ThreadSpecificData& ThreadSpecificData::getDataNoThreads() ThreadSpecificData* ThreadSpecificData::getCurrentData() { -#if APR_HAS_THREADS void* pData = NULL; +#if APR_HAS_THREADS apr_threadkey_private_get(&pData, APRInitializer::getTlsKey()); - return (ThreadSpecificData*) pData; +#elif LOG4CXX_HAS_THREAD_LOCAL + thread_local ThreadSpecificData data; + pData = &data; #else - return &getDataNoThreads(); + pData = &getDataNoThreads(); #endif + return (ThreadSpecificData*) pData; } void ThreadSpecificData::recycle() @@ -167,6 +170,8 @@ ThreadSpecificData* ThreadSpecificData::createCurrentData() } return newData; +#elif LOG4CXX_HAS_THREAD_LOCAL + return getCurrentData(); #else return 0; #endif
