Commit 0eef3671 authored by Aleksandr Konstantinov's avatar Aleksandr Konstantinov

Merge branch 'bug_3891' into 'master'

Fix a-rex segfaults on Logger code (Fixes BUGZ-3891)

See merge request nordugrid/arc!913
parents 5f430729 9a2625c8
......@@ -240,11 +240,14 @@ namespace Arc {
}
void LogDestination::setPrefix(const std::string& pre) {
Glib::Mutex::Lock lock(mutex);
prefix = pre;
}
std::string LogDestination::getPrefix() const {
return prefix;
Glib::Mutex::Lock lock(mutex);
std::string tmp(prefix);
return tmp;
}
LogStream::LogStream(std::ostream& destination)
......
......@@ -256,6 +256,15 @@ namespace Arc {
friend std::ostream& operator<<(std::ostream& os, const LogDestination& dest);
protected:
/// A mutex for synchronization.
/** This mutex is to be locked before a LogMessage is written and it is
not unlocked until the entire message has been written and the
stream flushed. This is done in order to prevent LogMessages to
appear mixed in the stream and prevent race on modification of
internal members. It is mutable to provide protection while reading members.
*/
mutable Glib::Mutex mutex;
/// Format to use in this LogDestination.
LogFormat format;
......@@ -318,14 +327,6 @@ namespace Arc {
*/
std::ostream& destination;
/// A mutex for synchronization.
/** This mutex is locked before a LogMessage is written and it is
not unlocked until the entire message has been written and the
stream flushed. This is done in order to prevent LogMessages to
appear mixed in the stream.
*/
Glib::Mutex mutex;
};
/// A class for logging to files.
......@@ -410,7 +411,6 @@ namespace Arc {
int maxsize;
int backups;
bool reopen;
Glib::Mutex mutex;
};
class LoggerContextRef;
......
......@@ -114,7 +114,7 @@ namespace DataStaging {
void Scheduler::log_to_root_logger(Arc::LogLevel level, const std::string& message) {
Arc::Logger::getRootLogger().addDestinations(root_destinations);
logger.msg(level, message);
logger.msg(level, "%s", message);
Arc::Logger::getRootLogger().removeDestinations();
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment