diff options
author | Alan Conway <aconway@apache.org> | 2011-03-21 18:05:38 +0000 |
---|---|---|
committer | Alan Conway <aconway@apache.org> | 2011-03-21 18:05:38 +0000 |
commit | 72c96978336990f59d819bf4b9ce632b4550cd5f (patch) | |
tree | 76af7a3fa40f7e45f5565296b54596f483725afc /cpp/src/qpid/log/Logger.cpp | |
parent | db22714f2217bbf90c5f9ee57f5fb03d5b81377e (diff) | |
download | qpid-python-72c96978336990f59d819bf4b9ce632b4550cd5f.tar.gz |
QPID-3147: Misconfigured tracing/logging can lead to hung threads in logging stack
The hang was caused by re-entrant attempts to initialize the Logger
singleton when an exception was thrown during logger configuration.
The fix is to disable exception logging temporarily while the logger
is constructed.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1083884 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src/qpid/log/Logger.cpp')
-rw-r--r-- | cpp/src/qpid/log/Logger.cpp | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/cpp/src/qpid/log/Logger.cpp b/cpp/src/qpid/log/Logger.cpp index 2217cdddbd..2339a62114 100644 --- a/cpp/src/qpid/log/Logger.cpp +++ b/cpp/src/qpid/log/Logger.cpp @@ -22,6 +22,7 @@ #include "qpid/memory.h" #include "qpid/sys/Thread.h" #include "qpid/sys/Time.h" +#include "qpid/DisableExceptionLogging.h" #include <boost/pool/detail/singleton.hpp> #include <boost/bind.hpp> #include <boost/function.hpp> @@ -48,11 +49,16 @@ Logger& Logger::instance() { } Logger::Logger() : flags(0) { + // Disable automatic logging in Exception constructors to avoid + // re-entrant use of logger singleton if there is an error in + // option parsing. + DisableExceptionLogging del; + // Initialize myself from env variables so all programs // (e.g. tests) can use logging even if they don't parse // command line args. Options opts(""); - opts.parse(0, 0); + opts.parse(0, 0); configure(opts); } @@ -73,7 +79,7 @@ void Logger::log(const Statement& s, const std::string& msg) { std::ostringstream os; if (!prefix.empty()) os << prefix << ": "; - if (flags&TIME) + if (flags&TIME) qpid::sys::outputFormattedNow(os); if (flags&LEVEL) os << LevelTraits::name(s.level) << " "; @@ -140,7 +146,7 @@ void Logger::configure(const Options& opts) { Options o(opts); if (o.trace) o.selectors.push_back("trace+"); - format(o); + format(o); select(Selector(o)); setPrefix(opts.prefix); options.sinkOptions->setup(this); |