Skip to content

Commit

Permalink
The FileWatchDog thread no longer uses APR threads
Browse files Browse the repository at this point in the history
  • Loading branch information
stephen-webb committed Nov 19, 2023
1 parent 65789cf commit 5a934e8
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 31 deletions.
2 changes: 0 additions & 2 deletions src/main/cpp/class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,7 @@ 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: 0 additions & 22 deletions src/main/cpp/domconfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ struct DOMConfigurator::DOMConfiguratorPrivate
spi::LoggerFactoryPtr loggerFactory;
};

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


IMPLEMENT_LOG4CXX_OBJECT(DOMConfigurator)
Expand Down Expand Up @@ -911,8 +909,6 @@ 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 @@ -927,17 +923,12 @@ 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 @@ -952,18 +943,13 @@ 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 @@ -978,18 +964,13 @@ 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 @@ -1004,9 +985,6 @@ spi::ConfigurationStatus DOMConfigurator::configureAndWatch(const CFStringRef& f
xdog->start();

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

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

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

namespace LOG4CXX_NS
{

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

}
#endif

using namespace LOG4CXX_NS;
using namespace LOG4CXX_NS::helpers;
Expand Down Expand Up @@ -445,7 +443,6 @@ 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 @@ -454,6 +451,5 @@ void OptionConverter::selectAndConfigure(const File& configFileName,
dog->start();
}
else
#endif
configurator->doConfigure(configFileName, hierarchy);
}
2 changes: 0 additions & 2 deletions src/main/cpp/propertyconfigurator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@ 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 @@ -161,7 +160,6 @@ spi::ConfigurationStatus PropertyConfigurator::configureAndWatch(

return stat;
}
#endif

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

0 comments on commit 5a934e8

Please sign in to comment.