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.
This commit is contained in:
Ludovic LIEVRE 2020-01-15 21:38:51 +00:00
parent 42629d1ed4
commit b651764007
2 changed files with 5 additions and 5 deletions

View File

@ -107,7 +107,7 @@
//#define POCO_NO_INOTIFY //#define POCO_NO_INOTIFY
// Define to force the use of PollingDirectoryWatcher // Define to force the use of PollingDirectoryWatcher
#define POCO_DW_FORCE_POLLING // #define POCO_DW_FORCE_POLLING
// Following are options to remove certain features // Following are options to remove certain features

View File

@ -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 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 class BSDDirectoryWatcherStrategy: public DirectoryWatcherStrategy
@ -570,11 +570,11 @@ void DirectoryWatcher::init()
if (!_directory.isDirectory()) if (!_directory.isDirectory())
throw Poco::InvalidArgumentException("not a directory", _directory.path()); 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); _pStrategy = new WindowsDirectoryWatcherStrategy(*this);
#elif (POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID) && !defined(POCO_DW_FORCE_POLLING) #elif (POCO_OS == POCO_OS_LINUX || POCO_OS == POCO_OS_ANDROID) && !defined(POCO_DW_FORCE_POLLING)
_pStrategy = new LinuxDirectoryWatcherStrategy(*this); _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); _pStrategy = new BSDDirectoryWatcherStrategy(*this);
#else #else
_pStrategy = new PollingDirectoryWatcherStrategy(*this); _pStrategy = new PollingDirectoryWatcherStrategy(*this);