Browse Source

porting rev.1998 from 1.4.4 (except ODBC, which will be done later, and SQLite, which was ported in rev.1999)

Aleksandar Fabijanic 13 years ago
parent
commit
a221b14522

+ 4 - 3
CHANGELOG

@@ -1,7 +1,7 @@
 This is the changelog file for the POCO C++ Libraries.
 
 
-Release 1.5.0 (2012-08-??)
+Release 1.5.0 (2012-09-??)
 ==========================
 
 - added JSON
@@ -34,7 +34,7 @@ Release 1.5.0 (2012-08-??)
 - added SF#3544720: AbstractConfigurator to support 64bit values
 - fixed SF#3522081: WinRegistryConfiguration unable to read REG_QWORD values
 
-Release 1.4.4 (2012-08-??)
+Release 1.4.4 (2012-09-03)
 ==========================
 
 - ZipStream now builds correctly in unbundled build.
@@ -105,7 +105,8 @@ Release 1.4.4 (2012-08-??)
 - fixed SF# 3559665: Poco::InflatingInputStream may not always inflate completely
 - added Poco::DirectoryWatcher class
 - fixed SF# 3561464: Poco::File::isDevice() can throw due to sharing violation
-
+- Poco::Zip::Compress::addRecursive() has a second variant that allows to specify the compression method.
+- Upgraded internal SQLite to 3.7.14
 
 Release 1.4.3p1 (2012-01-23)
 ============================

+ 1 - 2
Foundation/include/Poco/AtomicCounter.h

@@ -53,9 +53,8 @@
 	#if !defined(POCO_HAVE_GCC_ATOMICS) && !defined(POCO_NO_GCC_ATOMICS)
 		#define POCO_HAVE_GCC_ATOMICS
 	#endif
-#else
-	#include "Poco/Mutex.h"
 #endif // POCO_OS
+#include "Poco/Mutex.h"
 
 
 namespace Poco {

+ 5 - 3
Foundation/include/Poco/DirectoryWatcher.h

@@ -72,10 +72,12 @@ class Foundation_API DirectoryWatcher: protected Runnable
 	///
 	/// On Windows, this class is implemented using FindFirstChangeNotification()/FindNextChangeNotification().
 	/// On Linux, this class is implemented using inotify.
+	/// On FreeBSD and Darwin (Mac OS X, iOS), this class uses kevent/kqueue.
 	/// On all other platforms, the watched directory is periodically scanned
 	/// for changes. This can negatively affect performance if done too often.
 	/// Therefore, the interval in which scans are done can be specified in
-	/// the constructor.
+	/// the constructor. Note that periodic scanning will also be done on FreeBSD
+	/// and Darwin if events for changes to files (DW_ITEM_MODIFIED) are enabled.
 	///
 	/// DW_ITEM_MOVED_FROM and DW_ITEM_MOVED_TO events will only be reported
 	/// on Linux. On other platforms, a file rename or move operation
@@ -150,7 +152,7 @@ public:
 	DirectoryWatcher(const std::string& path, int eventMask = DW_FILTER_ENABLE_ALL, int scanInterval = DW_DEFAULT_SCAN_INTERVAL);
 		/// Creates a DirectoryWatcher for the directory given in path.
 		/// To enable only specific events, an eventMask can be specified by
-		/// OR-ing the desired event IDs (e.g., DW_FILE_ADDED | DW_FILE_MODIFIED).
+		/// OR-ing the desired event IDs (e.g., DW_ITEM_ADDED | DW_ITEM_MODIFIED).
 		/// On platforms where no native filesystem notifications are available,
 		/// scanInterval specifies the interval in seconds between scans
 		/// of the directory.
@@ -158,7 +160,7 @@ public:
 	DirectoryWatcher(const File& directory, int eventMask = DW_FILTER_ENABLE_ALL, int scanInterval = DW_DEFAULT_SCAN_INTERVAL);
 		/// Creates a DirectoryWatcher for the specified directory
 		/// To enable only specific events, an eventMask can be specified by
-		/// OR-ing the desired event IDs (e.g., DW_FILE_ADDED | DW_FILE_MODIFIED).
+		/// OR-ing the desired event IDs (e.g., DW_ITEM_ADDED | DW_ITEM_MODIFIED).
 		/// On platforms where no native filesystem notifications are available,
 		/// scanInterval specifies the interval in seconds between scans
 		/// of the directory.

+ 1 - 0
Foundation/include/Poco/File_UNIX.h

@@ -85,6 +85,7 @@ private:
 	
 	friend class DirectoryIteratorImpl;
 	friend class LinuxDirectoryWatcherStrategy;
+	friend class BSDDirectoryWatcherStrategy;
 };
 
 

