This is an automated email from the ASF dual-hosted git repository.
swebb2066 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/logging-log4cxx.git
The following commit(s) were added to refs/heads/master by this push:
new 04fce885 Watch for configuration files changes after
LogManager::shutdown (#613)
04fce885 is described below
commit 04fce885199e29c62d5a5babe5cabca3f68b42bd
Author: Stephen Webb <[email protected]>
AuthorDate: Wed Mar 25 11:41:45 2026 +1100
Watch for configuration files changes after LogManager::shutdown (#613)
---
src/main/cpp/threadutility.cpp | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/src/main/cpp/threadutility.cpp b/src/main/cpp/threadutility.cpp
index b9dec099..70476af5 100644
--- a/src/main/cpp/threadutility.cpp
+++ b/src/main/cpp/threadutility.cpp
@@ -82,6 +82,7 @@ struct ThreadUtility::priv_data
bool terminated{ false };
int retryCount{ 2 };
Period maxDelay{ 0 };
+ bool threadIsActive{ false };
void doPeriodicTasks();
@@ -270,9 +271,15 @@ void ThreadUtility::addPeriodicTask(const LogString& name,
std::function<void()>
m_priv->maxDelay = delay;
auto currentTime = std::chrono::system_clock::now();
m_priv->jobs.push_back( priv_data::NamedPeriodicFunction{name, delay,
currentTime + delay, f, 0, false} );
+
+ // Restart thread if it has stopped.
+ if (!m_priv->threadIsActive && m_priv->thread.joinable())
+ m_priv->thread.join();
+
if (!m_priv->thread.joinable())
{
m_priv->terminated = false;
+ m_priv->threadIsActive = true;
m_priv->thread = createThread(LOG4CXX_STR("log4cxx"),
std::bind(&priv_data::doPeriodicTasks, m_priv.get()));
}
else
@@ -399,6 +406,7 @@ void ThreadUtility::priv_data::doPeriodicTasks()
std::unique_lock<std::mutex> lock(this->interrupt_mutex);
this->interrupt.wait_until(lock, nextOperationTime);
}
+ this->threadIsActive = false;
}
} //namespace helpers