porting rev. 1994 from 1.4.4

This commit is contained in:
Aleksandar Fabijanic 2012-09-08 02:54:42 +00:00
parent 889f420a0b
commit 3f23af80c3
3 changed files with 104 additions and 103 deletions

View File

@ -46,6 +46,7 @@ Release 1.4.4p1 (2012-??-??)
- fixed SF# 3558012 Compilation fails when building with -ansi or -std=c++0x - fixed SF# 3558012 Compilation fails when building with -ansi or -std=c++0x
- fixed SF# 3563517 Get rid of loss-of-precision warnings on x64 MacOS - fixed SF# 3563517 Get rid of loss-of-precision warnings on x64 MacOS
- fixed SF#3562244: Portability fix for AF_LINK - fixed SF#3562244: Portability fix for AF_LINK
- fixed SF #3562400: DatagramSocketImpl'comment is faile
Release 1.4.4 (2012-09-03) Release 1.4.4 (2012-09-03)

View File

@ -48,10 +48,10 @@
#include <sys/inotify.h> #include <sys/inotify.h>
#include <sys/select.h> #include <sys/select.h>
#include <unistd.h> #include <unistd.h>
#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
#include <fcntl.h> #include <fcntl.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/event.h> #include <sys/event.h>
#include <sys/time.h> #include <sys/time.h>
#endif #endif
#include <algorithm> #include <algorithm>
@ -396,101 +396,101 @@ 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
class BSDDirectoryWatcherStrategy: public DirectoryWatcherStrategy class BSDDirectoryWatcherStrategy: public DirectoryWatcherStrategy
{ {
public: public:
BSDDirectoryWatcherStrategy(DirectoryWatcher& owner): BSDDirectoryWatcherStrategy(DirectoryWatcher& owner):
DirectoryWatcherStrategy(owner), DirectoryWatcherStrategy(owner),
_queueFD(-1), _queueFD(-1),
_dirFD(-1), _dirFD(-1),
_stopped(false) _stopped(false)
{ {
_dirFD = open(owner.directory().path().c_str(), O_EVTONLY); _dirFD = open(owner.directory().path().c_str(), O_EVTONLY);
if (_dirFD < 0) throw Poco::FileNotFoundException(owner.directory().path()); if (_dirFD < 0) throw Poco::FileNotFoundException(owner.directory().path());
_queueFD = kqueue(); _queueFD = kqueue();
if (_queueFD < 0) if (_queueFD < 0)
{ {
close(_dirFD); close(_dirFD);
throw Poco::SystemException("Cannot create kqueue", errno); throw Poco::SystemException("Cannot create kqueue", errno);
} }
} }
~BSDDirectoryWatcherStrategy() ~BSDDirectoryWatcherStrategy()
{ {
close(_dirFD); close(_dirFD);
close(_queueFD); close(_queueFD);
} }
void run() void run()
{ {
Poco::Timestamp lastScan; Poco::Timestamp lastScan;
ItemInfoMap entries; ItemInfoMap entries;
scan(entries); scan(entries);
while (!_stopped) while (!_stopped)
{ {
struct timespec timeout; struct timespec timeout;
timeout.tv_sec = 0; timeout.tv_sec = 0;
timeout.tv_nsec = 200000000; timeout.tv_nsec = 200000000;
unsigned eventFilter = NOTE_WRITE; unsigned eventFilter = NOTE_WRITE;
struct kevent event; struct kevent event;
struct kevent eventData; struct kevent eventData;
EV_SET(&event, _dirFD, EVFILT_VNODE, EV_ADD | EV_CLEAR, eventFilter, 0, 0); EV_SET(&event, _dirFD, EVFILT_VNODE, EV_ADD | EV_CLEAR, eventFilter, 0, 0);
int nEvents = kevent(_queueFD, &event, 1, &eventData, 1, &timeout); int nEvents = kevent(_queueFD, &event, 1, &eventData, 1, &timeout);
if (nEvents < 0 || eventData.flags == EV_ERROR) if (nEvents < 0 || eventData.flags == EV_ERROR)
{ {
try try
{ {
FileImpl::handleLastErrorImpl(owner().directory().path()); FileImpl::handleLastErrorImpl(owner().directory().path());
} }
catch (Poco::Exception& exc) catch (Poco::Exception& exc)
{ {
owner().scanError(&owner(), exc); owner().scanError(&owner(), exc);
} }
} }
else if (nEvents > 0 || ((owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED) && lastScan.isElapsed(owner().scanInterval()*1000000))) else if (nEvents > 0 || ((owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED) && lastScan.isElapsed(owner().scanInterval()*1000000)))
{ {
ItemInfoMap newEntries; ItemInfoMap newEntries;
scan(newEntries); scan(newEntries);
compare(entries, newEntries); compare(entries, newEntries);
std::swap(entries, newEntries); std::swap(entries, newEntries);
lastScan.update(); lastScan.update();
} }
} }
} }
void stop() void stop()
{ {
_stopped = true; _stopped = true;
} }
bool supportsMoveEvents() const bool supportsMoveEvents() const
{ {
return false; return false;
} }
private: private:
int _queueFD; int _queueFD;
int _dirFD; int _dirFD;
bool _stopped; bool _stopped;
}; };
#else #else
class DefaultDirectoryWatcherStrategy: public DirectoryWatcherStrategy class PollingDirectoryWatcherStrategy: public DirectoryWatcherStrategy
{ {
public: public:
DefaultDirectoryWatcherStrategy(DirectoryWatcher& owner): PollingDirectoryWatcherStrategy(DirectoryWatcher& owner):
DirectoryWatcherStrategy(owner) DirectoryWatcherStrategy(owner)
{ {
} }
~DefaultDirectoryWatcherStrategy() ~PollingDirectoryWatcherStrategy()
{ {
} }
@ -583,10 +583,10 @@ void DirectoryWatcher::init()
_pStrategy = new WindowsDirectoryWatcherStrategy(*this); _pStrategy = new WindowsDirectoryWatcherStrategy(*this);
#elif POCO_OS == POCO_OS_LINUX #elif POCO_OS == POCO_OS_LINUX
_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
_pStrategy = new BSDDirectoryWatcherStrategy(*this); _pStrategy = new BSDDirectoryWatcherStrategy(*this);
#else #else
_pStrategy = new DefaultDirectoryWatcherStrategy(*this); _pStrategy = new PollingDirectoryWatcherStrategy(*this);
#endif #endif
_thread.start(*this); _thread.start(*this);
} }

