diff options
-rw-r--r-- | TAO/ChangeLog | 9 | ||||
-rw-r--r-- | TAO/tao/PortableServer/Root_POA.cpp | 87 | ||||
-rw-r--r-- | TAO/tao/PortableServer/Root_POA.h | 7 |
3 files changed, 53 insertions, 50 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 1933a1f1641..d1b1da7882b 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,12 @@ +Tue Oct 30 10:50:49 UTC 2012 Johnny Willemsen <jwillemsen@remedy.nl> + + * tao/PortableServer/Root_POA.h: + * tao/PortableServer/Root_POA.cpp: + Cache ORT_Adapter_Factory in the POA at creation, prevents + a lookup when (un)registering a servant which could trigger + a possible deadlock when the registering of the servant is + coming from the init of an ACE service + Fri Oct 19 07:56:56 UTC 2012 Johnny Willemsen <jwillemsen@remedy.nl> * tao/AnyTypeCode/Alias_TypeCode.cpp: diff --git a/TAO/tao/PortableServer/Root_POA.cpp b/TAO/tao/PortableServer/Root_POA.cpp index df3e11a6a96..425c915a208 100644 --- a/TAO/tao/PortableServer/Root_POA.cpp +++ b/TAO/tao/PortableServer/Root_POA.cpp @@ -199,6 +199,7 @@ TAO_Root_POA::TAO_Root_POA (const TAO_Root_POA::String &name, profile_id_array_ (0), policies_ (policies), ort_adapter_ (0), + ort_adapter_factory_ (0), adapter_state_ (PortableInterceptor::HOLDING), network_priority_hook_ (0), #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) && !defined (CORBA_E_MICRO) @@ -245,6 +246,11 @@ TAO_Root_POA::TAO_Root_POA (const TAO_Root_POA::String &name, *this, this->policies_); } + // Cache ort adapter factory + this->ort_adapter_factory_ + = ACE_Dynamic_Service<TAO::ORT_Adapter_Factory>::instance + (orb_core_.configuration (), TAO_Root_POA::ort_adapter_factory_name ()); + #if (TAO_HAS_MINIMUM_POA == 1) // If this is the RootPOA, set the value of the ImplicitActivationPolicy // to IMPLICIT_ACTIVATION since it is impossible to pass the policy @@ -402,10 +408,10 @@ TAO_Root_POA::complete_destruction_i (void) { ort_adapter->release (my_array_obj_ref_template[0]); - TAO::ORT_Adapter_Factory *ort_factory = - this->ORT_adapter_factory (); - - ort_factory->destroy (ort_adapter); + if (this->ort_adapter_factory_) + { + this->ort_adapter_factory_->destroy (ort_adapter); + } this->ort_adapter_ = 0; } @@ -939,10 +945,10 @@ TAO_Root_POA::destroy_i (CORBA::Boolean etherealize_objects, { ort_adapter->release (my_array_obj_ref_template[0]); - TAO::ORT_Adapter_Factory *ort_factory = - this->ORT_adapter_factory (); - - ort_factory->destroy (ort_adapter); + if (this->ort_adapter_factory_) + { + this->ort_adapter_factory_->destroy (ort_adapter); + } this->ort_adapter_ = 0; } @@ -2285,51 +2291,38 @@ TAO_Root_POA::find_servant_priority ( find_servant_priority (system_id, priority); } -TAO::ORT_Adapter_Factory * -TAO_Root_POA::ORT_adapter_factory (void) -{ - return ACE_Dynamic_Service<TAO::ORT_Adapter_Factory>::instance - (orb_core_.configuration (), - TAO_Root_POA::ort_adapter_factory_name ()); -} - TAO::ORT_Adapter * TAO_Root_POA::ORT_adapter_i (void) { - if (this->ort_adapter_ != 0) - return this->ort_adapter_; - - try + if ((this->ort_adapter_ == 0) && (this->ort_adapter_factory_)) { - TAO::ORT_Adapter_Factory * ort_ap_factory = this->ORT_adapter_factory (); - - if (!ort_ap_factory) - return 0; - - // Get the full adapter name of this POA, do this before we - // create the adapter so that in case this fails, we just - // return 0 and not a not activated adapter - PortableInterceptor::AdapterName *adapter_name = this->adapter_name_i (); - - this->ort_adapter_ = ort_ap_factory->create (); + try + { + // Get the full adapter name of this POA, do this before we + // create the adapter so that in case this fails, we just + // return 0 and not a not activated adapter + PortableInterceptor::AdapterName *adapter_name = this->adapter_name_i (); - if (!this->ort_adapter_) - return 0; + this->ort_adapter_ = this->ort_adapter_factory_->create (); - // @todo We have to look at this, we activate it but hold the POA lock, - // in case we are called by ORT_adapter, we shouldn't keep the lock - // here, but then the ort_adapter should be guarded against multiple - // activations. - this->ort_adapter_->activate (this->orb_core_.server_id (), - this->orb_core_.orbid (), - adapter_name, - this); - } - catch (const ::CORBA::Exception& ex) - { - ex._tao_print_exception ( - "(%P|%t) Cannot initialize the " - "object_reference_template_adapter\n"); + if (this->ort_adapter_) + { + // @todo We have to look at this, we activate it but hold the POA lock, + // in case we are called by ORT_adapter, we shouldn't keep the lock + // here, but then the ort_adapter should be guarded against multiple + // activations. + this->ort_adapter_->activate (this->orb_core_.server_id (), + this->orb_core_.orbid (), + adapter_name, + this); + } + } + catch (const ::CORBA::Exception& ex) + { + ex._tao_print_exception ( + "(%P|%t) Cannot initialize the " + "object_reference_template_adapter\n"); + } } return this->ort_adapter_; diff --git a/TAO/tao/PortableServer/Root_POA.h b/TAO/tao/PortableServer/Root_POA.h index 44bf1cb9077..97a9a1070ad 100644 --- a/TAO/tao/PortableServer/Root_POA.h +++ b/TAO/tao/PortableServer/Root_POA.h @@ -649,8 +649,6 @@ protected: /// try to create one but assumes the POA lock is already hold TAO::ORT_Adapter *ORT_adapter_i (void); - TAO::ORT_Adapter_Factory *ORT_adapter_factory (void); - CORBA::Boolean persistent (void); static char persistent_key_char (void); @@ -705,7 +703,10 @@ protected: /// Pointer to the object reference template adapter. TAO::ORT_Adapter *ort_adapter_; - + + /// Pointer to the object reference template adapter factory. + TAO::ORT_Adapter_Factory *ort_adapter_factory_; + /// Adapter can be accepting, rejecting etc. PortableInterceptor::AdapterState adapter_state_; |