Skip to content

Commit a221b14

Browse files
committed
porting rev.1998 from 1.4.4 (except ODBC, which will be done later, and SQLite, which was ported in rev.1999)
1 parent 86bafbb commit a221b14

17 files changed

Lines changed: 224 additions & 48 deletions

CHANGELOG

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
This is the changelog file for the POCO C++ Libraries.
22

33

4-
Release 1.5.0 (2012-08-??)
4+
Release 1.5.0 (2012-09-??)
55
==========================
66

77
- added JSON
@@ -34,7 +34,7 @@ Release 1.5.0 (2012-08-??)
3434
- added SF#3544720: AbstractConfigurator to support 64bit values
3535
- fixed SF#3522081: WinRegistryConfiguration unable to read REG_QWORD values
3636

37-
Release 1.4.4 (2012-08-??)
37+
Release 1.4.4 (2012-09-03)
3838
==========================
3939

4040
- ZipStream now builds correctly in unbundled build.
@@ -105,7 +105,8 @@ Release 1.4.4 (2012-08-??)
105105
- fixed SF# 3559665: Poco::InflatingInputStream may not always inflate completely
106106
- added Poco::DirectoryWatcher class
107107
- fixed SF# 3561464: Poco::File::isDevice() can throw due to sharing violation
108-
108+
- Poco::Zip::Compress::addRecursive() has a second variant that allows to specify the compression method.
109+
- Upgraded internal SQLite to 3.7.14
109110

110111
Release 1.4.3p1 (2012-01-23)
111112
============================

Foundation/include/Poco/AtomicCounter.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,8 @@
5353
#if !defined(POCO_HAVE_GCC_ATOMICS) && !defined(POCO_NO_GCC_ATOMICS)
5454
#define POCO_HAVE_GCC_ATOMICS
5555
#endif
56-
#else
57-
#include "Poco/Mutex.h"
5856
#endif // POCO_OS
57+
#include "Poco/Mutex.h"
5958

6059

6160
namespace Poco {

Foundation/include/Poco/DirectoryWatcher.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ class Foundation_API DirectoryWatcher: protected Runnable
7272
///
7373
/// On Windows, this class is implemented using FindFirstChangeNotification()/FindNextChangeNotification().
7474
/// On Linux, this class is implemented using inotify.
75+
/// On FreeBSD and Darwin (Mac OS X, iOS), this class uses kevent/kqueue.
7576
/// On all other platforms, the watched directory is periodically scanned
7677
/// for changes. This can negatively affect performance if done too often.
7778
/// Therefore, the interval in which scans are done can be specified in
78-
/// the constructor.
79+
/// the constructor. Note that periodic scanning will also be done on FreeBSD
80+
/// and Darwin if events for changes to files (DW_ITEM_MODIFIED) are enabled.
7981
///
8082
/// DW_ITEM_MOVED_FROM and DW_ITEM_MOVED_TO events will only be reported
8183
/// on Linux. On other platforms, a file rename or move operation
@@ -150,15 +152,15 @@ class Foundation_API DirectoryWatcher: protected Runnable
150152
DirectoryWatcher(const std::string& path, int eventMask = DW_FILTER_ENABLE_ALL, int scanInterval = DW_DEFAULT_SCAN_INTERVAL);
151153
/// Creates a DirectoryWatcher for the directory given in path.
152154
/// To enable only specific events, an eventMask can be specified by
153-
/// OR-ing the desired event IDs (e.g., DW_FILE_ADDED | DW_FILE_MODIFIED).
155+
/// OR-ing the desired event IDs (e.g., DW_ITEM_ADDED | DW_ITEM_MODIFIED).
154156
/// On platforms where no native filesystem notifications are available,
155157
/// scanInterval specifies the interval in seconds between scans
156158
/// of the directory.
157159

158160
DirectoryWatcher(const File& directory, int eventMask = DW_FILTER_ENABLE_ALL, int scanInterval = DW_DEFAULT_SCAN_INTERVAL);
159161
/// Creates a DirectoryWatcher for the specified directory
160162
/// To enable only specific events, an eventMask can be specified by
161-
/// OR-ing the desired event IDs (e.g., DW_FILE_ADDED | DW_FILE_MODIFIED).
163+
/// OR-ing the desired event IDs (e.g., DW_ITEM_ADDED | DW_ITEM_MODIFIED).
162164
/// On platforms where no native filesystem notifications are available,
163165
/// scanInterval specifies the interval in seconds between scans
164166
/// of the directory.

Foundation/include/Poco/File_UNIX.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ class FileImpl
8585

8686
friend class DirectoryIteratorImpl;
8787
friend class LinuxDirectoryWatcherStrategy;
88+
friend class BSDDirectoryWatcherStrategy;
8889
};
8990