+ 94 - 4
Foundation/src/DirectoryWatcher.cpp

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

+ 17 - 2
Foundation/src/Process_UNIX.cpp

@@ -129,18 +129,33 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
 		fdmap[1] = outPipe ? outPipe->writeHandle() : 1;
 		fdmap[2] = errPipe ? errPipe->writeHandle() : 2;
 	
-		char* envPtr = 0;
+		char** envPtr = 0;
 		std::vector<char> envChars;
+		std::vector<char*> envPtrs;
 		if (!env.empty())
 		{
 			envChars = getEnvironmentVariablesBuffer(env);
-			envPtr = &environmentChars[0];
+			envPtrs.reserve(env.size() + 1);
+			char* p = &envChars[0];
+			while (*p)
+			{
+				envPtrs.push_back(p);
+				while (*p) ++p;
+				++p;
+			}
+			envPtrs.push_back(0);
+			envPtr = &envPtrs[0];
 		}
 	
 		int pid = spawn(command.c_str(), 3, fdmap, &inherit, argv, envPtr);
 		delete [] argv;
 		if (pid == -1) 
 			throw SystemException("cannot spawn", command);
+
+		if (inPipe)  inPipe->close(Pipe::CLOSE_READ);
+		if (outPipe) outPipe->close(Pipe::CLOSE_WRITE);
+		if (errPipe) errPipe->close(Pipe::CLOSE_WRITE);
+		return new ProcessHandleImpl(pid);
 	}
 	else
 	{

+ 1 - 0
Foundation/testsuite/src/TaskManagerTest.cpp

@@ -290,6 +290,7 @@ void TaskManagerTest::testFinish()
 	pTT->cont();
 	while (pTT->state() != Task::TASK_FINISHED) Thread::sleep(50);
 	assert (pTT->state() == Task::TASK_FINISHED);
+	while (!to.finished()) Thread::sleep(50);
 	assert (to.finished());
 	while (tm.count() == 1) Thread::sleep(50);
 	list = tm.taskList();

+ 1 - 1
Net/include/Poco/Net/WebSocketImpl.h

@@ -66,7 +66,7 @@ public:
 	virtual SocketImpl* acceptConnection(SocketAddress& clientAddr);
 	virtual void connect(const SocketAddress& address);
 	virtual void connect(const SocketAddress& address, const Poco::Timespan& timeout);
-	virtual void connectNB(const SocketAddress& address, const Poco::Timespan& timeout);
+	virtual void connectNB(const SocketAddress& address);
 	virtual void bind(const SocketAddress& address, bool reuseAddress = false);
 	virtual void bind6(const SocketAddress& address, bool reuseAddress = false, bool ipV6Only = false);
 	virtual void listen(int backlog = 64);

+ 1 - 1
Net/src/HTTPServerResponseImpl.cpp

@@ -90,7 +90,7 @@ std::ostream& HTTPServerResponseImpl::send()
 {
 	poco_assert (!_pStream);
 
-	if (_pRequest && _pRequest->getMethod() == HTTPRequest::HTTP_HEAD ||
+	if ((_pRequest && _pRequest->getMethod() == HTTPRequest::HTTP_HEAD) ||
 		getStatus() < 200 ||
 		getStatus() == HTTPResponse::HTTP_NO_CONTENT ||
 		getStatus() == HTTPResponse::HTTP_NOT_MODIFIED)

+ 1 - 1
Net/src/WebSocketImpl.cpp

@@ -222,7 +222,7 @@ void WebSocketImpl::connect(const SocketAddress& address, const Poco::Timespan&
 }
 
 
-void WebSocketImpl::connectNB(const SocketAddress& address, const Poco::Timespan& timeout)
+void WebSocketImpl::connectNB(const SocketAddress& address)
 {
 	throw Poco::InvalidAccessException("Cannot connectNB() a WebSocketImpl");
 }

+ 2 - 2
NetSSL_OpenSSL/testsuite/src/HTTPSClientSessionTest.cpp

@@ -319,7 +319,7 @@ void HTTPSClientSessionTest::testInterop()
 	StreamCopier::copyStream(rs, ostr);
 	std::string str(ostr.str());
 	assert (str == "This is a test file for NetSSL.\n");
-	assert (cert.commonName() == "secure.appinf.com");
+	assert (cert.commonName() == "secure.appinf.com" || cert.commonName() == "*.appinf.com");
 }
 
 
@@ -340,7 +340,7 @@ void HTTPSClientSessionTest::testProxy()
 	StreamCopier::copyStream(rs, ostr);
 	std::string str(ostr.str());
 	assert (str == "This is a test file for NetSSL.\n");
-	assert (cert.commonName() == "secure.appinf.com");
+	assert (cert.commonName() == "secure.appinf.com" || cert.commonName() == "*.appinf.com");
 }
 
 

+ 4 - 0
Zip/include/Poco/Zip/Compress.h

@@ -76,6 +76,10 @@ public:
 		/// Adds a directory entry recursively to the zip file, set excludeRoot to false to exclude the parent directory.
 		/// If excludeRoot is true you can specify an empty name to add the files as relative files
 
+	void addRecursive(const Poco::Path& entry, ZipCommon::CompressionMethod cm, ZipCommon::CompressionLevel cl = ZipCommon::CL_MAXIMUM, bool excludeRoot = true, const Poco::Path& name = Poco::Path());
+		/// Adds a directory entry recursively to the zip file, set excludeRoot to false to exclude the parent directory.
+		/// If excludeRoot is true you can specify an empty name to add the files as relative files
+
 	void setZipComment(const std::string& comment);
 		/// Sets the Zip file comment.
 

+ 8 - 2
Zip/src/Compress.cpp

@@ -227,6 +227,12 @@ void Compress::addDirectory(const Poco::Path& entryName, const Poco::DateTime& l
 
 
 void Compress::addRecursive(const Poco::Path& entry, ZipCommon::CompressionLevel cl, bool excludeRoot, const Poco::Path& name)
+{
+	addRecursive(entry, ZipCommon::CM_DEFLATE, cl, excludeRoot, name);
+}
+
+
+void Compress::addRecursive(const Poco::Path& entry, ZipCommon::CompressionMethod cm, ZipCommon::CompressionLevel cl, bool excludeRoot, const Poco::Path& name)
 {
 	Poco::File aFile(entry);
 	if (!aFile.isDirectory())
@@ -260,13 +266,13 @@ void Compress::addRecursive(const Poco::Path& entry, ZipCommon::CompressionLevel
 		{
 			realFile.makeDirectory();
 			renamedFile.makeDirectory();
-			addRecursive(realFile, cl, false, renamedFile);
+			addRecursive(realFile, cm, cl, false, renamedFile);
 		}
 		else
 		{
 			realFile.makeFile();
 			renamedFile.makeFile();
-			addFile(realFile, renamedFile, ZipCommon::CM_DEFLATE, cl);
+			addFile(realFile, renamedFile, cm, cl);
 		}
 	}
 }

+ 3 - 3
doc/90100-Acknowledgements.page

@@ -157,7 +157,7 @@ following copyrighted material, the use of which is hereby acknowledged.
 ----    
 
 
-!!!zlib 1.2.3
+!!!zlib 1.2.5
 
     Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler
     
@@ -182,10 +182,10 @@ following copyrighted material, the use of which is hereby acknowledged.
 ----
 
 
-!!!SQlite 3.6.20
+!!!SQlite 3.7.14
 
 The original author of SQLite has dedicated the code to the 
 public domain (http://www.sqlite.org/copyright.html). 
 Anyone is free to copy, modify, publish, use, compile, sell, or distribute the 
 original SQLite code, either in source code form or as a compiled binary, 
-for any purpose, commerical or non-commerical, and by any means.
+for any purpose, commercial or non-commercial, and by any means.

+ 76 - 0
doc/99100-ReleaseNotes.page

@@ -1,6 +1,82 @@
 POCO C++ Libraries Release Notes
 AAAIntroduction
 
+!!!Release 1.4.4
+
+!!Summary of Changes
+
+  - ZipStream now builds correctly in unbundled build.
+  - added proxy digest authentication support to Net library
+  - integrated MySQL BLOB fixes from Franky Braem.
+  - use standard OpenSSL import libraries (libeay32.lib, ssleay32.lib) for Crypto and 
+    NetSSL_OpenSSL Visual Studio project files.
+  - fixed a potential buffer corruption issue in Poco::Net::SecureStreamSocket if lazy 
+    handshake is enabled and the first attempt to complete the handshake fails
+  - Poco::DateTimeParser::tryParse() without format specifier now correctly parses ISO8601 
+    date/times with fractional seconds.
+  - Poco::Process::launch() now has additional overloads allowing to specify an initial 
+    directory and/or environment.
+  - Poco::Net::FTPClientSession: timeout was not applied to data connection, only to 
+    control connection.
+  - Fixed potential IPv6 issue with socket constructors if IPv6 SocketAddress is given 
+    (contributed by ??????? ????????? <[email protected]>).
+  - Added an additional (optional) parameter to Poco::Thread::setOSPriority() allowing to 
+    specify a scheduling policy. Currently this is only used on POSIX platforms and allows 
+    specifying SCHED_OTHER (default), SCHED_FIFO or SCHED_RR, as well as other 
+    platform-specific policy values.
+  - Added Poco::Crypto::DigestEngine class providing a Poco::DigestEngine interface to
+    the digest algorithms provided by OpenSSL.
+  - Fixed some potential compiler warnings in Crypto library
+  - In some cases, when an SSL exception was unexpectedly closed, a generic Poco::IOException
+    was thrown. This was fixed to throw a SSLConnectionUnexpectedlyClosedException instead.
+  - Added Poco::ObjectPool class template.
+  - Poco::Net::HTTPServer has a new stopAll() method allowing stopping/aborting of all 
+    currently active client connections.
+  - The HTTP server framework now actively prevents sending a message body in the
+    response to a HEAD request, or in case of a 204 No Content or 304 Not Modified
+    response status.
+  - fixed a DOM parser performance bug (patch by Peter Klotz)
+  - fixed SF# 3559325: Util Windows broken in non-Unicode
+  - updated iOS build configuration to use xcode-select for finding toolchain
+  - Poco::Net::SecureSocketImpl::shutdown() now also shuts down the underlying socket.
+  - fixed SF# 3552597: Crypto  des-ecb error
+  - fixed SF# 3550553: SecureSocketImpl::connect hangs
+  - fixed SF# 3543047: Poco::Timer bug for long startInterval/periodic interval 
+  - fixed SF# 3539695: Thread attributes should be destroyed using the pthread_attr_destroy() 
+  - fixed SF# 3532311: Not able to set socket option on ServerSocket before bind
+    Added Poco::Net::Socket::init(int af) which can be used to explicitely
+    initialize the underlying socket before calling bind(), connect(), etc.
+  - fixed SF# 3521347: Typo in UnWindows.h undef
+  - fixed SF# 3519474: WinRegistryConfiguration bug
+    Also added tests and fixed another potential issue with an empty root path passed to the constructor.
+  - fixed SF# 3516827: wrong return value of WinRegistryKey::exists()
+  - fixed SF# 3515284: RSA publickey format(X.509 SubjectPublicKeyInfo)
+  - fixed SF# 3503267: VxWorks OS prio is not set in standard constructor
+  - fixed SF# 3500438: HTTPResponse failure when reason is empty
+  - fixed SF# 3495656: numberformater, numberparser error in mingw
+  - fixed SF# 3496493: Reference counting broken in TaskManager postNotification
+  - fixed SF# 3483174: LogFile flushing behavior on Windows
+    Flushing is now configurable for FileChannel and SimpleFileChannel
+    using the "flush" property (true or false).
+  - fixed SF# 3479561: Subsequent IPs on a NIC is not enumerated
+  - fixed SF# 3478665: Permission checks in Poco::File not correct for root
+  - fixed SF# 3475050: Threading bug in initializeNetwork() on Windows
+  - fixed SF# 3552680: websocket small frames bug and proposed fix
+  - fixed a WebSocket interop issue with Firefox
+  - added Poco::Net::MessageHeader::hasToken()
+  - Poco::AtomicCounter now uses GCC 4.3 builtin atomics on more platforms
+  - fixed SF# 3555938: NetSSL: socket closed twice
+  - socket exceptions now include OS error code
+  - fixed SF# 3556975: Need to fix Shared Memory for memory map
+  - Poco::Net::SecureSocketImpl::close() now catches exceptions thrown by its call to shutdown().
+  - fixed SF# 3535990: POCO_HAVE_IPv6 without POCO_WIN32_UTF8 conflict
+  - fixed SF# 3559665: Poco::InflatingInputStream may not always inflate completely
+  - added Poco::DirectoryWatcher class
+  - fixed SF# 3561464: Poco::File::isDevice() can throw due to sharing violation
+  - Poco::Zip::Compress::addRecursive() has a second variant that allows to specify the compression method.
+  - Upgraded internal SQLite to 3.7.14
+
+
 !!!Release 1.4.3p1
 
 !!Summary of Changes

+ 2 - 1
doc/99150-GMakeBuildNotes.page

@@ -330,7 +330,8 @@ in your Makefile, e.g.
 
 Independently of which kind of product (library, executable, plugin) is 
 being built, there are always five make targets available:
-
+Note that these targets are only available in project-level Makefiles, not
+the global Makefile.
 
 !clean
 

+ 3 - 23
doc/Acknowledgements.html

@@ -76,26 +76,6 @@ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 SUCH DAMAGE.</pre>
 
 
-<h3>MD2 (RFC 1319) Message-Digest Algorithm</h3>
-
-<pre>Copyright (C) 1990-2, RSA Data Security, Inc. Created 1990. All
-rights reserved.
-
-License to copy and use this software is granted for
-non-commercial Internet Privacy-Enhanced Mail provided that it is
-identified as the "RSA Data Security, Inc. MD2 Message Digest
-Algorithm" in all material mentioning or referencing this software
-or this function.
-
-RSA Data Security, Inc. makes no representations concerning either
-the merchantability of this software or the suitability of this
-software for any particular purpose. It is provided "as is"
-without express or implied warranty of any kind.
-
-These notices must be retained in any copies of any part of this
-documentation and/or software.</pre>
-
-
 <h3>MD4 (RFC 1320) Message-Digest Algorithm</h3>
 
 <pre>Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All
@@ -186,7 +166,7 @@ POSSIBILITY OF SUCH DAMAGE.
 </pre>
 
 
-<h3>zlib 1.2.3</h3>
+<h3>zlib 1.2.5</h3>
 <pre>Copyright (C) 1995-2004 Jean-loup Gailly and Mark Adler
 
 This software is provided 'as-is', without any express or implied
@@ -209,12 +189,12 @@ Jean-loup Gailly [email protected]
 Mark Adler [email protected]</pre>
 
 
-<h3>SQlite 3.6.20</h3>
+<h3>SQlite 3.7.14</h3>
 <p>The original author of SQLite has dedicated the code to the 
 <a href="http://www.sqlite.org/copyright.html">public domain</a>. 
 Anyone is free to copy, modify, publish, use, compile, sell, or distribute the 
 original SQLite code, either in source code form or as a compiled binary, 
-for any purpose, commerical or non-commerical, and by any means.
+for any purpose, commercial or non-commercial, and by any means.
 </p>