File tree Expand file tree Collapse file tree 1 file changed +5
-1
lines changed
Expand file tree Collapse file tree 1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ void TCPServerDispatcher::release()
9292
9393void TCPServerDispatcher::run ()
9494{
95- AutoPtr<TCPServerDispatcher> guard (this , true ); // ensure object stays alive
95+ AutoPtr<TCPServerDispatcher> guard (this , false ); // ensure _rc is decreased when function exits
9696
9797 int idleTime = (int ) _pParams->getThreadIdleTime ().totalMilliseconds ();
9898
@@ -144,6 +144,10 @@ void TCPServerDispatcher::enqueue(const StreamSocket& socket)
144144 {
145145 _threadPool.startWithPriority (_pParams->getThreadPriority (), *this , threadName);
146146 ++_currentThreads;
147+ // Ensure this object lives at least until run() starts
148+ // Small chance of leaking if threadpool is stopped before this
149+ // work runs, but better than a dangling pointer and crash!
150+ duplicate ();
147151 }
148152 catch (Poco::Exception&)
149153 {
You can’t perform that action at this time.
0 commit comments