diff options
author | vzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-01-08 10:16:50 +0000 |
---|---|---|
committer | vzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2008-01-08 10:16:50 +0000 |
commit | f594a9d396df2be56b4d39dd27d296f0d6a1e663 (patch) | |
tree | 9c11d7fbc8cbe5c18fd84c618a91aff81221a32e /TAO/tao/PortableServer | |
parent | a6257b22f954561a291b7bbde09ba7bd6e944a0e (diff) | |
download | ATCD-f594a9d396df2be56b4d39dd27d296f0d6a1e663.tar.gz |
ChangeLogTag: Tue Jan 8 10:11:48 UTC 2008 Vladimir Zykov <vladimir.zykov@prismtech.com>
Diffstat (limited to 'TAO/tao/PortableServer')
-rw-r--r-- | TAO/tao/PortableServer/Active_Policy_Strategies.h | 16 | ||||
-rw-r--r-- | TAO/tao/PortableServer/Active_Policy_Strategies.inl | 26 | ||||
-rw-r--r-- | TAO/tao/PortableServer/Root_POA.cpp | 11 |
3 files changed, 51 insertions, 2 deletions
diff --git a/TAO/tao/PortableServer/Active_Policy_Strategies.h b/TAO/tao/PortableServer/Active_Policy_Strategies.h index 16cec7c1071..b5f2cac656c 100644 --- a/TAO/tao/PortableServer/Active_Policy_Strategies.h +++ b/TAO/tao/PortableServer/Active_Policy_Strategies.h @@ -91,6 +91,22 @@ namespace TAO IdUniquenessStrategyFactory *id_uniqueness_strategy_factory_; IdAssignmentStrategyFactory *id_assignment_strategy_factory_; }; + + /** + * This class quards the cleanup of strategies if something went wrong + * in the code that called Active_Policy_Strategies::update(). + */ + class Active_Policy_Strategies_Cleanup_Guard + { + public: + Active_Policy_Strategies_Cleanup_Guard (Active_Policy_Strategies *p); + ~Active_Policy_Strategies_Cleanup_Guard (void); + + Active_Policy_Strategies *_retn (void); + + private: + Active_Policy_Strategies *ptr_; + }; } } diff --git a/TAO/tao/PortableServer/Active_Policy_Strategies.inl b/TAO/tao/PortableServer/Active_Policy_Strategies.inl index ab606b04b1a..5050cfe8cbe 100644 --- a/TAO/tao/PortableServer/Active_Policy_Strategies.inl +++ b/TAO/tao/PortableServer/Active_Policy_Strategies.inl @@ -56,6 +56,32 @@ namespace TAO { return this->servant_retention_strategy_; } + + ACE_INLINE + Active_Policy_Strategies_Cleanup_Guard + ::Active_Policy_Strategies_Cleanup_Guard (Active_Policy_Strategies *p) + : ptr_ (p) + { + } + + ACE_INLINE + Active_Policy_Strategies_Cleanup_Guard + ::~Active_Policy_Strategies_Cleanup_Guard (void) + { + if (this->ptr_) + { + this->ptr_->cleanup (); + } + } + + ACE_INLINE + Active_Policy_Strategies * + Active_Policy_Strategies_Cleanup_Guard::_retn (void) + { + Active_Policy_Strategies *temp = this->ptr_; + this->ptr_ = 0; + return temp; + } } } diff --git a/TAO/tao/PortableServer/Root_POA.cpp b/TAO/tao/PortableServer/Root_POA.cpp index eeeaea055d4..02932633fa4 100644 --- a/TAO/tao/PortableServer/Root_POA.cpp +++ b/TAO/tao/PortableServer/Root_POA.cpp @@ -231,8 +231,9 @@ TAO_Root_POA::TAO_Root_POA (const TAO_Root_POA::String &name, servant_for_key_to_object_ (0) { // Since we are keeping a reference to a POAManager, we need to - // increment the reference count - this->poa_manager_._add_ref(); + // increment the reference count but we do this safely. + PortableServer::POAManager_var pm_guard ( + PortableServer::POAManager::_duplicate(&this->poa_manager_)); // Parse the policies that are used in the critical path in // a cache. @@ -268,6 +269,8 @@ TAO_Root_POA::TAO_Root_POA (const TAO_Root_POA::String &name, // Set the active strategies to be used by this POA this->active_policy_strategies_.update (this->cached_policies_, this); + TAO::Portable_Server::Active_Policy_Strategies_Cleanup_Guard aps_cleanup_guard ( + &this->active_policy_strategies_); // Set the folded name of this POA. this->set_folded_name (parent); @@ -309,6 +312,10 @@ TAO_Root_POA::TAO_Root_POA (const TAO_Root_POA::String &name, this->system_name_.in ()); throw; } + + // Now when everything is fine we can release the quards. + pm_guard._retn (); + aps_cleanup_guard._retn (); } TAO_Root_POA::~TAO_Root_POA (void) |