Author: tschoening
Date: Sun Sep 7 13:56:58 2014
New Revision: 1623014
URL: http://svn.apache.org/r1623014
Log:
LOGCXX-430: My patch didn't work, against my expactations I seem to have
introduced "static initialization order fiasco", which the former
implementation didn't suffer from. So I changed the problem of not beeing
thread safe with another one and I was surely only lucky in my former runs of
the testsuite to succeed. Currently they don't, so I'll revert my changes and
reopen the issue again.
Modified:
incubator/log4cxx/trunk/src/changes/changes.xml
incubator/log4cxx/trunk/src/main/cpp/logmanager.cpp
incubator/log4cxx/trunk/src/main/include/log4cxx/logmanager.h
Modified: incubator/log4cxx/trunk/src/changes/changes.xml
URL:
http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/changes/changes.xml?rev=1623014&r1=1623013&r2=1623014&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/changes/changes.xml (original)
+++ incubator/log4cxx/trunk/src/changes/changes.xml Sun Sep 7 13:56:58 2014
@@ -87,7 +87,6 @@
<action issue="LOGCXX-423" type="fix">Repair autogen
script warnings</action>
<action issue="LOGCXX-424" type="fix">liblog4cxx.pc.in
should reflect dependency on apr-1, apr-1-util</action>
<action issue="LOGCXX-425" type="fix">exceptions in
CachedDateFormatTestCase after LOGCXX-420</action>
- <action issue="LOGCXX-430"
type="fix">LogManager::getRootLogger is not thread-safe</action>
<action type="change">Behavior of
StringHelper::startsWith and endsWith synced</action>
<action type="change">Documented C (class) and M
(method) log format keywords.</action>
Modified: incubator/log4cxx/trunk/src/main/cpp/logmanager.cpp
URL:
http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/cpp/logmanager.cpp?rev=1623014&r1=1623013&r2=1623014&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/main/cpp/logmanager.cpp (original)
+++ incubator/log4cxx/trunk/src/main/cpp/logmanager.cpp Sun Sep 7 13:56:58 2014
@@ -49,19 +49,15 @@ using namespace log4cxx::helpers;
IMPLEMENT_LOG4CXX_OBJECT(DefaultRepositorySelector)
void * LogManager::guard = 0;
-spi::RepositorySelectorPtr
LogManager::repoSelector(LogManager::getDefaultRepositorySelector());
-RepositorySelectorPtr LogManager::getDefaultRepositorySelector() {
+RepositorySelectorPtr& LogManager::getRepositorySelector() {
//
// call to initialize APR and trigger "start" of logging clock
//
APRInitializer::initialize();
-
- LoggerRepositoryPtr hierarchy(new Hierarchy());
- RepositorySelectorPtr selector(new DefaultRepositorySelector(hierarchy));
-
+ static spi::RepositorySelectorPtr selector;
return selector;
}
@@ -79,14 +75,21 @@ void LogManager::setRepositorySelector(s
}
LogManager::guard = guard1;
- LogManager::repoSelector = selector;
+ LogManager::getRepositorySelector() = selector;
}
LoggerRepositoryPtr& LogManager::getLoggerRepository()
{
- return LogManager::repoSelector->getLoggerRepository();
+ if (getRepositorySelector() == 0)
+ {
+ LoggerRepositoryPtr hierarchy(new Hierarchy());
+ RepositorySelectorPtr selector(new
DefaultRepositorySelector(hierarchy));
+ getRepositorySelector() = selector;
+ }
+
+ return getRepositorySelector()->getLoggerRepository();
}
LoggerPtr LogManager::getRootLogger()
Modified: incubator/log4cxx/trunk/src/main/include/log4cxx/logmanager.h
URL:
http://svn.apache.org/viewvc/incubator/log4cxx/trunk/src/main/include/log4cxx/logmanager.h?rev=1623014&r1=1623013&r2=1623014&view=diff
==============================================================================
--- incubator/log4cxx/trunk/src/main/include/log4cxx/logmanager.h (original)
+++ incubator/log4cxx/trunk/src/main/include/log4cxx/logmanager.h Sun Sep 7
13:56:58 2014
@@ -40,8 +40,8 @@ namespace log4cxx
/**
* Use the <code>LogManager</code> class to retreive Logger
- * instances or to operate on the current
- * {@link log4cxx::spi::LoggerRepository LoggerRepository}.
+ * instances or to operate on the current
+ * {@link log4cxx::spi::LoggerRepository LoggerRepository}.
* When the <code>LogManager</code> class is loaded
* into memory the default initialization procedure is inititated.
*/
@@ -49,8 +49,7 @@ namespace log4cxx
{
private:
static void * guard;
- static spi::RepositorySelectorPtr repoSelector;
- static spi::RepositorySelectorPtr getDefaultRepositorySelector();
+ static spi::RepositorySelectorPtr& getRepositorySelector();
public:
/**