Author: tschoening
Date: Tue Oct 13 05:30:19 2015
New Revision: 1708287
URL: http://svn.apache.org/viewvc?rev=1708287&view=rev
Log:
LOGCXX-322: I applied some changes to address the issue that multi threaded
apps using log4cxx may crash on application exit. To reduce the risk of
unwanted side effects, they all depend on APR supporting threads, because in
such a case it's most likely that the problems occur. Regarding the bug,
there's no fast and easy solution, so I'll just leak resources, which shouldn't
harm much on app exit. Without that, to many users need to patch the lib on
their own...
Modified:
incubator/log4cxx/trunk/src/main/cpp/aprinitializer.cpp
incubator/log4cxx/trunk/src/main/cpp/mutex.cpp
Modified: incubator/log4cxx/trunk/src/main/cpp/aprinitializer.cpp
URL:
http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/cpp/aprinitializer.cpp?rev=1708287&r1=1708286&r2=1708287&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/main/cpp/aprinitializer.cpp (original)
+++ incubator/log4cxx/trunk/src/main/cpp/aprinitializer.cpp Tue Oct 13 05:30:19
2015
@@ -65,7 +65,11 @@ APRInitializer::~APRInitializer() {
delete *iter;
}
}
- apr_terminate();
+
+// LOGCXX-322
+#ifndef APR_HAS_THREADS
+ apr_terminate();
+#endif
isDestructed = true;
}
Modified: incubator/log4cxx/trunk/src/main/cpp/mutex.cpp
URL:
http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/cpp/mutex.cpp?rev=1708287&r1=1708286&r2=1708287&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/main/cpp/mutex.cpp (original)
+++ incubator/log4cxx/trunk/src/main/cpp/mutex.cpp Tue Oct 13 05:30:19 2015
@@ -53,7 +53,13 @@ Mutex::Mutex(apr_pool_t* p) {
Mutex::~Mutex() {
#if APR_HAS_THREADS
- apr_thread_mutex_destroy(mutex);
+ // LOGCXX-322
+ if (APRInitializer::isDestructed)
+ {
+ return;
+ }
+
+ apr_thread_mutex_destroy(mutex);
#endif
}