Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/main/cpp/aprinitializer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ void APRInitializer::addObject(size_t key, const ObjectPtr& pObject)
m_priv->objects.emplace_back(key, pObject);
}

const ObjectPtr& APRInitializer::findOrAddObject(size_t key, std::function<ObjectPtr()> creator)
const ObjectPtr APRInitializer::findOrAddObject(size_t key, std::function<ObjectPtr()> creator)
{
std::lock_guard<std::mutex> lock(m_priv->mutex);
if (m_priv->objects.empty())
Expand Down
2 changes: 1 addition & 1 deletion src/main/cpp/domconfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ class XMLWatchdog : public FileWatchdog
Call DOMConfigurator#doConfigure with the
<code>filename</code> to reconfigure log4cxx.
*/
void doOnChange()
void doOnChange() override
{
DOMConfigurator().doConfigure(file(),
LogManager::getLoggerRepository());
Expand Down
8 changes: 8 additions & 0 deletions src/main/cpp/filewatchdog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,12 @@ struct FileWatchdog::FileWatchdogPrivate{
bool warnedAlready;
LogString taskName;
ThreadUtility::ManagerWeakPtr taskManager;

/**
Serialize access and modification to: file, lastModif and warnedAlready.
Recursive because doOnChange may re-enter watchdog methods.
*/
std::recursive_mutex mutex;
};

FileWatchdog::FileWatchdog(const File& file1)
Expand Down Expand Up @@ -95,6 +101,7 @@ const File& FileWatchdog::file()

void FileWatchdog::checkAndConfigure()
{
std::lock_guard<std::recursive_mutex> lock(m_priv->mutex);
if (LogLog::isDebugEnabled())
{
LogString msg(LOG4CXX_STR("Checking ["));
Expand Down Expand Up @@ -164,6 +171,7 @@ void FileWatchdog::setDelay(long delay1){

void FileWatchdog::setFile(const File& newValue)
{
std::lock_guard<std::recursive_mutex> lock(m_priv->mutex);
if (m_priv->file.getPath() != newValue.getPath())
{
m_priv->file = newValue;
Expand Down
2 changes: 1 addition & 1 deletion src/main/cpp/propertyconfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class PropertyWatchdog : public FileWatchdog
const spi::LoggerRepositoryPtr& hierarchy) with the
<code>filename</code> to reconfigure log4cxx.
*/
void doOnChange()
void doOnChange() override
{
PropertyConfigurator().doConfigure(file(),
LogManager::getLoggerRepository());
Expand Down
3 changes: 3 additions & 0 deletions src/main/cpp/socketappenderskeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,8 @@ void SocketAppenderSkeleton::SocketAppenderSkeletonPriv::setOutputSink(const Soc
{
OutputStreamPtr os = std::make_shared<SocketOutputStream>(socket);
auto charset = CharsetEncoder::getUTF8Encoder();
// Serialize with AppenderSkeleton::doAppend
std::lock_guard<std::recursive_mutex> lock(this->mutex);
this->outputSink = std::make_shared<OutputStreamWriter>(os, charset);
}

Expand All @@ -244,6 +246,7 @@ void SocketAppenderSkeleton::SocketAppenderSkeletonPriv::close()
;
else if (auto pManager = this->taskManager.lock())
pManager->value().removePeriodicTask(this->taskName);
std::lock_guard<std::recursive_mutex> lock(this->mutex);
if (this->outputSink)
{
try
Expand Down
2 changes: 1 addition & 1 deletion src/main/include/log4cxx/helpers/aprinitializer.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class APRInitializer
APRInitializer& operator=(const APRInitializer&) = delete;
private: // Modifiers
void addObject(size_t key, const ObjectPtr& pObject);
const ObjectPtr& findOrAddObject(size_t key, std::function<ObjectPtr()> creator);
const ObjectPtr findOrAddObject(size_t key, std::function<ObjectPtr()> creator);
private: // Attributes
LOG4CXX_DECLARE_PRIVATE_MEMBER_PTR(APRInitializerPrivate, m_priv)
private: // Class methods
Expand Down
Loading