mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-23 16:48:06 +02:00
prevent TCPServer thread from stopping of poll() throws (due to resource issues)
This commit is contained in:
@@ -115,28 +115,38 @@ void TCPServer::run()
|
|||||||
while (!_stopped)
|
while (!_stopped)
|
||||||
{
|
{
|
||||||
Poco::Timespan timeout(250000);
|
Poco::Timespan timeout(250000);
|
||||||
if (_socket.poll(timeout, Socket::SELECT_READ))
|
try
|
||||||
{
|
{
|
||||||
try
|
if (_socket.poll(timeout, Socket::SELECT_READ))
|
||||||
{
|
{
|
||||||
StreamSocket ss = _socket.acceptConnection();
|
try
|
||||||
// enabe nodelay per default: OSX really needs that
|
{
|
||||||
ss.setNoDelay(true);
|
StreamSocket ss = _socket.acceptConnection();
|
||||||
_pDispatcher->enqueue(ss);
|
// enabe nodelay per default: OSX really needs that
|
||||||
}
|
ss.setNoDelay(true);
|
||||||
catch (Poco::Exception& exc)
|
_pDispatcher->enqueue(ss);
|
||||||
{
|
}
|
||||||
ErrorHandler::handle(exc);
|
catch (Poco::Exception& exc)
|
||||||
}
|
{
|
||||||
catch (std::exception& exc)
|
ErrorHandler::handle(exc);
|
||||||
{
|
}
|
||||||
ErrorHandler::handle(exc);
|
catch (std::exception& exc)
|
||||||
}
|
{
|
||||||
catch (...)
|
ErrorHandler::handle(exc);
|
||||||
{
|
}
|
||||||
ErrorHandler::handle();
|
catch (...)
|
||||||
|
{
|
||||||
|
ErrorHandler::handle();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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();
|
return _pDispatcher->currentThreads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int TCPServer::maxThreads() const
|
int TCPServer::maxThreads() const
|
||||||
{
|
{
|
||||||
return _pDispatcher->maxThreads();
|
return _pDispatcher->maxThreads();
|
||||||
|
Reference in New Issue
Block a user