Skip to content

Commit

Permalink
pocoproject#2746: Fix race condition on TCPServerDispatcher stop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Lyubimov authored and villytiger committed Dec 24, 2020
1 parent 3fc3e5f commit 688405a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion Net/src/TCPServerDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ class TCPConnectionNotification: public Notification
};


class StopNotification: public Notification {
};


TCPServerDispatcher::TCPServerDispatcher(TCPServerConnectionFactory::Ptr pFactory, Poco::ThreadPool& threadPool, TCPServerParams::Ptr pParams):
_rc(1),
_pParams(pParams),
Expand Down Expand Up @@ -166,9 +170,10 @@ void TCPServerDispatcher::enqueue(const StreamSocket& socket)

void TCPServerDispatcher::stop()
{
FastMutex::ScopedLock lock(_mutex);
_stopped = true;
_queue.clear();
_queue.wakeUpAll();
_queue.enqueueNotification(new StopNotification);
}


Expand Down

0 comments on commit 688405a

Please sign in to comment.