summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-01-26 17:31:11 +0000
committerjai <jai@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-01-26 17:31:11 +0000
commit250758a858f5df586336eb429d8b018adff93890 (patch)
treeb93d32556500bc4833f50c4cb2a808cc9d704ed5
parent76e5f9022f7cfbd2263617a62ae96eb67e4e6276 (diff)
downloadATCD-250758a858f5df586336eb429d8b018adff93890.tar.gz
refactoring protocols hooks
-rw-r--r--TAO/tao/Default_Network_Priority_Protocols_Hook.cpp73
-rw-r--r--TAO/tao/Default_Network_Priority_Protocols_Hooks.h3
-rw-r--r--TAO/tao/Default_Policy_Protocols_Hooks.h3
-rw-r--r--TAO/tao/Default_Protocols_Properties_Protocols_Hooks.h3
-rw-r--r--TAO/tao/Default_Thread_Priority_Protocols_Hooks.h3
-rw-r--r--TAO/tao/Network_Priority_Protocols_Hooks.h3
-rw-r--r--TAO/tao/Policy_Protocols_Hooks.h3
-rw-r--r--TAO/tao/Protocols_Properties_Protocols_Hooks.h3
-rw-r--r--TAO/tao/RTCORBA/RT_Policy_Protocols_Hooks.cpp886
-rw-r--r--TAO/tao/RTCORBA/RT_Protocols_Properties_Protocols_Hooks.cpp886
-rw-r--r--TAO/tao/RTCORBA/RT_Thread_Priority_Protocols_Hooks.cpp207
-rw-r--r--TAO/tao/Thread_Priority_Protocols_Hooks.h3
12 files changed, 2003 insertions, 73 deletions
diff --git a/TAO/tao/Default_Network_Priority_Protocols_Hook.cpp b/TAO/tao/Default_Network_Priority_Protocols_Hook.cpp
deleted file mode 100644
index 0cc64e5ae77..00000000000
--- a/TAO/tao/Default_Network_Priority_Protocols_Hook.cpp
+++ /dev/null
@@ -1,73 +0,0 @@
-// $Id$
-
-#include "tao/Default_Network_Priority_Protocols_Hooks.h"
-#include "ace/Log_Msg.h"
-#include "tao/Stub.h"
-#include "tao/ORB_Core.h"
-#include "tao/MProfile.h"
-#include "tao/Service_Context.h"
-#include "tao/Acceptor_Registry.h"
-#include "tao/Thread_Lane_Resources.h"
-#include "tao/Protocol_Factory.h"
-#include "tao/Transport_Acceptor.h"
-#include "tao/Transport_Connector.h"
-#include "tao/Policy_Set.h"
-#include "tao/debug.h"
-#include "tao/CDR.h"
-#include "ace/Dynamic_Service.h"
-#include "ace/OS_NS_string.h"
-#include "tao/Client_Network_Priority_Policy.h"
-
-ACE_RCSID (tao,
- Default_Network_Priority_Protocols_Hooks,
- "$Id$")
-
-TAO_BEGIN_VERSIONED_NAMESPACE_DECL
-
-TAO_Default_Network_Priority_Protocols_Hooks::
-~TAO_Default_Network_Priority_Protocols_Hooks (void)
-{
-}
-
-void
-TAO_Default_Network_Priority_Protocols_Hooks::add_rep_np_service_context_hook (
- TAO_Service_Context &,
- CORBA::Long &
- ACE_ENV_ARG_DECL_NOT_USED)
-{
-}
-
-void
-TAO_Default_Network_Priority_Protocols_Hooks::np_service_context (
- TAO_Stub *,
- TAO_Service_Context &,
- CORBA::Boolean
- ACE_ENV_ARG_DECL_NOT_USED)
-{
-}
-
-void
-TAO_Default_Network_Priority_Protocols_Hooks::set_dscp_codepoint (
- CORBA::Long &
- ACE_ENV_ARG_DECL_NOT_USED)
-{
-}
-
-CORBA::Long
-TAO_Default_Network_Priority_Protocols_Hooks::get_dscp_codepoint (void)
-{
- return 0;
-}
-
-TAO_END_VERSIONED_NAMESPACE_DECL
-
-// ****************************************************************
-
-ACE_STATIC_SVC_DEFINE (TAO_Default_Network_Priority_Protocols_Hooks,
- ACE_TEXT ("Network_Priority_Protocols_Hooks"),
- ACE_SVC_OBJ_T,
- &ACE_SVC_NAME (
- TAO_Default_Network_Priority_Protocols_Hooks),
- ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ,
- 0)
-ACE_FACTORY_DEFINE (TAO, TAO_Default_Network_Priority_Protocols_Hooks)
diff --git a/TAO/tao/Default_Network_Priority_Protocols_Hooks.h b/TAO/tao/Default_Network_Priority_Protocols_Hooks.h
index 09fa9d91647..923b15c5715 100644
--- a/TAO/tao/Default_Network_Priority_Protocols_Hooks.h
+++ b/TAO/tao/Default_Network_Priority_Protocols_Hooks.h
@@ -35,6 +35,9 @@ public:
/// destructor
virtual ~TAO_Default_Network_Priority_Protocols_Hooks (void);
+ void init_hooks (TAO_ORB_Core *orb_core
+ ACE_ENV_ARG_DECL);
+
CORBA::Long get_dscp_codepoint (void);
void set_dscp_codepoint (CORBA::Long &dscp_codepoint
diff --git a/TAO/tao/Default_Policy_Protocols_Hooks.h b/TAO/tao/Default_Policy_Protocols_Hooks.h
index 98420738111..bdab2fb54f0 100644
--- a/TAO/tao/Default_Policy_Protocols_Hooks.h
+++ b/TAO/tao/Default_Policy_Protocols_Hooks.h
@@ -35,6 +35,9 @@ public:
/// destructor
virtual ~TAO_Default_Policy_Protocols_Hooks (void);
+ void init_hooks (TAO_ORB_Core *orb_core
+ ACE_ENV_ARG_DECL);
+
CORBA::Boolean set_client_network_priority (IOP::ProfileId protocol_tag,
TAO_Stub *stub
ACE_ENV_ARG_DECL);
diff --git a/TAO/tao/Default_Protocols_Properties_Protocols_Hooks.h b/TAO/tao/Default_Protocols_Properties_Protocols_Hooks.h
index 1b616db6615..8204e259a18 100644
--- a/TAO/tao/Default_Protocols_Properties_Protocols_Hooks.h
+++ b/TAO/tao/Default_Protocols_Properties_Protocols_Hooks.h
@@ -35,6 +35,9 @@ public:
/// destructor
virtual ~TAO_Default_Protocols_Properties_Protocols_Hooks (void);
+ void init_hooks (TAO_ORB_Core *orb_core
+ ACE_ENV_ARG_DECL);
+
void server_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &protocol_properties
ACE_ENV_ARG_DECL);
diff --git a/TAO/tao/Default_Thread_Priority_Protocols_Hooks.h b/TAO/tao/Default_Thread_Priority_Protocols_Hooks.h
index 85ecee70196..af7717675d5 100644
--- a/TAO/tao/Default_Thread_Priority_Protocols_Hooks.h
+++ b/TAO/tao/Default_Thread_Priority_Protocols_Hooks.h
@@ -35,6 +35,9 @@ public:
/// destructor
virtual ~TAO_Default_Thread_Priority_Protocols_Hooks (void);
+ void init_hooks (TAO_ORB_Core *orb_core
+ ACE_ENV_ARG_DECL);
+
int get_thread_CORBA_priority (CORBA::Short &
ACE_ENV_ARG_DECL);
diff --git a/TAO/tao/Network_Priority_Protocols_Hooks.h b/TAO/tao/Network_Priority_Protocols_Hooks.h
index e4cb8fb7e3d..4cc406c60c0 100644
--- a/TAO/tao/Network_Priority_Protocols_Hooks.h
+++ b/TAO/tao/Network_Priority_Protocols_Hooks.h
@@ -48,6 +48,9 @@ public:
/// destructor
virtual ~TAO_Network_Priority_Protocols_Hooks (void);
+ virtual void init_hooks (TAO_ORB_Core *orb_core
+ ACE_ENV_ARG_DECL) = 0;
+
virtual CORBA::Long get_dscp_codepoint (void) = 0;
virtual void set_dscp_codepoint (CORBA::Long &dscp_codepoint
diff --git a/TAO/tao/Policy_Protocols_Hooks.h b/TAO/tao/Policy_Protocols_Hooks.h
index 536f788d642..4e6d4d44b01 100644
--- a/TAO/tao/Policy_Protocols_Hooks.h
+++ b/TAO/tao/Policy_Protocols_Hooks.h
@@ -48,6 +48,9 @@ public:
/// destructor
virtual ~TAO_Policy_Protocols_Hooks (void);
+ virtual void init_hooks (TAO_ORB_Core *orb_core
+ ACE_ENV_ARG_DECL) = 0;
+
virtual CORBA::Boolean set_client_network_priority (
IOP::ProfileId protocol_tag,
TAO_Stub *stub
diff --git a/TAO/tao/Protocols_Properties_Protocols_Hooks.h b/TAO/tao/Protocols_Properties_Protocols_Hooks.h
index ef2f70f6b77..3a77b73015c 100644
--- a/TAO/tao/Protocols_Properties_Protocols_Hooks.h
+++ b/TAO/tao/Protocols_Properties_Protocols_Hooks.h
@@ -107,6 +107,9 @@ public:
/// destructor
virtual ~TAO_Protocols_Properties_Protocols_Hooks (void);
+ virtual void init_hooks (TAO_ORB_Core *orb_core
+ ACE_ENV_ARG_DECL) = 0;
+
virtual void server_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &protocol_properties
ACE_ENV_ARG_DECL) = 0;
diff --git a/TAO/tao/RTCORBA/RT_Policy_Protocols_Hooks.cpp b/TAO/tao/RTCORBA/RT_Policy_Protocols_Hooks.cpp
new file mode 100644
index 00000000000..c77097fc103
--- /dev/null
+++ b/TAO/tao/RTCORBA/RT_Policy_Protocols_Hooks.cpp
@@ -0,0 +1,886 @@
+#include "tao/RTCORBA/RT_Protocols_Hooks.h"
+
+#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
+
+#include "tao/RTCORBA/RT_Policy_i.h"
+#include "tao/RTCORBA/Priority_Mapping_Manager.h"
+#include "tao/RTCORBA/RT_Stub.h"
+
+#include "tao/Stub.h"
+#include "tao/ORB_Core.h"
+#include "tao/MProfile.h"
+#include "tao/Service_Context.h"
+#include "tao/Acceptor_Registry.h"
+#include "tao/Thread_Lane_Resources.h"
+#include "tao/Protocol_Factory.h"
+#include "tao/Transport_Acceptor.h"
+#include "tao/Transport_Connector.h"
+#include "tao/Policy_Set.h"
+#include "tao/debug.h"
+#include "tao/CDR.h"
+#include "tao/Client_Network_Priority_Policy.h"
+
+#include "ace/Dynamic_Service.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID (RTCORBA,
+ RT_Protocols_Hooks,
+ "$Id$")
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+TAO_RT_Protocols_Hooks::TAO_RT_Protocols_Hooks (void)
+ : orb_core_ (0)
+ , current_ ()
+{
+}
+
+
+TAO_RT_Protocols_Hooks::~TAO_RT_Protocols_Hooks (void)
+{
+}
+
+void
+TAO_RT_Protocols_Hooks::init_hooks (TAO_ORB_Core *orb_core
+ ACE_ENV_ARG_DECL)
+{
+ this->orb_core_ = orb_core;
+
+ // Save a reference to the priority mapping manager.
+ CORBA::Object_var obj =
+ orb_core->object_ref_table ().resolve_initial_reference (
+ TAO_OBJID_PRIORITYMAPPINGMANAGER);
+
+ this->mapping_manager_ =
+ TAO_Priority_Mapping_Manager::_narrow (obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ // Save a reference to the priority mapping manager.
+ CORBA::Object_var object =
+ orb_core->object_ref_table ().resolve_initial_reference (
+ TAO_OBJID_NETWORKPRIORITYMAPPINGMANAGER);
+
+ this->network_mapping_manager_ =
+ TAO_Network_Priority_Mapping_Manager::_narrow (object.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ object =
+ this->orb_core_->object_ref_table ().resolve_initial_reference (
+ TAO_OBJID_RTCURRENT);
+
+ this->current_ =
+ RTCORBA::Current::_narrow (object.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+}
+
+RTCORBA::ProtocolProperties_ptr
+TAO_RT_Protocols_Hooks::server_protocol_properties (IOP::ProfileId protocol_tag,
+ CORBA::Policy_ptr policy
+ ACE_ENV_ARG_DECL)
+{
+ if (CORBA::is_nil (policy))
+ return 0;
+
+ RTCORBA::ServerProtocolPolicy_var server_protocol_policy =
+ RTCORBA::ServerProtocolPolicy::_narrow (policy
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ if (CORBA::is_nil (server_protocol_policy.in ()))
+ return 0;
+
+ TAO_ServerProtocolPolicy *server_protocols =
+ dynamic_cast<TAO_ServerProtocolPolicy *> (server_protocol_policy.in ());
+
+ if (server_protocols == 0)
+ return 0;
+
+ // TAO_ServerProtocolPolicy
+ RTCORBA::ProtocolList &protocols =
+ server_protocols->protocols_rep ();
+
+ for (CORBA::ULong j = 0; j < protocols.length (); ++j)
+ {
+ if (protocols[j].protocol_type == protocol_tag)
+ {
+ return RTCORBA::ProtocolProperties::_duplicate (protocols[j].transport_protocol_properties.in ());
+ }
+ }
+
+ return 0;
+}
+
+RTCORBA::ProtocolProperties_ptr
+TAO_RT_Protocols_Hooks::client_protocol_properties (IOP::ProfileId protocol_tag,
+ CORBA::Policy_ptr policy
+ ACE_ENV_ARG_DECL)
+{
+ if (CORBA::is_nil (policy))
+ return 0;
+
+ RTCORBA::ClientProtocolPolicy_var client_protocol_policy =
+ RTCORBA::ClientProtocolPolicy::_narrow (policy
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ if (CORBA::is_nil (client_protocol_policy.in ()))
+ return 0;
+
+ TAO_ClientProtocolPolicy *client_protocols =
+ dynamic_cast<TAO_ClientProtocolPolicy *> (client_protocol_policy.in ());
+
+ if (client_protocols == 0)
+ return 0;
+
+ // TAO_ClientProtocolPolicy
+ RTCORBA::ProtocolList &protocols =
+ client_protocols->protocols_rep ();
+
+ for (CORBA::ULong j = 0; j < protocols.length (); ++j)
+ {
+ if (protocols[j].protocol_type == protocol_tag)
+ {
+ return RTCORBA::ProtocolProperties::_duplicate (protocols[j].transport_protocol_properties.in ());
+ }
+ }
+
+ return 0;
+}
+
+RTCORBA::ProtocolProperties_ptr
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ return this->server_protocol_properties (protocol_tag,
+ policy.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+RTCORBA::ProtocolProperties_ptr
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ return this->client_protocol_properties (protocol_tag,
+ policy.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+RTCORBA::ProtocolProperties_ptr
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ return this->client_protocol_properties (protocol_tag,
+ policy.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ to.send_buffer_size_ = protocol_properties->send_buffer_size ();
+ to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
+ to.keep_alive_ = protocol_properties->keep_alive ();
+ to.dont_route_ = protocol_properties->dont_route ();
+ to.no_delay_ = protocol_properties->no_delay ();
+ to.enable_network_priority_ = protocol_properties->enable_network_priority ();
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ to.send_buffer_size_ = protocol_properties->send_buffer_size ();
+ to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ to.preallocate_buffer_size_ = protocol_properties->preallocate_buffer_size ();
+ to.mmap_filename_ = protocol_properties->mmap_filename ();
+ to.mmap_lockname_ = protocol_properties->mmap_lockname ();
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ to.enable_network_priority_ = protocol_properties->enable_network_priority ();
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ to.send_buffer_size_ = protocol_properties->send_buffer_size ();
+ to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
+ to.keep_alive_ = protocol_properties->keep_alive ();
+ to.dont_route_ = protocol_properties->dont_route ();
+ to.no_delay_ = protocol_properties->no_delay ();
+ to.enable_network_priority_ = protocol_properties->enable_network_priority ();
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ 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<TAO_RT_Stub *> (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<TAO_PriorityModelPolicy *> (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<TAO_PriorityModelPolicy *> (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<TAO_PriorityBandedConnectionPolicy *> (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_SVC_OBJ_T,
+ &ACE_SVC_NAME (TAO_RT_Protocols_Hooks),
+ ACE_Service_Type::DELETE_THIS
+ | ACE_Service_Type::DELETE_OBJ,
+ 0)
+ACE_FACTORY_DEFINE (TAO_RTCORBA, TAO_RT_Protocols_Hooks)
+
+#endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */
diff --git a/TAO/tao/RTCORBA/RT_Protocols_Properties_Protocols_Hooks.cpp b/TAO/tao/RTCORBA/RT_Protocols_Properties_Protocols_Hooks.cpp
new file mode 100644
index 00000000000..c77097fc103
--- /dev/null
+++ b/TAO/tao/RTCORBA/RT_Protocols_Properties_Protocols_Hooks.cpp
@@ -0,0 +1,886 @@
+#include "tao/RTCORBA/RT_Protocols_Hooks.h"
+
+#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
+
+#include "tao/RTCORBA/RT_Policy_i.h"
+#include "tao/RTCORBA/Priority_Mapping_Manager.h"
+#include "tao/RTCORBA/RT_Stub.h"
+
+#include "tao/Stub.h"
+#include "tao/ORB_Core.h"
+#include "tao/MProfile.h"
+#include "tao/Service_Context.h"
+#include "tao/Acceptor_Registry.h"
+#include "tao/Thread_Lane_Resources.h"
+#include "tao/Protocol_Factory.h"
+#include "tao/Transport_Acceptor.h"
+#include "tao/Transport_Connector.h"
+#include "tao/Policy_Set.h"
+#include "tao/debug.h"
+#include "tao/CDR.h"
+#include "tao/Client_Network_Priority_Policy.h"
+
+#include "ace/Dynamic_Service.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID (RTCORBA,
+ RT_Protocols_Hooks,
+ "$Id$")
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+TAO_RT_Protocols_Hooks::TAO_RT_Protocols_Hooks (void)
+ : orb_core_ (0)
+ , current_ ()
+{
+}
+
+
+TAO_RT_Protocols_Hooks::~TAO_RT_Protocols_Hooks (void)
+{
+}
+
+void
+TAO_RT_Protocols_Hooks::init_hooks (TAO_ORB_Core *orb_core
+ ACE_ENV_ARG_DECL)
+{
+ this->orb_core_ = orb_core;
+
+ // Save a reference to the priority mapping manager.
+ CORBA::Object_var obj =
+ orb_core->object_ref_table ().resolve_initial_reference (
+ TAO_OBJID_PRIORITYMAPPINGMANAGER);
+
+ this->mapping_manager_ =
+ TAO_Priority_Mapping_Manager::_narrow (obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ // Save a reference to the priority mapping manager.
+ CORBA::Object_var object =
+ orb_core->object_ref_table ().resolve_initial_reference (
+ TAO_OBJID_NETWORKPRIORITYMAPPINGMANAGER);
+
+ this->network_mapping_manager_ =
+ TAO_Network_Priority_Mapping_Manager::_narrow (object.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ object =
+ this->orb_core_->object_ref_table ().resolve_initial_reference (
+ TAO_OBJID_RTCURRENT);
+
+ this->current_ =
+ RTCORBA::Current::_narrow (object.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+}
+
+RTCORBA::ProtocolProperties_ptr
+TAO_RT_Protocols_Hooks::server_protocol_properties (IOP::ProfileId protocol_tag,
+ CORBA::Policy_ptr policy
+ ACE_ENV_ARG_DECL)
+{
+ if (CORBA::is_nil (policy))
+ return 0;
+
+ RTCORBA::ServerProtocolPolicy_var server_protocol_policy =
+ RTCORBA::ServerProtocolPolicy::_narrow (policy
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ if (CORBA::is_nil (server_protocol_policy.in ()))
+ return 0;
+
+ TAO_ServerProtocolPolicy *server_protocols =
+ dynamic_cast<TAO_ServerProtocolPolicy *> (server_protocol_policy.in ());
+
+ if (server_protocols == 0)
+ return 0;
+
+ // TAO_ServerProtocolPolicy
+ RTCORBA::ProtocolList &protocols =
+ server_protocols->protocols_rep ();
+
+ for (CORBA::ULong j = 0; j < protocols.length (); ++j)
+ {
+ if (protocols[j].protocol_type == protocol_tag)
+ {
+ return RTCORBA::ProtocolProperties::_duplicate (protocols[j].transport_protocol_properties.in ());
+ }
+ }
+
+ return 0;
+}
+
+RTCORBA::ProtocolProperties_ptr
+TAO_RT_Protocols_Hooks::client_protocol_properties (IOP::ProfileId protocol_tag,
+ CORBA::Policy_ptr policy
+ ACE_ENV_ARG_DECL)
+{
+ if (CORBA::is_nil (policy))
+ return 0;
+
+ RTCORBA::ClientProtocolPolicy_var client_protocol_policy =
+ RTCORBA::ClientProtocolPolicy::_narrow (policy
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ if (CORBA::is_nil (client_protocol_policy.in ()))
+ return 0;
+
+ TAO_ClientProtocolPolicy *client_protocols =
+ dynamic_cast<TAO_ClientProtocolPolicy *> (client_protocol_policy.in ());
+
+ if (client_protocols == 0)
+ return 0;
+
+ // TAO_ClientProtocolPolicy
+ RTCORBA::ProtocolList &protocols =
+ client_protocols->protocols_rep ();
+
+ for (CORBA::ULong j = 0; j < protocols.length (); ++j)
+ {
+ if (protocols[j].protocol_type == protocol_tag)
+ {
+ return RTCORBA::ProtocolProperties::_duplicate (protocols[j].transport_protocol_properties.in ());
+ }
+ }
+
+ return 0;
+}
+
+RTCORBA::ProtocolProperties_ptr
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ return this->server_protocol_properties (protocol_tag,
+ policy.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+RTCORBA::ProtocolProperties_ptr
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ return this->client_protocol_properties (protocol_tag,
+ policy.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+RTCORBA::ProtocolProperties_ptr
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK_RETURN (0);
+
+ return this->client_protocol_properties (protocol_tag,
+ policy.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ to.send_buffer_size_ = protocol_properties->send_buffer_size ();
+ to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
+ to.keep_alive_ = protocol_properties->keep_alive ();
+ to.dont_route_ = protocol_properties->dont_route ();
+ to.no_delay_ = protocol_properties->no_delay ();
+ to.enable_network_priority_ = protocol_properties->enable_network_priority ();
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ to.send_buffer_size_ = protocol_properties->send_buffer_size ();
+ to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ to.preallocate_buffer_size_ = protocol_properties->preallocate_buffer_size ();
+ to.mmap_filename_ = protocol_properties->mmap_filename ();
+ to.mmap_lockname_ = protocol_properties->mmap_lockname ();
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ to.enable_network_priority_ = protocol_properties->enable_network_priority ();
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ to.send_buffer_size_ = protocol_properties->send_buffer_size ();
+ to.recv_buffer_size_ = protocol_properties->recv_buffer_size ();
+ to.keep_alive_ = protocol_properties->keep_alive ();
+ to.dont_route_ = protocol_properties->dont_route ();
+ to.no_delay_ = protocol_properties->no_delay ();
+ to.enable_network_priority_ = protocol_properties->enable_network_priority ();
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+}
+
+void
+TAO_RT_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
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ if (!CORBA::is_nil (from.in ()))
+ this->extract_protocol_properties (to,
+ from.in ()
+ 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<TAO_RT_Stub *> (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<TAO_PriorityModelPolicy *> (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<TAO_PriorityModelPolicy *> (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<TAO_PriorityBandedConnectionPolicy *> (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_SVC_OBJ_T,
+ &ACE_SVC_NAME (TAO_RT_Protocols_Hooks),
+ ACE_Service_Type::DELETE_THIS
+ | ACE_Service_Type::DELETE_OBJ,
+ 0)
+ACE_FACTORY_DEFINE (TAO_RTCORBA, TAO_RT_Protocols_Hooks)
+
+#endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */
diff --git a/TAO/tao/RTCORBA/RT_Thread_Priority_Protocols_Hooks.cpp b/TAO/tao/RTCORBA/RT_Thread_Priority_Protocols_Hooks.cpp
new file mode 100644
index 00000000000..0cf9604bb6d
--- /dev/null
+++ b/TAO/tao/RTCORBA/RT_Thread_Priority_Protocols_Hooks.cpp
@@ -0,0 +1,207 @@
+#include "tao/RTCORBA/RT_Protocols_Hooks.h"
+
+#if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
+
+#include "tao/RTCORBA/RT_Policy_i.h"
+#include "tao/RTCORBA/Priority_Mapping_Manager.h"
+#include "tao/RTCORBA/RT_Stub.h"
+
+#include "tao/Stub.h"
+#include "tao/ORB_Core.h"
+#include "tao/MProfile.h"
+#include "tao/Service_Context.h"
+#include "tao/Acceptor_Registry.h"
+#include "tao/Thread_Lane_Resources.h"
+#include "tao/Protocol_Factory.h"
+#include "tao/Transport_Acceptor.h"
+#include "tao/Transport_Connector.h"
+#include "tao/Policy_Set.h"
+#include "tao/debug.h"
+#include "tao/CDR.h"
+#include "tao/Client_Network_Priority_Policy.h"
+
+#include "ace/Dynamic_Service.h"
+#include "ace/OS_NS_string.h"
+
+ACE_RCSID (RTCORBA,
+ RT_Protocols_Hooks,
+ "$Id$")
+
+TAO_BEGIN_VERSIONED_NAMESPACE_DECL
+
+TAO_RT_Protocols_Hooks::TAO_RT_Protocols_Hooks (void)
+ : orb_core_ (0)
+ , current_ ()
+{
+}
+
+
+TAO_RT_Protocols_Hooks::~TAO_RT_Protocols_Hooks (void)
+{
+}
+
+void
+TAO_RT_Protocols_Hooks::init_hooks (TAO_ORB_Core *orb_core
+ ACE_ENV_ARG_DECL)
+{
+ this->orb_core_ = orb_core;
+
+ // Save a reference to the priority mapping manager.
+ CORBA::Object_var obj =
+ orb_core->object_ref_table ().resolve_initial_reference (
+ TAO_OBJID_PRIORITYMAPPINGMANAGER);
+
+ this->mapping_manager_ =
+ TAO_Priority_Mapping_Manager::_narrow (obj.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ // Save a reference to the priority mapping manager.
+ CORBA::Object_var object =
+ orb_core->object_ref_table ().resolve_initial_reference (
+ TAO_OBJID_NETWORKPRIORITYMAPPINGMANAGER);
+
+ this->network_mapping_manager_ =
+ TAO_Network_Priority_Mapping_Manager::_narrow (object.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+ object =
+ this->orb_core_->object_ref_table ().resolve_initial_reference (
+ TAO_OBJID_RTCURRENT);
+
+ this->current_ =
+ RTCORBA::Current::_narrow (object.in ()
+ ACE_ENV_ARG_PARAMETER);
+ ACE_CHECK;
+
+}
+
+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_SVC_OBJ_T,
+ &ACE_SVC_NAME (TAO_RT_Protocols_Hooks),
+ ACE_Service_Type::DELETE_THIS
+ | ACE_Service_Type::DELETE_OBJ,
+ 0)
+ACE_FACTORY_DEFINE (TAO_RTCORBA, TAO_RT_Protocols_Hooks)
+
+#endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */
diff --git a/TAO/tao/Thread_Priority_Protocols_Hooks.h b/TAO/tao/Thread_Priority_Protocols_Hooks.h
index bfc0e1c0659..6026131dff4 100644
--- a/TAO/tao/Thread_Priority_Protocols_Hooks.h
+++ b/TAO/tao/Thread_Priority_Protocols_Hooks.h
@@ -47,6 +47,9 @@ class TAO_Export TAO_Thread_Priority_Protocols_Hooks
public:
/// destructor
virtual ~TAO_Thread_Priority_Protocols_Hooks (void);
+
+ virtual void init_hooks (TAO_ORB_Core *orb_core
+ ACE_ENV_ARG_DECL) = 0;
virtual int get_thread_CORBA_priority (CORBA::Short &
ACE_ENV_ARG_DECL) = 0;