summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/ObjectAdapterI.cpp
diff options
context:
space:
mode:
authorMarc Laukien <marc@zeroc.com>2002-06-03 22:54:17 +0000
committerMarc Laukien <marc@zeroc.com>2002-06-03 22:54:17 +0000
commit7dc43b72395a86d0532be3eb2e5bd8d3244566a1 (patch)
treecb8d6aeabfc2c9be73b94016d9bca239b242a4ea /cpp/src/Ice/ObjectAdapterI.cpp
parentimproving diagnostics (diff)
downloadice-7dc43b72395a86d0532be3eb2e5bd8d3244566a1.tar.bz2
ice-7dc43b72395a86d0532be3eb2e5bd8d3244566a1.tar.xz
ice-7dc43b72395a86d0532be3eb2e5bd8d3244566a1.zip
fixed deadlock
Diffstat (limited to 'cpp/src/Ice/ObjectAdapterI.cpp')
-rw-r--r--cpp/src/Ice/ObjectAdapterI.cpp38
1 files changed, 25 insertions, 13 deletions
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp
index 69fc2d477bb..3f8d806b662 100644
--- a/cpp/src/Ice/ObjectAdapterI.cpp
+++ b/cpp/src/Ice/ObjectAdapterI.cpp
@@ -116,8 +116,11 @@ Ice::ObjectAdapterI::deactivate()
void
Ice::ObjectAdapterI::waitForDeactivate()
{
- IceUtil::Mutex::Lock sync(*this);
-
+ //
+ // _incommingConnectionFactories is immutable, thus no mutex lock
+ // is necessary. (A mutex lock wouldn't work here anyway, as there
+ // would be a deadlock with upcalls.)
+ //
for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(),
Ice::voidMemFun(&IncomingConnectionFactory::waitUntilFinished));
}
@@ -365,17 +368,17 @@ Ice::ObjectAdapterI::addRouter(const RouterPrx& router)
list<ConnectionPtr>
Ice::ObjectAdapterI::getIncomingConnections() const
{
- IceUtil::Mutex::Lock sync(*this);
-
+ //
+ // _incommingConnectionFactories is immutable, thus no mutex lock
+ // is necessary.
+ //
list<ConnectionPtr> connections;
-
vector<IncomingConnectionFactoryPtr>::const_iterator p;
for (p = _incomingConnectionFactories.begin(); p != _incomingConnectionFactories.end(); ++p)
{
list<ConnectionPtr> cons = (*p)->connections();
connections.splice(connections.end(), cons);
}
-
return connections;
}
@@ -513,17 +516,26 @@ Ice::ObjectAdapterI::isLocal(const ObjectPrx& proxy) const
}
//
- // Proxies which have at least one endpoint in common with the
- // router's server proxy endpoints (if any), are also considered
- // local.
+ // Must be synchronized, because _routerEndpoints is not
+ // immutable, and because this operation is called unsynchronized
+ // from ObjectAdapterFactory::findObjectAdapter().
//
- for (p = ref->endpoints.begin(); p != ref->endpoints.end(); ++p)
{
- if (binary_search(_routerEndpoints.begin(), _routerEndpoints.end(), *p)) // _routerEndpoints is sorted.
+ IceUtil::Mutex::Lock sync(*this);
+
+ //
+ // Proxies which have at least one endpoint in common with the
+ // router's server proxy endpoints (if any), are also considered
+ // local.
+ //
+ for (p = ref->endpoints.begin(); p != ref->endpoints.end(); ++p)
{
- return true;
+ if (binary_search(_routerEndpoints.begin(), _routerEndpoints.end(), *p)) // _routerEndpoints is sorted.
+ {
+ return true;
+ }
}
}
-
+
return false;
}