#538 prevent destructors from throwing exceptions

This commit is contained in:
Guenter Obiltschnig 2014-09-19 09:46:49 +02:00
parent c8686a727d
commit 544229302e
60 changed files with 555 additions and 131 deletions

View File

@ -47,7 +47,14 @@ OpenSSLInitializer::OpenSSLInitializer()
OpenSSLInitializer::~OpenSSLInitializer() OpenSSLInitializer::~OpenSSLInitializer()
{ {
try
{
uninitialize(); uninitialize();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -33,7 +33,14 @@ PooledSessionImpl::PooledSessionImpl(PooledSessionHolder* pHolder):
PooledSessionImpl::~PooledSessionImpl() PooledSessionImpl::~PooledSessionImpl()
{ {
try
{
close(); close();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -75,6 +75,8 @@ RecordSet::RecordSet(const RecordSet& other):
RecordSet::~RecordSet() RecordSet::~RecordSet()
{ {
try
{
delete _pBegin; delete _pBegin;
delete _pEnd; delete _pEnd;
if(_pFilter) _pFilter->release(); if(_pFilter) _pFilter->release();
@ -82,6 +84,11 @@ RecordSet::~RecordSet()
RowMap::iterator it = _rowMap.begin(); RowMap::iterator it = _rowMap.begin();
RowMap::iterator end = _rowMap.end(); RowMap::iterator end = _rowMap.end();
for (; it != end; ++it) delete it->second; for (; it != end; ++it) delete it->second;
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -60,9 +60,16 @@ void RowFilter::init()
RowFilter::~RowFilter() RowFilter::~RowFilter()
{ {
try
{
release(); release();
if (_pRecordSet) _pRecordSet->filter(0); if (_pRecordSet) _pRecordSet->filter(0);
if (_pParent.get()) _pParent->removeFilter(this); if (_pParent.get()) _pParent->removeFilter(this);
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -69,7 +69,14 @@ SQLChannel::SQLChannel(const std::string& connector,
SQLChannel::~SQLChannel() SQLChannel::~SQLChannel()
{ {
try
{
close(); close();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -41,7 +41,14 @@ SessionPool::SessionPool(const std::string& connector, const std::string& connec
SessionPool::~SessionPool() SessionPool::~SessionPool()
{ {
try
{
shutdown(); shutdown();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -40,6 +40,8 @@ Transaction::Transaction(Poco::Data::Session& rSession, bool start):
Transaction::~Transaction() Transaction::~Transaction()
{ {
try
{
if (_rSession.isTransaction()) if (_rSession.isTransaction())
{ {
try try
@ -55,6 +57,11 @@ Transaction::~Transaction()
_pLogger->error("Error while rolling back database transaction."); _pLogger->error("Error while rolling back database transaction.");
} }
} }
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -63,9 +63,16 @@ public:
} }
virtual ~AbstractCache() virtual ~AbstractCache()
{
try
{ {
uninitialize(); uninitialize();
} }
catch (...)
{
poco_unexpected();
}
}
void add(const TKey& key, const TValue& val) void add(const TKey& key, const TValue& val)
/// Adds the key value pair to the cache. /// Adds the key value pair to the cache.

View File

@ -93,10 +93,17 @@ public:
~Activity() ~Activity()
/// Stops and destroys the activity. /// Stops and destroys the activity.
{
try
{ {
stop(); stop();
wait(); wait();
} }
catch (...)
{
poco_unexpected();
}
}
void start() void start()
/// Starts the activity by acquiring a /// Starts the activity by acquiring a

View File

@ -58,7 +58,6 @@ union Placeholder
/// where the object was allocated (0 => heap, 1 => local). /// where the object was allocated (0 => heap, 1 => local).
{ {
public: public:
struct Size struct Size
{ {
static const unsigned int value = SizeV; static const unsigned int value = SizeV;
@ -86,7 +85,7 @@ public:
PlaceholderT* content() const PlaceholderT* content() const
{ {
if(isLocal()) if (isLocal())
return reinterpret_cast<PlaceholderT*>(holder); return reinterpret_cast<PlaceholderT*>(holder);
else else
return pHolder; return pHolder;
@ -192,9 +191,9 @@ public:
/// Destructor. If Any is locally held, calls ValueHolder destructor; /// Destructor. If Any is locally held, calls ValueHolder destructor;
/// otherwise, deletes the placeholder from the heap. /// otherwise, deletes the placeholder from the heap.
{ {
if(!empty()) if (!empty())
{ {
if(_valueHolder.isLocal()) if (_valueHolder.isLocal())
destruct(); destruct();
else else
delete content(); delete content();
@ -341,7 +340,7 @@ private:
void construct(const Any& other) void construct(const Any& other)
{ {
if(!other.empty()) if (!other.empty())
other.content()->clone(&_valueHolder); other.content()->clone(&_valueHolder);
else else
_valueHolder.erase(); _valueHolder.erase();

View File

@ -167,7 +167,7 @@ private:
template <typename T> template <typename T>
class BasicMemoryBinaryWriter : public BinaryWriter class BasicMemoryBinaryWriter: public BinaryWriter
/// A convenient wrapper for using Buffer and MemoryStream with BinarWriter. /// A convenient wrapper for using Buffer and MemoryStream with BinarWriter.
{ {
public: public:
@ -186,9 +186,16 @@ public:
} }
~BasicMemoryBinaryWriter() ~BasicMemoryBinaryWriter()
{
try
{ {
flush(); flush();
} }
catch (...)
{
poco_unexpected();
}
}
Buffer<T>& data() Buffer<T>& data()
{ {

View File

@ -41,7 +41,7 @@ public:
return new char_type[static_cast<std::size_t>(size)]; return new char_type[static_cast<std::size_t>(size)];
} }
static void deallocate(char_type* ptr, std::streamsize /*size*/) static void deallocate(char_type* ptr, std::streamsize /*size*/) throw()
{ {
delete [] ptr; delete [] ptr;
} }

View File

@ -592,7 +592,7 @@ private:
void destruct() void destruct()
{ {
if(!isEmpty()) delete content(); if (!isEmpty()) delete content();
} }
VarHolder* _pHolder; VarHolder* _pHolder;
@ -636,7 +636,7 @@ private:
void construct(const Var& other) void construct(const Var& other)
{ {
if(!other.isEmpty()) if (!other.isEmpty())
other.content()->clone(&_placeholder); other.content()->clone(&_placeholder);
else else
_placeholder.erase(); _placeholder.erase();
@ -644,9 +644,9 @@ private:
void destruct() void destruct()
{ {
if(!isEmpty()) if (!isEmpty())
{ {
if(_placeholder.isLocal()) if (_placeholder.isLocal())
content()->~VarHolder(); content()->~VarHolder();
else else
delete content(); delete content();

View File

@ -151,7 +151,14 @@ inline NDCScope::NDCScope(const std::string& info, int line, const char* filenam
inline NDCScope::~NDCScope() inline NDCScope::~NDCScope()
{ {
try
{
NestedDiagnosticContext::current().pop(); NestedDiagnosticContext::current().pop();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -193,12 +193,19 @@ public:
~ObjectPool() ~ObjectPool()
/// Destroys the ObjectPool. /// Destroys the ObjectPool.
{
try
{ {
for (typename std::vector<P>::iterator it = _pool.begin(); it != _pool.end(); ++it) for (typename std::vector<P>::iterator it = _pool.begin(); it != _pool.end(); ++it)
{ {
_factory.destroyObject(*it); _factory.destroyObject(*it);
} }
} }
catch (...)
{
poco_unexpected();
}
}
P borrowObject() P borrowObject()
/// Obtains an object from the pool, or creates a new object if /// Obtains an object from the pool, or creates a new object if

View File

@ -168,7 +168,14 @@ inline ScopedRWLock::ScopedRWLock(RWLock& rwl, bool write): _rwl(rwl)
inline ScopedRWLock::~ScopedRWLock() inline ScopedRWLock::~ScopedRWLock()
{ {
try
{
_rwl.unlock(); _rwl.unlock();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -42,7 +42,7 @@ public:
void duplicate() const; void duplicate() const;
/// Increments the object's reference count. /// Increments the object's reference count.
void release() const; void release() const throw();
/// Decrements the object's reference count /// Decrements the object's reference count
/// and deletes the object if the count /// and deletes the object if the count
/// reaches zero. /// reaches zero.
@ -77,9 +77,16 @@ inline void RefCountedObject::duplicate() const
} }
inline void RefCountedObject::release() const inline void RefCountedObject::release() const throw()
{ {
try
{
if (--_counter == 0) delete this; if (--_counter == 0) delete this;
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -46,9 +46,16 @@ public:
} }
~ScopedLock() ~ScopedLock()
{
try
{ {
_mutex.unlock(); _mutex.unlock();
} }
catch (...)
{
poco_unexpected();
}
}
private: private:
M& _mutex; M& _mutex;
@ -81,9 +88,16 @@ public:
} }
~ScopedLockWithUnlock() ~ScopedLockWithUnlock()
{
try
{ {
unlock(); unlock();
} }
catch (...)
{
poco_unexpected();
}
}
void unlock() void unlock()
{ {

View File

@ -142,9 +142,16 @@ public:
} }
~SharedPtr() ~SharedPtr()
{
try
{ {
release(); release();
} }
catch (...)
{
poco_unexpected();
}
}
SharedPtr& assign(C* ptr) SharedPtr& assign(C* ptr)
{ {

View File

@ -59,8 +59,15 @@ AsyncChannel::AsyncChannel(Channel* pChannel, Thread::Priority prio):
AsyncChannel::~AsyncChannel() AsyncChannel::~AsyncChannel()
{ {
try
{
close(); close();
if (_pChannel) _pChannel->release(); if (_pChannel) _pChannel->release();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -541,8 +541,15 @@ DirectoryWatcher::DirectoryWatcher(const Poco::File& directory, int eventMask, i
DirectoryWatcher::~DirectoryWatcher() DirectoryWatcher::~DirectoryWatcher()
{ {
try
{
stop(); stop();
delete _pStrategy; delete _pStrategy;
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -81,7 +81,14 @@ EventLogChannel::EventLogChannel(const std::string& name, const std::string& hos
EventLogChannel::~EventLogChannel() EventLogChannel::~EventLogChannel()
{ {
try
{
close(); close();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -71,10 +71,17 @@ FileChannel::FileChannel(const std::string& path):
FileChannel::~FileChannel() FileChannel::~FileChannel()
{ {
try
{
close(); close();
delete _pRotateStrategy; delete _pRotateStrategy;
delete _pArchiveStrategy; delete _pArchiveStrategy;
delete _pPurgeStrategy; delete _pPurgeStrategy;
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -443,9 +443,16 @@ public:
{ {
} }
~AutoLoggerShutdown() ~AutoLoggerShutdown()
{
try
{ {
Logger::shutdown(); Logger::shutdown();
} }
catch (...)
{
poco_unexpected();
}
}
}; };

View File

@ -30,7 +30,14 @@ NotificationQueue::NotificationQueue()
NotificationQueue::~NotificationQueue() NotificationQueue::~NotificationQueue()
{ {
try
{
clear(); clear();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -30,7 +30,14 @@ PriorityNotificationQueue::PriorityNotificationQueue()
PriorityNotificationQueue::~PriorityNotificationQueue() PriorityNotificationQueue::~PriorityNotificationQueue()
{ {
try
{
clear(); clear();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -52,7 +52,14 @@ SimpleFileChannel::SimpleFileChannel(const std::string& path):
SimpleFileChannel::~SimpleFileChannel() SimpleFileChannel::~SimpleFileChannel()
{ {
try
{
close(); close();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -36,6 +36,8 @@ public:
} }
~TempFileCollector() ~TempFileCollector()
{
try
{ {
for (std::set<std::string>::iterator it = _files.begin(); it != _files.end(); ++it) for (std::set<std::string>::iterator it = _files.begin(); it != _files.end(); ++it)
{ {
@ -50,6 +52,11 @@ public:
} }
} }
} }
catch (...)
{
poco_unexpected();
}
}
void registerFile(const std::string& path) void registerFile(const std::string& path)
{ {
@ -81,6 +88,8 @@ TemporaryFile::TemporaryFile(const std::string& tempDir):
TemporaryFile::~TemporaryFile() TemporaryFile::~TemporaryFile()
{ {
try
{
if (!_keep) if (!_keep)
{ {
try try
@ -92,6 +101,11 @@ TemporaryFile::~TemporaryFile()
{ {
} }
} }
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -280,7 +280,14 @@ ThreadPool::ThreadPool(const std::string& name,
ThreadPool::~ThreadPool() ThreadPool::~ThreadPool()
{ {
try
{
stopAll(); stopAll();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -29,7 +29,14 @@ TimedNotificationQueue::TimedNotificationQueue()
TimedNotificationQueue::~TimedNotificationQueue() TimedNotificationQueue::~TimedNotificationQueue()
{ {
try
{
clear(); clear();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -35,7 +35,14 @@ Timer::Timer(long startInterval, long periodicInterval):
Timer::~Timer() Timer::~Timer()
{ {
try
{
stop(); stop();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -85,7 +85,7 @@ const Var Var::operator + (const Var& other) const
{ {
if (isInteger()) if (isInteger())
{ {
if(isSigned()) if (isSigned())
return add<Poco::Int64>(other); return add<Poco::Int64>(other);
else else
return add<Poco::UInt64>(other); return add<Poco::UInt64>(other);
@ -103,7 +103,7 @@ Var& Var::operator += (const Var& other)
{ {
if (isInteger()) if (isInteger())
{ {
if(isSigned()) if (isSigned())
return *this = add<Poco::Int64>(other); return *this = add<Poco::Int64>(other);
else else
return *this = add<Poco::UInt64>(other); return *this = add<Poco::UInt64>(other);
@ -121,7 +121,7 @@ const Var Var::operator - (const Var& other) const
{ {
if (isInteger()) if (isInteger())
{ {
if(isSigned()) if (isSigned())
return subtract<Poco::Int64>(other); return subtract<Poco::Int64>(other);
else else
return subtract<Poco::UInt64>(other); return subtract<Poco::UInt64>(other);
@ -137,7 +137,7 @@ Var& Var::operator -= (const Var& other)
{ {
if (isInteger()) if (isInteger())
{ {
if(isSigned()) if (isSigned())
return *this = subtract<Poco::Int64>(other); return *this = subtract<Poco::Int64>(other);
else else
return *this = subtract<Poco::UInt64>(other); return *this = subtract<Poco::UInt64>(other);
@ -153,7 +153,7 @@ const Var Var::operator * (const Var& other) const
{ {
if (isInteger()) if (isInteger())
{ {
if(isSigned()) if (isSigned())
return multiply<Poco::Int64>(other); return multiply<Poco::Int64>(other);
else else
return multiply<Poco::UInt64>(other); return multiply<Poco::UInt64>(other);
@ -169,7 +169,7 @@ Var& Var::operator *= (const Var& other)
{ {
if (isInteger()) if (isInteger())
{ {
if(isSigned()) if (isSigned())
return *this = multiply<Poco::Int64>(other); return *this = multiply<Poco::Int64>(other);
else else
return *this = multiply<Poco::UInt64>(other); return *this = multiply<Poco::UInt64>(other);
@ -185,7 +185,7 @@ const Var Var::operator / (const Var& other) const
{ {
if (isInteger()) if (isInteger())
{ {
if(isSigned()) if (isSigned())
return divide<Poco::Int64>(other); return divide<Poco::Int64>(other);
else else
return divide<Poco::UInt64>(other); return divide<Poco::UInt64>(other);
@ -201,7 +201,7 @@ Var& Var::operator /= (const Var& other)
{ {
if (isInteger()) if (isInteger())
{ {
if(isSigned()) if (isSigned())
return *this = divide<Poco::Int64>(other); return *this = divide<Poco::Int64>(other);
else else
return *this = divide<Poco::UInt64>(other); return *this = divide<Poco::UInt64>(other);

View File

@ -83,9 +83,16 @@ public:
} }
virtual ~PooledConnection() virtual ~PooledConnection()
{
try
{ {
_pool.returnObject(_connection); _pool.returnObject(_connection);
} }
catch (...)
{
poco_unexpected();
}
}
operator Connection::Ptr () operator Connection::Ptr ()
{ {

View File

@ -86,9 +86,16 @@ public:
virtual ~ParallelSocketAcceptor() virtual ~ParallelSocketAcceptor()
/// Destroys the ParallelSocketAcceptor. /// Destroys the ParallelSocketAcceptor.
{
try
{ {
unregisterAcceptor(); unregisterAcceptor();
} }
catch (...)
{
poco_unexpected();
}
}
virtual void registerAcceptor(SocketReactor& reactor) virtual void registerAcceptor(SocketReactor& reactor)
/// Registers the ParallelSocketAcceptor with a SocketReactor. /// Registers the ParallelSocketAcceptor with a SocketReactor.

View File

@ -87,9 +87,16 @@ public:
virtual ~SocketAcceptor() virtual ~SocketAcceptor()
/// Destroys the SocketAcceptor. /// Destroys the SocketAcceptor.
{
try
{ {
unregisterAcceptor(); unregisterAcceptor();
} }
catch (...)
{
poco_unexpected();
}
}
virtual void registerAcceptor(SocketReactor& reactor) virtual void registerAcceptor(SocketReactor& reactor)
/// Registers the SocketAcceptor with a SocketReactor. /// Registers the SocketAcceptor with a SocketReactor.

View File

@ -91,9 +91,16 @@ public:
virtual ~SocketConnector() virtual ~SocketConnector()
/// Destroys the SocketConnector. /// Destroys the SocketConnector.
{
try
{ {
unregisterConnector(); unregisterConnector();
} }
catch (...)
{
poco_unexpected();
}
}
virtual void registerConnector(SocketReactor& reactor) virtual void registerConnector(SocketReactor& reactor)
/// Registers the SocketConnector with a SocketReactor. /// Registers the SocketConnector with a SocketReactor.

View File

@ -161,7 +161,14 @@ void* HTTPChunkedInputStream::operator new(std::size_t size)
void HTTPChunkedInputStream::operator delete(void* ptr) void HTTPChunkedInputStream::operator delete(void* ptr)
{ {
try
{
_pool.release(ptr); _pool.release(ptr);
}
catch (...)
{
poco_unexpected();
}
} }
@ -193,7 +200,14 @@ void* HTTPChunkedOutputStream::operator new(std::size_t size)
void HTTPChunkedOutputStream::operator delete(void* ptr) void HTTPChunkedOutputStream::operator delete(void* ptr)
{ {
try
{
_pool.release(ptr); _pool.release(ptr);
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -130,7 +130,14 @@ void* HTTPFixedLengthInputStream::operator new(std::size_t size)
void HTTPFixedLengthInputStream::operator delete(void* ptr) void HTTPFixedLengthInputStream::operator delete(void* ptr)
{ {
try
{
_pool.release(ptr); _pool.release(ptr);
}
catch (...)
{
poco_unexpected();
}
} }
@ -162,7 +169,14 @@ void* HTTPFixedLengthOutputStream::operator new(std::size_t size)
void HTTPFixedLengthOutputStream::operator delete(void* ptr) void HTTPFixedLengthOutputStream::operator delete(void* ptr)
{ {
try
{
_pool.release(ptr); _pool.release(ptr);
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -127,7 +127,14 @@ void* HTTPHeaderInputStream::operator new(std::size_t size)
void HTTPHeaderInputStream::operator delete(void* ptr) void HTTPHeaderInputStream::operator delete(void* ptr)
{ {
try
{
_pool.release(ptr); _pool.release(ptr);
}
catch (...)
{
poco_unexpected();
}
} }
@ -159,7 +166,14 @@ void* HTTPHeaderOutputStream::operator new(std::size_t size)
void HTTPHeaderOutputStream::operator delete(void* ptr) void HTTPHeaderOutputStream::operator delete(void* ptr)
{ {
try
{
_pool.release(ptr); _pool.release(ptr);
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -45,7 +45,14 @@ HTTPServerConnection::HTTPServerConnection(const StreamSocket& socket, HTTPServe
HTTPServerConnection::~HTTPServerConnection() HTTPServerConnection::~HTTPServerConnection()
{ {
try
{
_pFactory->serverStopped -= Poco::delegate(this, &HTTPServerConnection::onServerStopped); _pFactory->serverStopped -= Poco::delegate(this, &HTTPServerConnection::onServerStopped);
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -64,6 +64,8 @@ HTTPSession::HTTPSession(const StreamSocket& socket, bool keepAlive):
HTTPSession::~HTTPSession() HTTPSession::~HTTPSession()
{ {
try
{
if (_pBuffer) HTTPBufferAllocator::deallocate(_pBuffer, HTTPBufferAllocator::BUFFER_SIZE); if (_pBuffer) HTTPBufferAllocator::deallocate(_pBuffer, HTTPBufferAllocator::BUFFER_SIZE);
try try
{ {
@ -73,6 +75,11 @@ HTTPSession::~HTTPSession()
{ {
} }
delete _pException; delete _pException;
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -121,7 +121,14 @@ void* HTTPInputStream::operator new(std::size_t size)
void HTTPInputStream::operator delete(void* ptr) void HTTPInputStream::operator delete(void* ptr)
{ {
try
{
_pool.release(ptr); _pool.release(ptr);
}
catch (...)
{
poco_unexpected();
}
} }
@ -153,7 +160,14 @@ void* HTTPOutputStream::operator new(std::size_t size)
void HTTPOutputStream::operator delete(void* ptr) void HTTPOutputStream::operator delete(void* ptr)
{ {
try
{
_pool.release(ptr); _pool.release(ptr);
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -131,7 +131,13 @@ MultipartIOS::MultipartIOS(std::istream& istr, const std::string& boundary):
MultipartIOS::~MultipartIOS() MultipartIOS::~MultipartIOS()
{ {
try
{
_buf.sync(); _buf.sync();
}
catch (...)
{
}
} }

View File

@ -61,9 +61,16 @@ void Net_API uninitializeNetwork()
~NetworkInitializer() ~NetworkInitializer()
/// Calls Poco::Net::uninitializeNetwork(); /// Calls Poco::Net::uninitializeNetwork();
{
try
{ {
Poco::Net::uninitializeNetwork(); Poco::Net::uninitializeNetwork();
} }
catch (...)
{
poco_unexpected();
}
}
}; };
const NetworkInitializer pocoNetworkInitializer; const NetworkInitializer pocoNetworkInitializer;

View File

@ -24,7 +24,10 @@ namespace Poco {
namespace Net { namespace Net {
/// PartStore //
// PartStore
//
PartStore::PartStore(const std::string& mediaType): PartSource(mediaType) PartStore::PartStore(const std::string& mediaType): PartSource(mediaType)
{ {
@ -36,7 +39,10 @@ PartStore::~PartStore()
} }
/// FilePartStore //
// FilePartStore
//
FilePartStore::FilePartStore(const std::string& content, const std::string& mediaType, const std::string& filename): FilePartStore::FilePartStore(const std::string& content, const std::string& mediaType, const std::string& filename):
PartStore(mediaType), PartStore(mediaType),
@ -56,7 +62,7 @@ FilePartStore::~FilePartStore()
_fstr.close(); _fstr.close();
File(_path).remove(); File(_path).remove();
} }
catch (Exception&) catch (...)
{ {
} }
} }

View File

@ -61,7 +61,14 @@ RemoteSyslogChannel::RemoteSyslogChannel(const std::string& address, const std::
RemoteSyslogChannel::~RemoteSyslogChannel() RemoteSyslogChannel::~RemoteSyslogChannel()
{ {
try
{
close(); close();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -69,7 +69,14 @@ SMTPChannel::SMTPChannel(const std::string& mailhost, const std::string& sender,
SMTPChannel::~SMTPChannel() SMTPChannel::~SMTPChannel()
{ {
try
{
close(); close();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -32,6 +32,7 @@
#include <stropts.h> #include <stropts.h>
#endif #endif
using Poco::IOException; using Poco::IOException;
using Poco::TimeoutException; using Poco::TimeoutException;
using Poco::InvalidArgumentException; using Poco::InvalidArgumentException;

View File

@ -72,8 +72,15 @@ TCPServer::TCPServer(TCPServerConnectionFactory::Ptr pFactory, Poco::ThreadPool&
TCPServer::~TCPServer() TCPServer::~TCPServer()
{ {
try
{
stop(); stop();
_pDispatcher->release(); _pDispatcher->release();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -23,7 +23,7 @@
#include "Poco/MemoryStream.h" #include "Poco/MemoryStream.h"
#include "Poco/Format.h" #include "Poco/Format.h"
#include <cstring> #include <cstring>
#include <iostream>
namespace Poco { namespace Poco {
namespace Net { namespace Net {
@ -42,8 +42,15 @@ WebSocketImpl::WebSocketImpl(StreamSocketImpl* pStreamSocketImpl, bool mustMaskP
WebSocketImpl::~WebSocketImpl() WebSocketImpl::~WebSocketImpl()
{ {
try
{
_pStreamSocketImpl->release(); _pStreamSocketImpl->release();
reset(); reset();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -168,9 +168,15 @@ Context::Context(
Context::~Context() Context::~Context()
{ {
try
{
SSL_CTX_free(_pSSLContext); SSL_CTX_free(_pSSLContext);
Poco::Crypto::OpenSSLInitializer::uninitialize(); Poco::Crypto::OpenSSLInitializer::uninitialize();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -37,10 +37,17 @@ InvalidCertificateHandler::InvalidCertificateHandler(bool handleErrorsOnServerSi
InvalidCertificateHandler::~InvalidCertificateHandler() InvalidCertificateHandler::~InvalidCertificateHandler()
{ {
try
{
if (_handleErrorsOnServerSide) if (_handleErrorsOnServerSide)
SSLManager::instance().ServerVerificationError -= Delegate<InvalidCertificateHandler, VerificationErrorArgs>(this, &InvalidCertificateHandler::onInvalidCertificate); SSLManager::instance().ServerVerificationError -= Delegate<InvalidCertificateHandler, VerificationErrorArgs>(this, &InvalidCertificateHandler::onInvalidCertificate);
else else
SSLManager::instance().ClientVerificationError -= Delegate<InvalidCertificateHandler, VerificationErrorArgs>(this, &InvalidCertificateHandler::onInvalidCertificate); SSLManager::instance().ClientVerificationError -= Delegate<InvalidCertificateHandler, VerificationErrorArgs>(this, &InvalidCertificateHandler::onInvalidCertificate);
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -34,7 +34,14 @@ PrivateKeyPassphraseHandler::PrivateKeyPassphraseHandler(bool onServerSide): _se
PrivateKeyPassphraseHandler::~PrivateKeyPassphraseHandler() PrivateKeyPassphraseHandler::~PrivateKeyPassphraseHandler()
{ {
try
{
SSLManager::instance().PrivateKeyPassphraseRequired -= Delegate<PrivateKeyPassphraseHandler, std::string>(this, &PrivateKeyPassphraseHandler::onPrivateKeyRequested); SSLManager::instance().PrivateKeyPassphraseRequired -= Delegate<PrivateKeyPassphraseHandler, std::string>(this, &PrivateKeyPassphraseHandler::onPrivateKeyRequested);
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -69,7 +69,14 @@ SSLManager::SSLManager()
SSLManager::~SSLManager() SSLManager::~SSLManager()
{ {
try
{
shutdown(); shutdown();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -29,7 +29,14 @@ SecureServerSocketImpl::SecureServerSocketImpl(Context::Ptr pContext):
SecureServerSocketImpl::~SecureServerSocketImpl() SecureServerSocketImpl::~SecureServerSocketImpl()
{ {
try
{
reset(); reset();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -41,7 +41,14 @@ SecureStreamSocketImpl::SecureStreamSocketImpl(StreamSocketImpl* pStreamSocket,
SecureStreamSocketImpl::~SecureStreamSocketImpl() SecureStreamSocketImpl::~SecureStreamSocketImpl()
{ {
try
{
reset(); reset();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -46,9 +46,16 @@ public:
} }
~ArchiveImpl() ~ArchiveImpl()
{
try
{ {
close(); close();
} }
catch (...)
{
poco_unexpected();
}
}
const std::string& path() const const std::string& path() const
{ {

View File

@ -232,8 +232,15 @@ Timer::Timer(Poco::Thread::Priority priority)
Timer::~Timer() Timer::~Timer()
{ {
try
{
_queue.enqueueNotification(new StopNotification(_queue), Poco::Clock(0)); _queue.enqueueNotification(new StopNotification(_queue), Poco::Clock(0));
_thread.join(); _thread.join();
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -54,7 +54,14 @@ Decompress::Decompress(std::istream& in, const Poco::Path& outputDir, bool flatt
Decompress::~Decompress() Decompress::~Decompress()
{ {
try
{
EOk -= Poco::Delegate<Decompress, std::pair<const ZipLocalFileHeader, const Poco::Path> >(this, &Decompress::onOk); EOk -= Poco::Delegate<Decompress, std::pair<const ZipLocalFileHeader, const Poco::Path> >(this, &Decompress::onOk);
}
catch (...)
{
poco_unexpected();
}
} }

View File

@ -242,7 +242,14 @@ PartialOutputStream::PartialOutputStream(std::ostream& ostr, std::size_t start,
PartialOutputStream::~PartialOutputStream() PartialOutputStream::~PartialOutputStream()
{ {
try
{
close(); close();
}
catch (...)
{
poco_unexpected();
}
} }