diff options
author | Marc Laukien <marc@zeroc.com> | 2003-11-20 14:01:59 +0000 |
---|---|---|
committer | Marc Laukien <marc@zeroc.com> | 2003-11-20 14:01:59 +0000 |
commit | ccef487b84e474ccafa9cc1ad0043ea55b080c9a (patch) | |
tree | 8a5c25023fbd5d781e3599004b53f7504f93d06e /cpp/src/Ice/ObjectAdapterI.cpp | |
parent | Fixed problem with GC singleton that happened if a communicator was (diff) | |
download | ice-ccef487b84e474ccafa9cc1ad0043ea55b080c9a.tar.bz2 ice-ccef487b84e474ccafa9cc1ad0043ea55b080c9a.tar.xz ice-ccef487b84e474ccafa9cc1ad0043ea55b080c9a.zip |
OA deadlock fix
Diffstat (limited to 'cpp/src/Ice/ObjectAdapterI.cpp')
-rw-r--r-- | cpp/src/Ice/ObjectAdapterI.cpp | 84 |
1 files changed, 48 insertions, 36 deletions
diff --git a/cpp/src/Ice/ObjectAdapterI.cpp b/cpp/src/Ice/ObjectAdapterI.cpp index afa026ff9aa..0e9da65ff94 100644 --- a/cpp/src/Ice/ObjectAdapterI.cpp +++ b/cpp/src/Ice/ObjectAdapterI.cpp @@ -63,54 +63,66 @@ Ice::ObjectAdapterI::getCommunicator() void Ice::ObjectAdapterI::activate() { - IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + LocatorRegistryPrx locatorRegistry; - checkForDeactivation(); - - if(!_printAdapterReadyDone) - { - if(_locatorInfo && !_id.empty()) + { + IceUtil::Monitor<IceUtil::RecMutex>::Lock sync(*this); + + checkForDeactivation(); + + if(!_printAdapterReadyDone) { - Identity ident; - ident.name = "dummy"; - - // - // TODO: This might throw if we can't connect to the - // locator. Shall we raise a special exception for the - // activate operation instead of a non obvious network - // exception? - // - try + if(_locatorInfo && !_id.empty()) { - _locatorInfo->getLocatorRegistry()->setAdapterDirectProxy(_id, newDirectProxy(ident)); + locatorRegistry = _locatorInfo->getLocatorRegistry(); } - catch(const Ice::AdapterNotFoundException&) - { - NotRegisteredException ex(__FILE__, __LINE__); - ex.kindOfObject = "object adapter"; - ex.id = _id; - throw ex; - } - catch(const Ice::AdapterAlreadyActiveException&) + } + + for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(), + Ice::voidMemFun(&IncomingConnectionFactory::activate)); + + if(!_printAdapterReadyDone) + { + if(_instance->properties()->getPropertyAsInt("Ice.PrintAdapterReady") > 0) { - ObjectAdapterIdInUseException ex(__FILE__, __LINE__); - ex.id = _id; - throw ex; + cout << _name << " ready" << endl; } + + _printAdapterReadyDone = true; } } - for_each(_incomingConnectionFactories.begin(), _incomingConnectionFactories.end(), - Ice::voidMemFun(&IncomingConnectionFactory::activate)); - - if(!_printAdapterReadyDone) + // + // We must call on the locator registry outside the thread + // synchronization, to avoid deadlocks. + // + if(locatorRegistry) { - if(_instance->properties()->getPropertyAsInt("Ice.PrintAdapterReady") > 0) + // + // TODO: This might throw if we can't connect to the + // locator. Shall we raise a special exception for the + // activate operation instead of a non obvious network + // exception? + // + try { - cout << _name << " ready" << endl; + Identity ident; + ident.name = "dummy"; + locatorRegistry->setAdapterDirectProxy(_id, newDirectProxy(ident)); + } + catch(const Ice::AdapterNotFoundException&) + { + NotRegisteredException ex(__FILE__, __LINE__); + ex.kindOfObject = "object adapter"; + ex.id = _id; + throw ex; + } + catch(const Ice::AdapterAlreadyActiveException&) + { + ObjectAdapterIdInUseException ex(__FILE__, __LINE__); + ex.id = _id; + throw ex; } - - _printAdapterReadyDone = true; } } |