fix(TCPServer): continues to accept connections after stop() #4892

This commit is contained in:
Alex Fabijanic 2025-03-11 15:36:19 +01:00
parent 91244ac9d9
commit ed65f839d9

View File

@ -116,6 +116,7 @@ void TCPServer::stop()
{
if (!_stopped)
{
_socket.close();
_stopped = true;
_thread.join();
_pDispatcher->stop();
@ -150,24 +151,30 @@ void TCPServer::run()
}
catch (Poco::Exception& exc)
{
ErrorHandler::handle(exc);
if (!_stopped)
ErrorHandler::handle(exc);
}
catch (std::exception& exc)
{
ErrorHandler::handle(exc);
if (!_stopped)
ErrorHandler::handle(exc);
}
catch (...)
{
ErrorHandler::handle();
if (!_stopped)
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);
if (!_stopped)
{
ErrorHandler::handle(exc);
// possibly a resource issue since poll() failed;
// give some time to recover before trying again
Poco::Thread::sleep(50);
}
}
}
}