TCPServerDispatcher: fix thread accounting leak (#1801)

* TCPServerDispatcher::run: catch errors in connection creation and handling to prevent threads from exiting without accounting for them
This commit is contained in:
Matt Tucker 2017-07-10 13:37:11 -07:00 committed by Aleksandar Fabijanic
parent 6c13f5d14c
commit 4da941f869

View File

@ -18,6 +18,7 @@
#include "Poco/Net/TCPServerConnectionFactory.h"
#include "Poco/Notification.h"
#include "Poco/AutoPtr.h"
#include "Poco/ErrorHandler.h"
#include <memory>
@ -104,6 +105,7 @@ void TCPServerDispatcher::run()
for (;;)
{
try {
AutoPtr<Notification> pNf = _queue.waitDequeueNotification(idleTime);
if (pNf)
{
@ -121,6 +123,19 @@ void TCPServerDispatcher::run()
endConnection();
}
}
}
catch (Poco::Exception &exc)
{
ErrorHandler::handle(exc);
}
catch (std::exception &exc)
{
ErrorHandler::handle(exc);
}
catch (...)
{
ErrorHandler::handle();
}
FastMutex::ScopedLock lock(_mutex);
if (_stopped || (_currentThreads > 1 && _queue.empty()))