diff options
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/Ice/Instance.cpp | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/cpp/src/Ice/Instance.cpp b/cpp/src/Ice/Instance.cpp index 75894b607bf..19372b51a64 100644 --- a/cpp/src/Ice/Instance.cpp +++ b/cpp/src/Ice/Instance.cpp @@ -507,6 +507,9 @@ IceInternal::Instance::destroy() _outgoingConnectionFactory->destroy(); _outgoingConnectionFactory->waitUntilFinished(); + ThreadPoolPtr serverThreadPool; + ThreadPoolPtr clientThreadPool; + { IceUtil::RecMutex::Lock sync(*this); @@ -516,15 +519,13 @@ IceInternal::Instance::destroy() if(_serverThreadPool) { _serverThreadPool->destroy(); - _serverThreadPool->joinWithAllThreads(); - _serverThreadPool = 0; + std::swap(_serverThreadPool, serverThreadPool); } if(_clientThreadPool) { _clientThreadPool->destroy(); - _clientThreadPool->joinWithAllThreads(); - _clientThreadPool = 0; + std::swap(_clientThreadPool, clientThreadPool); } _servantFactoryManager->destroy(); @@ -558,4 +559,16 @@ IceInternal::Instance::destroy() _destroyed = true; } + + // + // Join with the thread pool threads outside the synchronization. + // + if(clientThreadPool) + { + clientThreadPool->joinWithAllThreads(); + } + if(serverThreadPool) + { + serverThreadPool->joinWithAllThreads(); + } } |