summaryrefslogtreecommitdiff
path: root/TAO/tao/RTPortableServer/RT_Policy_Validator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tao/RTPortableServer/RT_Policy_Validator.cpp')
-rw-r--r--TAO/tao/RTPortableServer/RT_Policy_Validator.cpp147
1 files changed, 126 insertions, 21 deletions
diff --git a/TAO/tao/RTPortableServer/RT_Policy_Validator.cpp b/TAO/tao/RTPortableServer/RT_Policy_Validator.cpp
index 895a53d6fab..f3272685092 100644
--- a/TAO/tao/RTPortableServer/RT_Policy_Validator.cpp
+++ b/TAO/tao/RTPortableServer/RT_Policy_Validator.cpp
@@ -4,12 +4,18 @@
#include "tao/PortableServer/PortableServerC.h"
#include "tao/ORB_Core.h"
#include "tao/RTCORBA/RT_Policy_i.h"
+#include "tao/RTCORBA/Thread_Pool.h"
+#include "tao/RTCORBA/RT_ORB.h"
+#include "tao/Thread_Lane_Resources_Manager.h"
+#include "tao/Thread_Lane_Resources.h"
#include "tao/Acceptor_Registry.h"
ACE_RCSID(tao, POA, "$Id$")
TAO_POA_RT_Policy_Validator::TAO_POA_RT_Policy_Validator (TAO_ORB_Core &orb_core)
- : TAO_POA_Policy_Validator (orb_core)
+ : TAO_POA_Policy_Validator (orb_core),
+ acceptor_registry_ (0),
+ thread_pool_ (0)
{
// No-Op.
}
@@ -19,17 +25,27 @@ TAO_POA_RT_Policy_Validator::~TAO_POA_RT_Policy_Validator (void)
// No-Op.
}
+TAO_Acceptor_Registry *
+TAO_POA_RT_Policy_Validator::acceptor_registry (void)
+{
+ if (this->acceptor_registry_ == 0)
+ this->acceptor_registry_ =
+ TAO_POA_RT_Policy_Validator::extract_acceptor_registry (this->orb_core_,
+ this->thread_pool_);
+ return this->acceptor_registry_;
+}
+
void
TAO_POA_RT_Policy_Validator::validate_impl (TAO_Policy_Set &policies,
CORBA::Environment &ACE_TRY_ENV)
{
- this->validate_server_protocol (policies, ACE_TRY_ENV);
+ this->validate_thread_pool (policies, ACE_TRY_ENV);
ACE_CHECK;
- this->validate_priorities (policies, ACE_TRY_ENV);
+ this->validate_server_protocol (policies, ACE_TRY_ENV);
ACE_CHECK;
- this->validate_thread_pool (policies, ACE_TRY_ENV);
+ this->validate_priorities (policies, ACE_TRY_ENV);
ACE_CHECK;
}
@@ -65,19 +81,28 @@ TAO_POA_RT_Policy_Validator::validate_server_protocol (TAO_Policy_Set &policies,
RTCORBA::ProtocolList &protocols =
server_protocol->protocols_rep ();
- TAO_Acceptor_Registry *ar = this->orb_core_.acceptor_registry ();
+ TAO_Acceptor_Registry *acceptor_registry =
+ this->acceptor_registry ();
for (CORBA::ULong j = 0; j < protocols.length (); ++j)
{
+ int found = 0;
CORBA::ULong protocol_type = protocols[j].protocol_type;
- for (TAO_AcceptorSetIterator a = ar->begin (); a != ar->end (); ++a)
+ for (TAO_AcceptorSetIterator a = acceptor_registry->begin ();
+ a != acceptor_registry->end ();
+ ++a)
{
if ((*a)->tag () == protocol_type)
- return;
+ {
+ found = 1;
+ break;
+ }
}
+
+ if (!found)
+ ACE_THROW (PortableServer::POA::InvalidPolicy ());
}
- ACE_THROW (PortableServer::POA::InvalidPolicy ());
}
void
@@ -158,7 +183,9 @@ TAO_POA_RT_Policy_Validator::validate_priorities (TAO_Policy_Set &policies,
}
// Check 3.
- TAO_Acceptor_Registry *ar = this->orb_core_.acceptor_registry ();
+ TAO_Acceptor_Registry *ar =
+ this->acceptor_registry ();
+
for (CORBA::ULong i = 0; i < bands.length (); ++i)
{
int match = 0;
@@ -187,7 +214,8 @@ TAO_POA_RT_Policy_Validator::validate_priorities (TAO_Policy_Set &policies,
// priority.
if (rt_priority_model == RTCORBA::SERVER_DECLARED)
{
- TAO_Acceptor_Registry *ar = this->orb_core_.acceptor_registry ();
+ TAO_Acceptor_Registry *ar =
+ this->acceptor_registry ();
for (TAO_AcceptorSetIterator a = ar->begin (); a != ar->end (); ++a)
{
@@ -203,23 +231,100 @@ void
TAO_POA_RT_Policy_Validator::validate_thread_pool (TAO_Policy_Set &policies,
CORBA::Environment &ACE_TRY_ENV)
{
+ this->thread_pool_ =
+ TAO_POA_RT_Policy_Validator::extract_thread_pool (this->orb_core_,
+ policies,
+ ACE_TRY_ENV);
+ ACE_CHECK;
+}
+
+/* static */
+TAO_Thread_Pool *
+TAO_POA_RT_Policy_Validator::extract_thread_pool (TAO_ORB_Core &orb_core,
+ TAO_Policy_Set &policies,
+ CORBA::Environment &ACE_TRY_ENV)
+{
CORBA::Policy_var policy =
policies.get_cached_policy (TAO_CACHED_POLICY_THREADPOOL);
- RTCORBA::ThreadpoolPolicy_var thread_pool =
+ RTCORBA::ThreadpoolPolicy_var thread_pool_policy =
RTCORBA::ThreadpoolPolicy::_narrow (policy.in (),
ACE_TRY_ENV);
- ACE_CHECK;
+ ACE_CHECK_RETURN (0);
- if (!CORBA::is_nil (thread_pool.in ()))
+ if (CORBA::is_nil (thread_pool_policy.in ()))
+ return 0;
+
+ RTCORBA::ThreadpoolId thread_pool_id =
+ thread_pool_policy->threadpool (ACE_TRY_ENV);
+ ACE_CHECK_RETURN (0);
+
+ // Get the RTORB.
+ CORBA::Object_var object =
+ orb_core.resolve_rt_orb (ACE_TRY_ENV);
+ ACE_CHECK_RETURN (0);
+
+ RTCORBA::RTORB_var rt_orb =
+ RTCORBA::RTORB::_narrow (object,
+ ACE_TRY_ENV);
+ ACE_CHECK_RETURN (0);
+
+ TAO_RT_ORB *tao_rt_orb =
+ ACE_dynamic_cast (TAO_RT_ORB *,
+ rt_orb.in ());
+
+ TAO_Thread_Pool_Manager &tp_manager =
+ tao_rt_orb->tp_manager ();
+
+ TAO_Thread_Pool_Manager::THREAD_POOLS &thread_pools =
+ tp_manager.thread_pools ();
+
+ // Check that the thread pool id is valid.
+ TAO_Thread_Pool *thread_pool = 0;
+ int result =
+ thread_pools.find (thread_pool_id,
+ thread_pool);
+
+ if (result != 0)
+ ACE_THROW_RETURN (PortableServer::POA::InvalidPolicy (),
+ 0);
+
+ return thread_pool;
+}
+
+/* static */
+TAO_Acceptor_Registry *
+TAO_POA_RT_Policy_Validator::extract_acceptor_registry (TAO_ORB_Core &orb_core,
+ TAO_Thread_Pool *thread_pool)
+{
+ TAO_Acceptor_Registry *acceptor_registry = 0;
+
+ // If <thread_pool_> != 0, it means that we have a RT thread pool.
+ if (thread_pool)
{
- RTCORBA::ThreadpoolId thread_pool_id =
- = thread_pool->thread_pool (ACE_TRY_ENV);
- ACE_CHECK;
+ TAO_Thread_Lane **lanes =
+ thread_pool->lanes ();
- // Check that the thread pool id is valid.
- int result =
- find (thread_pool_id);
- if (result != 0)
- ACE_THROW (PortableServer::POA::InvalidPolicy ());
+ // All the lanes have similar acceptor registries. Therefore,
+ // looking at the first lane should suffice.
+ TAO_Thread_Lane_Resources &resources =
+ lanes[0]->resources ();
+
+ acceptor_registry =
+ &resources.acceptor_registry ();
}
+ else
+ // We are dealing with the default thread pool.
+ {
+ TAO_Thread_Lane_Resources_Manager &thread_lane_resources_manager =
+ orb_core.thread_lane_resources_manager ();
+
+ TAO_Thread_Lane_Resources &resources =
+ thread_lane_resources_manager.default_lane_resources ();
+
+ acceptor_registry =
+ &resources.acceptor_registry ();
+ }
+
+ return acceptor_registry;
+}