From 68090463abdc4d4c0931336a0590735aa9f50f85 Mon Sep 17 00:00:00 2001 From: jai Date: Fri, 26 Jan 2007 19:08:44 +0000 Subject: refactoring protocols hooks --- .../RT_Protocols_Properties_Protocols_Hooks.cpp | 578 +++------------------ 1 file changed, 76 insertions(+), 502 deletions(-) diff --git a/TAO/tao/RTCORBA/RT_Protocols_Properties_Protocols_Hooks.cpp b/TAO/tao/RTCORBA/RT_Protocols_Properties_Protocols_Hooks.cpp index c77097fc103..8ff2a3407b4 100644 --- a/TAO/tao/RTCORBA/RT_Protocols_Properties_Protocols_Hooks.cpp +++ b/TAO/tao/RTCORBA/RT_Protocols_Properties_Protocols_Hooks.cpp @@ -1,4 +1,4 @@ -#include "tao/RTCORBA/RT_Protocols_Hooks.h" +#include "tao/RTCORBA/RT_Protocols_Properties_Protocols_Hooks.h" #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 @@ -24,24 +24,26 @@ #include "ace/OS_NS_string.h" ACE_RCSID (RTCORBA, - RT_Protocols_Hooks, + RT_Protocols_Properties_Protocols_Hooks, "$Id$") TAO_BEGIN_VERSIONED_NAMESPACE_DECL -TAO_RT_Protocols_Hooks::TAO_RT_Protocols_Hooks (void) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +TAO_RT_Protocols_Properties_Protocols_Hooks (void) : orb_core_ (0) , current_ () { } -TAO_RT_Protocols_Hooks::~TAO_RT_Protocols_Hooks (void) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +~TAO_RT_Protocols_Properties_Protocols_Hooks (void) { } void -TAO_RT_Protocols_Hooks::init_hooks (TAO_ORB_Core *orb_core +TAO_RT_Protocols_Properties_Protocols_Hooks::init_hooks (TAO_ORB_Core *orb_core ACE_ENV_ARG_DECL) { this->orb_core_ = orb_core; @@ -78,9 +80,8 @@ TAO_RT_Protocols_Hooks::init_hooks (TAO_ORB_Core *orb_core } RTCORBA::ProtocolProperties_ptr -TAO_RT_Protocols_Hooks::server_protocol_properties (IOP::ProfileId protocol_tag, - CORBA::Policy_ptr policy - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks::server_protocol_properties ( + IOP::ProfileId protocol_tag, CORBA::Policy_ptr policy ACE_ENV_ARG_DECL) { if (CORBA::is_nil (policy)) return 0; @@ -115,9 +116,8 @@ TAO_RT_Protocols_Hooks::server_protocol_properties (IOP::ProfileId protocol_tag, } RTCORBA::ProtocolProperties_ptr -TAO_RT_Protocols_Hooks::client_protocol_properties (IOP::ProfileId protocol_tag, - CORBA::Policy_ptr policy - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks::client_protocol_properties ( + IOP::ProfileId protocol_tag, CORBA::Policy_ptr policy ACE_ENV_ARG_DECL) { if (CORBA::is_nil (policy)) return 0; @@ -152,8 +152,9 @@ TAO_RT_Protocols_Hooks::client_protocol_properties (IOP::ProfileId protocol_tag, } RTCORBA::ProtocolProperties_ptr -TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (IOP::ProfileId protocol_tag - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +server_protocol_properties_at_orb_level (IOP::ProfileId protocol_tag + ACE_ENV_ARG_DECL) { CORBA::Policy_var policy = this->orb_core_->get_cached_policy (TAO_CACHED_POLICY_RT_SERVER_PROTOCOL @@ -166,8 +167,9 @@ TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (IOP::ProfileId } RTCORBA::ProtocolProperties_ptr -TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (IOP::ProfileId protocol_tag - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +client_protocol_properties_at_orb_level (IOP::ProfileId protocol_tag + ACE_ENV_ARG_DECL) { CORBA::Policy_var policy = this->orb_core_->get_cached_policy (TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL @@ -180,9 +182,10 @@ TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (IOP::ProfileId } RTCORBA::ProtocolProperties_ptr -TAO_RT_Protocols_Hooks::client_protocol_properties_at_object_level (IOP::ProfileId protocol_tag, - TAO_Stub *stub - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +client_protocol_properties_at_object_level (IOP::ProfileId protocol_tag, + TAO_Stub *stub + ACE_ENV_ARG_DECL) { CORBA::Policy_var policy = stub->get_cached_policy (TAO_CACHED_POLICY_RT_CLIENT_PROTOCOL @@ -195,9 +198,10 @@ TAO_RT_Protocols_Hooks::client_protocol_properties_at_object_level (IOP::Profile } void -TAO_RT_Protocols_Hooks::extract_protocol_properties (TAO_IIOP_Protocol_Properties &to, - RTCORBA::ProtocolProperties_ptr from - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks::extract_protocol_properties ( + TAO_IIOP_Protocol_Properties &to, + RTCORBA::ProtocolProperties_ptr from + ACE_ENV_ARG_DECL) { RTCORBA::TCPProtocolProperties_var protocol_properties = RTCORBA::TCPProtocolProperties::_narrow (from @@ -213,8 +217,9 @@ TAO_RT_Protocols_Hooks::extract_protocol_properties (TAO_IIOP_Protocol_Propertie } void -TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &to - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +server_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &to + ACE_ENV_ARG_DECL) { RTCORBA::ProtocolProperties_var from = this->server_protocol_properties_at_orb_level (IOP::TAG_INTERNET_IOP @@ -229,8 +234,9 @@ TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (TAO_IIOP_Protoc } void -TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &to - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +client_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &to + ACE_ENV_ARG_DECL) { RTCORBA::ProtocolProperties_var from = this->client_protocol_properties_at_orb_level (IOP::TAG_INTERNET_IOP @@ -244,9 +250,10 @@ TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (TAO_IIOP_Protoc } void -TAO_RT_Protocols_Hooks::extract_protocol_properties (TAO_UIOP_Protocol_Properties &to, - RTCORBA::ProtocolProperties_ptr from - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +extract_protocol_properties (TAO_UIOP_Protocol_Properties &to, + RTCORBA::ProtocolProperties_ptr from + ACE_ENV_ARG_DECL) { RTCORBA::UnixDomainProtocolProperties_var protocol_properties = RTCORBA::UnixDomainProtocolProperties::_narrow (from @@ -258,8 +265,9 @@ TAO_RT_Protocols_Hooks::extract_protocol_properties (TAO_UIOP_Protocol_Propertie } void -TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (TAO_UIOP_Protocol_Properties &to - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +server_protocol_properties_at_orb_level (TAO_UIOP_Protocol_Properties &to + ACE_ENV_ARG_DECL) { RTCORBA::ProtocolProperties_var from = this->server_protocol_properties_at_orb_level (TAO_TAG_UIOP_PROFILE @@ -274,8 +282,9 @@ TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (TAO_UIOP_Protoc } void -TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (TAO_UIOP_Protocol_Properties &to - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +client_protocol_properties_at_orb_level (TAO_UIOP_Protocol_Properties &to + ACE_ENV_ARG_DECL) { RTCORBA::ProtocolProperties_var from = this->client_protocol_properties_at_orb_level (TAO_TAG_UIOP_PROFILE @@ -289,9 +298,10 @@ TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (TAO_UIOP_Protoc } void -TAO_RT_Protocols_Hooks::extract_protocol_properties (TAO_SHMIOP_Protocol_Properties &to, - RTCORBA::ProtocolProperties_ptr from - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks::extract_protocol_properties ( + TAO_SHMIOP_Protocol_Properties &to, + RTCORBA::ProtocolProperties_ptr from + ACE_ENV_ARG_DECL) { RTCORBA::SharedMemoryProtocolProperties_var protocol_properties = RTCORBA::SharedMemoryProtocolProperties::_narrow (from @@ -304,8 +314,9 @@ TAO_RT_Protocols_Hooks::extract_protocol_properties (TAO_SHMIOP_Protocol_Propert } void -TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (TAO_SHMIOP_Protocol_Properties &to - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +server_protocol_properties_at_orb_level (TAO_SHMIOP_Protocol_Properties &to + ACE_ENV_ARG_DECL) { RTCORBA::ProtocolProperties_var from = this->server_protocol_properties_at_orb_level (TAO_TAG_SHMEM_PROFILE @@ -320,8 +331,9 @@ TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (TAO_SHMIOP_Prot } void -TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (TAO_SHMIOP_Protocol_Properties &to - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +client_protocol_properties_at_orb_level (TAO_SHMIOP_Protocol_Properties &to + ACE_ENV_ARG_DECL) { RTCORBA::ProtocolProperties_var from = this->client_protocol_properties_at_orb_level (TAO_TAG_SHMEM_PROFILE @@ -335,9 +347,10 @@ TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (TAO_SHMIOP_Prot } void -TAO_RT_Protocols_Hooks::extract_protocol_properties (TAO_DIOP_Protocol_Properties &to, - RTCORBA::ProtocolProperties_ptr from - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks::extract_protocol_properties ( + TAO_DIOP_Protocol_Properties &to, + RTCORBA::ProtocolProperties_ptr from + ACE_ENV_ARG_DECL) { RTCORBA::UserDatagramProtocolProperties_var protocol_properties = RTCORBA::UserDatagramProtocolProperties::_narrow (from @@ -348,8 +361,9 @@ TAO_RT_Protocols_Hooks::extract_protocol_properties (TAO_DIOP_Protocol_Propertie } void -TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (TAO_DIOP_Protocol_Properties &to - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +server_protocol_properties_at_orb_level (TAO_DIOP_Protocol_Properties &to + ACE_ENV_ARG_DECL) { RTCORBA::ProtocolProperties_var from = this->server_protocol_properties_at_orb_level (TAO_TAG_DIOP_PROFILE @@ -364,8 +378,9 @@ TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (TAO_DIOP_Protoc } void -TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (TAO_DIOP_Protocol_Properties &to - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +client_protocol_properties_at_orb_level (TAO_DIOP_Protocol_Properties &to + ACE_ENV_ARG_DECL) { RTCORBA::ProtocolProperties_var from = this->client_protocol_properties_at_orb_level (TAO_TAG_DIOP_PROFILE @@ -379,9 +394,10 @@ TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (TAO_DIOP_Protoc } void -TAO_RT_Protocols_Hooks::extract_protocol_properties (TAO_SCIOP_Protocol_Properties &to, - RTCORBA::ProtocolProperties_ptr from - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks::extract_protocol_properties ( + TAO_SCIOP_Protocol_Properties &to, + RTCORBA::ProtocolProperties_ptr from + ACE_ENV_ARG_DECL) { RTCORBA::StreamControlProtocolProperties_var protocol_properties = RTCORBA::StreamControlProtocolProperties::_narrow (from @@ -397,8 +413,9 @@ TAO_RT_Protocols_Hooks::extract_protocol_properties (TAO_SCIOP_Protocol_Properti } void -TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (TAO_SCIOP_Protocol_Properties &to - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +server_protocol_properties_at_orb_level (TAO_SCIOP_Protocol_Properties &to + ACE_ENV_ARG_DECL) { RTCORBA::ProtocolProperties_var from = this->server_protocol_properties_at_orb_level (TAO_TAG_SCIOP_PROFILE @@ -413,8 +430,9 @@ TAO_RT_Protocols_Hooks::server_protocol_properties_at_orb_level (TAO_SCIOP_Proto } void -TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (TAO_SCIOP_Protocol_Properties &to - ACE_ENV_ARG_DECL) +TAO_RT_Protocols_Properties_Protocols_Hooks:: +client_protocol_properties_at_orb_level (TAO_SCIOP_Protocol_Properties &to + ACE_ENV_ARG_DECL) { RTCORBA::ProtocolProperties_var from = this->client_protocol_properties_at_orb_level (TAO_TAG_SCIOP_PROFILE @@ -427,460 +445,16 @@ TAO_RT_Protocols_Hooks::client_protocol_properties_at_orb_level (TAO_SCIOP_Proto ACE_ENV_ARG_PARAMETER); } -CORBA::Boolean -TAO_RT_Protocols_Hooks::set_network_priority (IOP::ProfileId protocol_tag, - RTCORBA::ProtocolProperties_ptr protocol_properties - ACE_ENV_ARG_DECL) -{ - if (CORBA::is_nil (protocol_properties)) - return false; - - if (protocol_tag == IOP::TAG_INTERNET_IOP) - { - RTCORBA::TCPProtocolProperties_var tcp_protocol_properties = - RTCORBA::TCPProtocolProperties::_narrow (protocol_properties - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (false); - - return tcp_protocol_properties->enable_network_priority (); - } - - if (protocol_tag == TAO_TAG_DIOP_PROFILE) - { - RTCORBA::UserDatagramProtocolProperties_var udp_protocol_properties = - RTCORBA::UserDatagramProtocolProperties::_narrow (protocol_properties - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (false); - - return udp_protocol_properties->enable_network_priority (); - } - - if (protocol_tag == TAO_TAG_SCIOP_PROFILE) - { - RTCORBA::StreamControlProtocolProperties_var sctp_protocol_properties = - RTCORBA::StreamControlProtocolProperties::_narrow (protocol_properties - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (false); - - return sctp_protocol_properties->enable_network_priority (); - } - - return false; -} - -CORBA::Boolean -TAO_RT_Protocols_Hooks::set_client_network_priority (IOP::ProfileId protocol_tag, - TAO_Stub *stub - ACE_ENV_ARG_DECL) -{ - if (protocol_tag != IOP::TAG_INTERNET_IOP && - protocol_tag != TAO_TAG_DIOP_PROFILE && - protocol_tag != TAO_TAG_SCIOP_PROFILE) - return false; - - RTCORBA::ProtocolProperties_var protocol_properties = - this->client_protocol_properties_at_object_level (protocol_tag, - stub - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (false); - - return this->set_network_priority (protocol_tag, - protocol_properties.in () - ACE_ENV_ARG_PARAMETER); -} - -CORBA::Boolean -TAO_RT_Protocols_Hooks::set_server_network_priority (IOP::ProfileId protocol_tag, - CORBA::Policy *policy - ACE_ENV_ARG_DECL) -{ - if (protocol_tag != IOP::TAG_INTERNET_IOP && - protocol_tag != TAO_TAG_DIOP_PROFILE && - protocol_tag != TAO_TAG_SCIOP_PROFILE) - return false; - - RTCORBA::ProtocolProperties_var protocol_properties = - this->server_protocol_properties (protocol_tag, - policy - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (false); - - return this->set_network_priority (protocol_tag, - protocol_properties.in () - ACE_ENV_ARG_PARAMETER); -} - -void -TAO_RT_Protocols_Hooks::set_dscp_codepoint (CORBA::Long &dscp_codepoint - ACE_ENV_ARG_DECL_NOT_USED) -{ -} - -CORBA::Long -TAO_RT_Protocols_Hooks::get_dscp_codepoint (void) -{ - if (TAO_debug_level) - ACE_DEBUG ((LM_DEBUG, - "TAO_RT_Protocols_Hooks::get_dscp_codepoint\n")); - - CORBA::Long codepoint = 0; - - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - // Make several invocation, changing the priority of this thread - // for each. - - RTCORBA::NetworkPriorityMapping *pm = - this->network_mapping_manager_->mapping (); - - const CORBA::Short priority = - this->current_->the_priority (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (pm->to_network (priority, codepoint) == 0) - { - if (TAO_debug_level > 0) - { - ACE_ERROR ((LM_ERROR, - "Cannot convert corba priority %d " - "to network priority\n", - priority)); - } - - return -1; - } - } - ACE_CATCHANY - { - if (TAO_debug_level > 0) - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "TAO_RT_Protocols_Hooks::get_dscp_codepoint"); - } - - return -1; - } - ACE_ENDTRY; - ACE_CHECK_RETURN (-1); - - return codepoint; -} - -void -TAO_RT_Protocols_Hooks::np_service_context ( - TAO_Stub *stub, - TAO_Service_Context &service_context, - CORBA::Boolean restart - ACE_ENV_ARG_DECL_NOT_USED) -{ - if (!restart) - { - CORBA::Policy_var cnpp = - stub->get_cached_policy (TAO_CACHED_POLICY_CLIENT_NETWORK_PRIORITY - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (!CORBA::is_nil (cnpp.in ())) - { - TAO::NetworkPriorityPolicy_var cnp = - TAO::NetworkPriorityPolicy::_narrow (cnpp.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - TAO::DiffservCodepoint reply_diffserv_codepoint; - reply_diffserv_codepoint = cnp->get_reply_diffserv_codepoint (); - - CORBA::Long rep_dscp_codepoint = reply_diffserv_codepoint; - - this->add_rep_np_service_context_hook (service_context, - rep_dscp_codepoint - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } - } -} - -void -TAO_RT_Protocols_Hooks::rt_service_context ( - TAO_Stub *stub, - TAO_Service_Context &service_context, - CORBA::Boolean restart - ACE_ENV_ARG_DECL - ) -{ - // If the restart flag is true, then this call for a - // reinvocation. We need not prepare the Service Context List once - // again. We can use the already existing one. - if (!restart) - { - TAO_RT_Stub *rt_stub = - dynamic_cast (stub); - - CORBA::Policy_var priority_model_policy = - rt_stub->get_cached_policy (TAO_CACHED_POLICY_PRIORITY_MODEL - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - if (!CORBA::is_nil (priority_model_policy.in ())) - { - CORBA::Short client_priority; - - int status = - this->get_thread_CORBA_priority (client_priority - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - if (status == -1) - ACE_THROW (CORBA::DATA_CONVERSION (1, CORBA::COMPLETED_NO)); - - this->add_rt_service_context_hook (service_context, - priority_model_policy.in (), - client_priority - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } - else - { - // The Object does not contain PriorityModel policy in its IOR. - // We must be talking to a non-RT ORB. Do nothing. - } - } -} - -void -TAO_RT_Protocols_Hooks::add_rep_np_service_context_hook ( - TAO_Service_Context &service_context, - CORBA::Long &dscp_codepoint - ACE_ENV_ARG_DECL_NOT_USED) -{ - TAO_OutputCDR cdr; - if ((cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) == 0) - || (cdr << dscp_codepoint) == 0) - { - ACE_THROW (CORBA::MARSHAL ()); - } - - service_context.set_context (IOP::REP_NWPRIORITY, cdr); -} - -void -TAO_RT_Protocols_Hooks::add_rt_service_context_hook ( - TAO_Service_Context &service_context, - CORBA::Policy *model_policy, - CORBA::Short &client_priority - ACE_ENV_ARG_DECL - ) -{ - - RTCORBA::PriorityModelPolicy_var model_policy_ptr = - RTCORBA::PriorityModelPolicy::_narrow (model_policy - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - TAO_PriorityModelPolicy *priority_model = - static_cast (model_policy_ptr.in ()); - - if (priority_model->get_priority_model () == RTCORBA::CLIENT_PROPAGATED) - { - // Encapsulate the priority of the current thread into - // a service context. - TAO_OutputCDR cdr; - if ((cdr << ACE_OutputCDR::from_boolean (TAO_ENCAP_BYTE_ORDER) == 0) - || (cdr << client_priority) == 0) - { - ACE_THROW (CORBA::MARSHAL ()); - } - - service_context.set_context (IOP::RTCorbaPriority, cdr); - } -} - -void -TAO_RT_Protocols_Hooks::get_selector_hook ( - CORBA::Policy *model_policy, - CORBA::Boolean &is_client_propagated, - CORBA::Short &server_priority - ) -{ - - RTCORBA::PriorityModelPolicy_var model_policy_ptr = - RTCORBA::PriorityModelPolicy::_narrow (model_policy); - - TAO_PriorityModelPolicy *priority_model_policy = - static_cast (model_policy_ptr.in ()); - - if (priority_model_policy->get_priority_model () - == RTCORBA::CLIENT_PROPAGATED) - { - is_client_propagated = 1; - } - - if (!is_client_propagated) - { - server_priority = priority_model_policy->server_priority (); - } - - return; -} - -void -TAO_RT_Protocols_Hooks::get_selector_bands_policy_hook ( - CORBA::Policy *bands_policy, - CORBA::Short priority, - CORBA::Short &min_priority, - CORBA::Short &max_priority, - int &in_range - ) -{ - RTCORBA::PriorityBandedConnectionPolicy_var bands_policy_ptr = - RTCORBA::PriorityBandedConnectionPolicy::_narrow (bands_policy); - - TAO_PriorityBandedConnectionPolicy *priority_bands_policy = - static_cast (bands_policy_ptr.in ()); - - // Find the band with the range covering our target priority. - RTCORBA::PriorityBands &bands = - priority_bands_policy->priority_bands_rep (); - - for (CORBA::ULong i = 0; i < bands.length (); ++i) - { - if (bands[i].low <= priority && bands[i].high >= priority) - { - min_priority = bands[i].low; - max_priority = bands[i].high; - - in_range = 1; - break; - } - } -} - -int -TAO_RT_Protocols_Hooks::get_thread_CORBA_priority (CORBA::Short &priority - ACE_ENV_ARG_DECL) -{ - CORBA::Short native_priority = 0; - int const result = - this->get_thread_CORBA_and_native_priority (priority, - native_priority - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - - if (result == -1) - { - return result; - } - - return 0; -} - -int -TAO_RT_Protocols_Hooks::get_thread_native_priority ( - CORBA::Short &native_priority - ACE_ENV_ARG_DECL_NOT_USED - ) -{ - ACE_hthread_t current; - ACE_Thread::self (current); - - int priority; - - if (ACE_Thread::getprio (current, priority) == -1) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) - ") - ACE_TEXT ("RT_Protocols_Hooks::get_thread_priority: ") - ACE_TEXT (" ACE_Thread::get_prio\n"))); - - return -1; - } - - native_priority = CORBA::Short (priority); - return 0; -} - -int -TAO_RT_Protocols_Hooks::get_thread_CORBA_and_native_priority ( - CORBA::Short &priority, - CORBA::Short &native_priority - ACE_ENV_ARG_DECL - ) -{ - int result = - this->get_thread_native_priority (native_priority - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - - if (result == -1) - { - return result; - } - - TAO_Priority_Mapping *priority_mapping = - this->mapping_manager_.in ()->mapping (); - - if (priority_mapping->to_CORBA (native_priority, priority) == 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("TAO (%P|%t) - ") - ACE_TEXT ("RT_Protocols_Hooks::get_thread_priority: ") - ACE_TEXT ("Priority_Mapping::to_CORBA\n"))); - return -1; - } - - return 0; -} - -int -TAO_RT_Protocols_Hooks::set_thread_CORBA_priority (CORBA::Short priority - ACE_ENV_ARG_DECL) -{ - TAO_Priority_Mapping *priority_mapping = - this->mapping_manager_.in ()->mapping (); - - CORBA::Short native_priority; - - if (priority_mapping->to_native (priority, native_priority) == 0) - { - return -1; - } - - return this->set_thread_native_priority (native_priority - ACE_ENV_ARG_PARAMETER); -} - -int -TAO_RT_Protocols_Hooks::set_thread_native_priority ( - CORBA::Short native_priority - ACE_ENV_ARG_DECL_NOT_USED - ) -{ - ACE_hthread_t current; - ACE_Thread::self (current); - - if (ACE_Thread::setprio (current, native_priority) == -1) - { - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%N,%l) Error setting thread ") - ACE_TEXT ("priority to %d, errno %d %m\n"), - native_priority, - errno ), - -1); - } - - return 0; -} - TAO_END_VERSIONED_NAMESPACE_DECL -ACE_STATIC_SVC_DEFINE (TAO_RT_Protocols_Hooks, - ACE_TEXT ("RT_Protocols_Hooks"), +ACE_STATIC_SVC_DEFINE (TAO_RT_Protocols_Properties_Protocols_Hooks, + ACE_TEXT ("RT_Protocols_Properties_Protocols_Hooks"), ACE_SVC_OBJ_T, - &ACE_SVC_NAME (TAO_RT_Protocols_Hooks), + &ACE_SVC_NAME ( + TAO_RT_Protocols_Properties_Protocols_Hooks), ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, 0) -ACE_FACTORY_DEFINE (TAO_RTCORBA, TAO_RT_Protocols_Hooks) +ACE_FACTORY_DEFINE (TAO_RTCORBA, TAO_RT_Protocols_Properties_Protocols_Hooks) #endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */ -- cgit v1.2.1