From b651764007b5676bfabad7f6d01495caa148a450 Mon Sep 17 00:00:00 2001 From: Ludovic LIEVRE Date: Wed, 15 Jan 2020 21:38:51 +0000 Subject: [PATCH] Option to force PollingDirectoryWatcherStrategy Add an option to force the use of PollingDirectoryWatcherStrategy Should work on any platform (Not Linux only) See previous PR on this topic : https://github.com/pocoproject/poco/pull/2881 On Linux, inotfy does not work for network volumes (such as NFS). See https://stackoverflow.com/questions/4231243/inotify-with-nfs By adding flag POCO_DW_FORCE_POLLING in Foundation/Config.h, the use of PollingDirectoryWatcherStrategy is forced. This is not the same behavior as flag POCO_NO_INOTIFY. This only disables compilation of DirectoryWatcher. --- Foundation/include/Poco/Config.h | 2 +- Foundation/src/DirectoryWatcher.cpp | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Foundation/include/Poco/Config.h b/Foundation/include/Poco/Config.h index 4f46dc3a2..ce57cb3f5 100644 --- a/Foundation/include/Poco/Config.h +++ b/Foundation/include/Poco/Config.h @@ -107,7 +107,7 @@ //#define POCO_NO_INOTIFY // Define to force the use of PollingDirectoryWatcher -#define POCO_DW_FORCE_POLLING +// #define POCO_DW_FORCE_POLLING // Following are options to remove certain features diff --git a/Foundation/src/DirectoryWatcher.cpp b/Foundation/src/DirectoryWatcher.cpp index ab52ad454..58dc9b4b3 100644 --- a/Foundation/src/DirectoryWatcher.cpp +++ b/Foundation/src/DirectoryWatcher.cpp @@ -150,7 +150,7 @@ private: }; -#if POCO_OS == POCO_OS_WINDOWS_NT +#if (POCO_OS == POCO_OS_WINDOWS_NT) && !defined(POCO_DW_FORCE_POLLING) class WindowsDirectoryWatcherStrategy: public DirectoryWatcherStrategy @@ -380,7 +380,7 @@ private: }; -#elif POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_FREE_BSD +#elif (POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_FREE_BSD) && !defined(POCO_DW_FORCE_POLLING) class BSDDirectoryWatcherStrategy: public DirectoryWatcherStrategy @@ -570,11 +570,11 @@ void DirectoryWatcher::init() if (!_directory.isDirectory()) throw Poco::InvalidArgumentException("not a directory", _directory.path()); -#if POCO_OS == POCO_OS_WINDOWS_NT +#if (POCO_OS == POCO_OS_WINDOWS_NT) && !defined(POCO_DW_FORCE_POLLING) _pStrategy = new WindowsDirectoryWatcherStrategy(*this); #elif (POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID) && !defined(POCO_DW_FORCE_POLLING) _pStrategy = new LinuxDirectoryWatcherStrategy(*this); -#elif POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_FREE_BSD +#elif (POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_FREE_BSD) && !defined(POCO_DW_FORCE_POLLING) _pStrategy = new BSDDirectoryWatcherStrategy(*this); #else _pStrategy = new PollingDirectoryWatcherStrategy(*this);