9091

Foundation/src/DirectoryWatcher.cpp

Lines changed: 94 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,17 @@
4242
#include "Poco/Exception.h"
4343
#include "Poco/Buffer.h"
4444
#if defined(POCO_WIN32_UTF8)
45-
#include "Poco/UnicodeConverter.h"
45+
#include "Poco/UnicodeConverter.h"
4646
#endif
4747
#if POCO_OS == POCO_OS_LINUX
48-
#include <sys/inotify.h>
49-
#include <sys/select.h>
50-
#include <unistd.h>
48+
#include <sys/inotify.h>
49+
#include <sys/select.h>
50+
#include <unistd.h>
51+
#elif POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_FREE_BSD
52+
#include <fcntl.h>
53+
#include <sys/types.h>
54+
#include <sys/event.h>
55+
#include <sys/time.h>
5156
#endif
5257
#include <algorithm>
5358
#include <map>
@@ -391,6 +396,89 @@ class LinuxDirectoryWatcherStrategy: public DirectoryWatcherStrategy
391396
};
392397

393398

399+
#elif POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_FREE_BSD
400+
401+
402+
class BSDDirectoryWatcherStrategy: public DirectoryWatcherStrategy
403+
{
404+
public:
405+
BSDDirectoryWatcherStrategy(DirectoryWatcher& owner):
406+
DirectoryWatcherStrategy(owner),
407+
_queueFD(-1),
408+
_dirFD(-1),
409+
_stopped(false)
410+
{
411+
_dirFD = open(owner.directory().path().c_str(), O_EVTONLY);
412+
if (_dirFD < 0) throw Poco::FileNotFoundException(owner.directory().path());
413+
_queueFD = kqueue();
414+
if (_queueFD < 0)
415+
{
416+
close(_dirFD);
417+
throw Poco::SystemException("Cannot create kqueue", errno);
418+
}
419+
}
420+
421+
~BSDDirectoryWatcherStrategy()
422+
{
423+
close(_dirFD);
424+
close(_queueFD);
425+
}
426+
427+
void run()
428+
{
429+
Poco::Timestamp lastScan;
430+
ItemInfoMap entries;
431+
scan(entries);
432+
433+
while (!_stopped)
434+
{
435+
struct timespec timeout;
436+
timeout.tv_sec = 0;
437+
timeout.tv_nsec = 200000000;
438+
unsigned eventFilter = NOTE_WRITE;
439+
struct kevent event;
440+
struct kevent eventData;
441+
EV_SET(&event, _dirFD, EVFILT_VNODE, EV_ADD | EV_CLEAR, eventFilter, 0, 0);
442+
int nEvents = kevent(_queueFD, &event, 1, &eventData, 1, &timeout);
443+
if (nEvents < 0 || eventData.flags == EV_ERROR)
444+
{
445+
try
446+
{
447+
FileImpl::handleLastErrorImpl(owner().directory().path());
448+
}
449+
catch (Poco::Exception& exc)
450+
{
451+
owner().scanError(&owner(), exc);
452+
}
453+
}
454+
else if (nEvents > 0 || ((owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED) && lastScan.isElapsed(owner().scanInterval()*1000000)))
455+
{
456+
ItemInfoMap newEntries;
457+
scan(newEntries);
458+
compare(entries, newEntries);
459+
std::swap(entries, newEntries);
460+
lastScan.update();
461+
}
462+
}
463+
}
464+
465+
void stop()
466+
{
467+
_stopped = true;
468+
}
469+
470+
bool supportsMoveEvents() const
471+
{
472+
return false;
473+
}
474+
475+
private:
476+
int _queueFD;
477+
int _dirFD;
478+
bool _stopped;
479+
};
480+
481+
394482
#else
395483

