#2746, #3169: Fix race condition on TCPServerDispatcher stop

This commit is contained in:
Günter Obiltschnig
2021-06-15 15:26:26 +02:00
parent 19b2c5b415
commit 330bc22b30

View File

@@ -50,6 +50,11 @@ private:
}; };
class StopNotification: public Notification
{
};
TCPServerDispatcher::TCPServerDispatcher(TCPServerConnectionFactory::Ptr pFactory, Poco::ThreadPool& threadPool, TCPServerParams::Ptr pParams): TCPServerDispatcher::TCPServerDispatcher(TCPServerConnectionFactory::Ptr pFactory, Poco::ThreadPool& threadPool, TCPServerParams::Ptr pParams):
_rc(1), _rc(1),
_pParams(pParams), _pParams(pParams),
@@ -166,9 +171,10 @@ void TCPServerDispatcher::enqueue(const StreamSocket& socket)
void TCPServerDispatcher::stop() void TCPServerDispatcher::stop()
{ {
FastMutex::ScopedLock lock(_mutex);
_stopped = true; _stopped = true;
_queue.clear(); _queue.clear();
_queue.wakeUpAll(); _queue.enqueueNotification(new StopNotification);
} }