Skip to content

Commit

Permalink
Revert "The FileWatchDog thread no longer uses APR threads"
Browse files Browse the repository at this point in the history
This reverts commit 5a934e8.
  • Loading branch information
stephen-webb committed Nov 20, 2023
1 parent a73b876 commit c5c13ac
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/main/cpp/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,9 @@ bool Class::registerClass(const Class& newClass)

void Class::registerClasses()
{
#if APR_HAS_THREADS
AsyncAppender::registerClass();
#endif
ConsoleAppender::registerClass();
FileAppender::registerClass();
LOG4CXX_NS::db::ODBCAppender::registerClass();
Expand Down
22 changes: 22 additions & 0 deletions src/main/cpp/domconfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ struct DOMConfigurator::DOMConfiguratorPrivate
spi::LoggerFactoryPtr loggerFactory;
};

#if APR_HAS_THREADS
namespace LOG4CXX_NS
{
namespace xml
Expand All @@ -89,6 +90,7 @@ class XMLWatchdog : public FileWatchdog
}
}
XMLWatchdog* DOMConfigurator::xdog = NULL;
#endif


IMPLEMENT_LOG4CXX_OBJECT(DOMConfigurator)
Expand Down Expand Up @@ -909,6 +911,8 @@ spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const CFStringRef& f
spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const std::string& filename, long delay)
{
File file(filename);
#if APR_HAS_THREADS

if ( xdog )
{
APRInitializer::unregisterCleanup(xdog);
Expand All @@ -923,12 +927,17 @@ spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const std::string& f
xdog->start();

return status;
#else
return DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
#endif
}

#if LOG4CXX_WCHAR_T_API
spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const std::wstring& filename, long delay)
{
File file(filename);
#if APR_HAS_THREADS

if ( xdog )
{
APRInitializer::unregisterCleanup(xdog);
Expand All @@ -943,13 +952,18 @@ spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const std::wstring&
xdog->start();

return status;
#else
return DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
#endif
}
#endif

#if LOG4CXX_UNICHAR_API || LOG4CXX_LOGCHAR_IS_UNICHAR
spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const std::basic_string<UniChar>& filename, long delay)
{
File file(filename);
#if APR_HAS_THREADS

if ( xdog )
{
APRInitializer::unregisterCleanup(xdog);
Expand All @@ -964,13 +978,18 @@ spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const std::basic_str
xdog->start();

return status;
#else
return DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
#endif
}
#endif

#if LOG4CXX_CFSTRING_API
spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const CFStringRef& filename, long delay)
{
File file(filename);
#if APR_HAS_THREADS

if ( xdog )
{
APRInitializer::unregisterCleanup(xdog);
Expand All @@ -985,6 +1004,9 @@ spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const CFStringRef& f
xdog->start();

return status;
#else
return DOMConfigurator().doConfigure(file, LogManager::getLoggerRepository());
#endif
}
#endif

Expand Down
6 changes: 5 additions & 1 deletion src/main/cpp/optionconverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@
#define LOG4CXX 1
#endif
#include <log4cxx/helpers/aprinitializer.h>
#include <log4cxx/helpers/filewatchdog.h>

#if APR_HAS_THREADS
#include <log4cxx/helpers/filewatchdog.h>
namespace LOG4CXX_NS
{

Expand All @@ -69,6 +70,7 @@ class ConfiguratorWatchdog : public helpers::FileWatchdog
};

}
#endif

using namespace LOG4CXX_NS;
using namespace LOG4CXX_NS::helpers;
Expand Down Expand Up @@ -443,6 +445,7 @@ void OptionConverter::selectAndConfigure(const File& configFileName,
configurator = std::make_shared<PropertyConfigurator>();
}

#if APR_HAS_THREADS
if (0 < delay)
{
auto dog = new ConfiguratorWatchdog(configurator, configFileName);
Expand All @@ -451,5 +454,6 @@ void OptionConverter::selectAndConfigure(const File& configFileName,
dog->start();
}
else
#endif
configurator->doConfigure(configFileName, hierarchy);
}
2 changes: 2 additions & 0 deletions src/main/cpp/propertyconfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ spi::ConfigurationStatus PropertyConfigurator::configure(helpers::Properties& pr
return PropertyConfigurator().doConfigure(properties, LogManager::getLoggerRepository());
}

#if APR_HAS_THREADS
spi::ConfigurationStatus PropertyConfigurator::configureAndWatch(const File& configFilename)
{
return configureAndWatch(configFilename, FileWatchdog::DEFAULT_DELAY);
Expand All @@ -160,6 +161,7 @@ spi::ConfigurationStatus PropertyConfigurator::configureAndWatch(

return stat;
}
#endif

spi::ConfigurationStatus PropertyConfigurator::doConfigure(helpers::Properties& properties,
spi::LoggerRepositoryPtr hierarchy)
Expand Down

0 comments on commit c5c13ac

Please sign in to comment.