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

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

* fix(TCPServer): first attempt to silence TSAN #4892

* fix(TCPServer): check stopped status after poll; add TCPServerFactory::stop() and allow factory to return nullptr on connection creation request #4892

* fix(TCPServer): initialize factory stopped flag #4892

* revert(SocketImpl): atomic sock fd
This commit is contained in:
Aleksandar Fabijanic
2025-03-12 16:15:19 -05:00
committed by GitHub
parent 91244ac9d9
commit eb94de03a6
5 changed files with 74 additions and 21 deletions

View File

@@ -112,10 +112,12 @@ void TCPServerDispatcher::run()
if (pCNf)
{
std::unique_ptr<TCPServerConnection> pConnection(_pConnectionFactory->createConnection(pCNf->socket()));
poco_check_ptr(pConnection.get());
beginConnection();
pConnection->start();
endConnection();
if (pConnection)
{
beginConnection();
pConnection->start();
endConnection();
}
}
}
}
@@ -173,6 +175,7 @@ void TCPServerDispatcher::enqueue(const StreamSocket& socket)
void TCPServerDispatcher::stop()
{
FastMutex::ScopedLock lock(_mutex);
_pConnectionFactory->stop();
_stopped = true;
_queue.clear();
for (int i = 0; i < _threadPool.allocated(); i++)