diff options
author | Johnny Willemsen <jwillemsen@remedy.nl> | 2012-10-30 10:52:59 +0000 |
---|---|---|
committer | Johnny Willemsen <jwillemsen@remedy.nl> | 2012-10-30 10:52:59 +0000 |
commit | 3cbd9025d4eaa68f7df0ed3a11b5d6a8ea814cf3 (patch) | |
tree | 0aa712af97bd864cb0183dae58259a3cbe6ded5a /TAO/tao/PortableServer/Root_POA.cpp | |
parent | 143af784e8afa559cc7042bebf86c2b5e189dc12 (diff) | |
download | ATCD-3cbd9025d4eaa68f7df0ed3a11b5d6a8ea814cf3.tar.gz |
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
Diffstat (limited to 'TAO/tao/PortableServer/Root_POA.cpp')
-rw-r--r-- | TAO/tao/PortableServer/Root_POA.cpp | 87 |
1 files changed, 40 insertions, 47 deletions
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_; |