396484

@@ -495,6 +583,8 @@ void DirectoryWatcher::init()
495583
_pStrategy = new WindowsDirectoryWatcherStrategy(*this);
496584
#elif POCO_OS == POCO_OS_LINUX
497585
_pStrategy = new LinuxDirectoryWatcherStrategy(*this);
586+
#elif POCO_OS == POCO_OS_MAC_OS_X || POCO_OS == POCO_OS_FREE_BSD
587+
_pStrategy = new BSDDirectoryWatcherStrategy(*this);
498588
#else
499589
_pStrategy = new DefaultDirectoryWatcherStrategy(*this);
500590
#endif

Foundation/src/Process_UNIX.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,18 +129,33 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
129129
fdmap[1] = outPipe ? outPipe->writeHandle() : 1;
130130
fdmap[2] = errPipe ? errPipe->writeHandle() : 2;
131131

132-
char* envPtr = 0;
132+
char** envPtr = 0;
133133
std::vector<char> envChars;
134+
std::vector<char*> envPtrs;
134135
if (!env.empty())
135136
{
136137
envChars = getEnvironmentVariablesBuffer(env);
137-
envPtr = &environmentChars[0];
138+
envPtrs.reserve(env.size() + 1);
139+
char* p = &envChars[0];
140+
while (*p)
141+
{
142+
envPtrs.push_back(p);
143+
while (*p) ++p;
144+
++p;
145+
}
146+
envPtrs.push_back(0);
147+
envPtr = &envPtrs[0];
138148
}
139149

140150
int pid = spawn(command.c_str(), 3, fdmap, &inherit, argv, envPtr);
141151
delete [] argv;
142152
if (pid == -1)
143153
throw SystemException("cannot spawn", command);
154+
155+
if (inPipe) inPipe->close(Pipe::CLOSE_READ);
156+
if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
157+
if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
158+
return new ProcessHandleImpl(pid);
144159
}
145160
else
146161
{

Foundation/testsuite/src/TaskManagerTest.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,7 @@ void TaskManagerTest::testFinish()
290290
pTT->cont();
291291
while (pTT->state() != Task::TASK_FINISHED) Thread::sleep(50);
292292
assert (pTT->state() == Task::TASK_FINISHED);
293+
while (!to.finished()) Thread::sleep(50);
293294
assert (to.finished());
294295
while (tm.count() == 1) Thread::sleep(50);
295296
list = tm.taskList();

Net/include/Poco/Net/WebSocketImpl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class Net_API WebSocketImpl: public StreamSocketImpl
6666
virtual SocketImpl* acceptConnection(SocketAddress& clientAddr);
6767
virtual void connect(const SocketAddress& address);
6868
virtual void connect(const SocketAddress& address, const Poco::Timespan& timeout);
69-
virtual void connectNB(const SocketAddress& address, const Poco::Timespan& timeout);
69+
virtual void connectNB(const SocketAddress& address);
7070
virtual void bind(const SocketAddress& address, bool reuseAddress = false);
7171
virtual void bind6(const SocketAddress& address, bool reuseAddress = false, bool ipV6Only = false);
7272
virtual void listen(int backlog = 64);

Net/src/HTTPServerResponseImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ std::ostream& HTTPServerResponseImpl::send()
9090
{
9191
poco_assert (!_pStream);
9292

93-
if (_pRequest && _pRequest->getMethod() == HTTPRequest::HTTP_HEAD ||
93+
if ((_pRequest && _pRequest->getMethod() == HTTPRequest::HTTP_HEAD) ||
9494
getStatus() < 200 ||
9595
getStatus() == HTTPResponse::HTTP_NO_CONTENT ||
9696
getStatus() == HTTPResponse::HTTP_NOT_MODIFIED)

Net/src/WebSocketImpl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ void WebSocketImpl::connect(const SocketAddress& address, const Poco::Timespan&
222222
}
223223

224224

225-
void WebSocketImpl::connectNB(const SocketAddress& address, const Poco::Timespan& timeout)
225+
void WebSocketImpl::connectNB(const SocketAddress& address)
226226
{
227227
throw Poco::InvalidAccessException("Cannot connectNB() a WebSocketImpl");
228228
}

0 commit comments

Comments
 (0)