View File

@ -433,36 +433,36 @@ void FileImpl::handleLastErrorImpl(const std::string& path)
switch (errno) switch (errno)
{ {
case EIO: case EIO:
throw IOException(path); throw IOException(path, errno);
case EPERM: case EPERM:
throw FileAccessDeniedException("insufficient permissions", path); throw FileAccessDeniedException("insufficient permissions", path, errno);
case EACCES: case EACCES:
throw FileAccessDeniedException(path); throw FileAccessDeniedException(path, errno);
case ENOENT: case ENOENT:
throw FileNotFoundException(path); throw FileNotFoundException(path, errno);
case ENOTDIR: case ENOTDIR:
throw OpenFileException("not a directory", path); throw OpenFileException("not a directory", path, errno);
case EISDIR: case EISDIR:
throw OpenFileException("not a file", path); throw OpenFileException("not a file", path, errno);
case EROFS: case EROFS:
throw FileReadOnlyException(path); throw FileReadOnlyException(path, errno);
case EEXIST: case EEXIST:
throw FileExistsException(path); throw FileExistsException(path, errno);
case ENOSPC: case ENOSPC:
throw FileException("no space left on device", path); throw FileException("no space left on device", path, errno);
case EDQUOT: case EDQUOT:
throw FileException("disk quota exceeded", path); throw FileException("disk quota exceeded", path, errno);
#if !defined(_AIX) #if !defined(_AIX)
case ENOTEMPTY: case ENOTEMPTY:
throw FileException("directory not empty", path); throw FileException("directory not empty", path, errno);
#endif #endif
case ENAMETOOLONG: case ENAMETOOLONG:
throw PathSyntaxException(path); throw PathSyntaxException(path, errno);
case ENFILE: case ENFILE:
case EMFILE: case EMFILE:
throw FileException("too many open files", path); throw FileException("too many open files", path, errno);
default: default:
throw FileException(std::strerror(errno), path); throw FileException(std::strerror(errno), path, errno);
} }
} }