summaryrefslogtreecommitdiff
path: root/cpp/src
diff options
context:
space:
mode:
Diffstat (limited to 'cpp/src')
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp48
1 files changed, 33 insertions, 15 deletions
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 769a33e907b..c9382303b0e 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -189,25 +189,43 @@ Ice::ObjectAdapterI::waitForHold()
void
Ice::ObjectAdapterI::deactivate()
{
- IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+ vector<IncomingConnectionFactoryPtr> incomingConnectionFactories;
+ OutgoingConnectionFactoryPtr outgoingConnectionFactory;
+
+ {
+ IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
+
+ //
+ // Ignore deactivation requests if the object adapter has already
+ // been deactivated.
+ //
+ if(_deactivated)
+ {
+ return;
+ }
+
+ incomingConnectionFactories = _incomingConnectionFactories;
+ outgoingConnectionFactory = _instance->outgoingConnectionFactory();
+ _deactivated = true;
+
+ notifyAll();
+ }
+
//
- // Ignore deactivation requests if the object adapter has already
- // been deactivated.
+ // Must be called outside the thread synchronization, because
+ // Connection::destroy() might block when sending a CloseConnection
+ // message.
//
- if(_deactivated)
- {
- return;
- }
-
- for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
+ for_each(incomingConnectionFactories.begin(), incomingConnectionFactories.end(),
Ice::voidMemFun(&IncomingConnectionFactory::destroy));
- _instance->outgoingConnectionFactory()->removeAdapter(this);
-
- _deactivated = true;
-
- notifyAll();
+ //
+ // Must be called outside the thread synchronization, because
+ // changing the object adapter might block if there are still
+ // requests being dispatched.
+ //
+ outgoingConnectionFactory->removeAdapter(this);
}
void
@@ -559,7 +577,7 @@ Ice::ObjectAdapterI::getIncomingConnections() const
void
Ice::ObjectAdapterI::flushBatchRequests()
{
- std::vector<IceInternal::IncomingConnectionFactoryPtr> f;
+ vector<IncomingConnectionFactoryPtr> f;
{
IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this);
f = _incomingConnectionFactories;