prevent TCPServer thread from stopping of poll() throws (due to resource issues)

This commit is contained in:
Guenter Obiltschnig
2016-03-05 14:40:34 +01:00
parent 15d1d0f1a2
commit 324e04e568

View File

@@ -115,6 +115,8 @@ void TCPServer::run()
while (!_stopped)
{
Poco::Timespan timeout(250000);
try
{
if (_socket.poll(timeout, Socket::SELECT_READ))
{
try
@@ -138,6 +140,14 @@ void TCPServer::run()
}
}
}
catch (Poco::Exception& exc)
{
ErrorHandler::handle(exc);
// possibly a resource issue since poll() failed;
// give some time to recover before trying again
Poco::Thread::sleep(50);
}
}
}
@@ -146,6 +156,7 @@ int TCPServer::currentThreads() const
return _pDispatcher->currentThreads();
}
int TCPServer::maxThreads() const
{
return _pDispatcher->maxThreads();