diff options
author | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-10-21 21:59:52 +0000 |
---|---|---|
committer | irfan <irfan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2004-10-21 21:59:52 +0000 |
commit | f7ca4c0854cf94c6bf5e69b8d5a919795a2d9f6c (patch) | |
tree | fec747497baeab661b6a5ca59aaf78cc8b295d71 | |
parent | 276688a04a2889118cfea05d4ca352ea421e3379 (diff) | |
download | ATCD-f7ca4c0854cf94c6bf5e69b8d5a919795a2d9f6c.tar.gz |
ChangeLogTag: Thu Oct 21 17:55:19 2004 Irfan Pyarali <irfan@oomworks.com>
34 files changed, 893 insertions, 457 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index f1a0cf1c2ff..6540cd8dc68 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,171 @@ +Thu Oct 21 17:55:19 2004 Irfan Pyarali <irfan@oomworks.com> + + The following changes allow the user to specify the endpoints + that will be used by thread pools and lanes. Previously, only + default endpoints were supported. With this addition, POAs that + use thread pools will be able to support persistent references. + Many thanks to Lothar Werzinger <lothar@xcerla.com> for helping + with this and for providing the initial patches. + + * tao/params.{h,cpp}: + + The endpoints were stored in an unbounded queue. Since we are + adding the capability to specify and store endpoints for each + thread lane, this one queue is insufficient. One solution would + be to have a mapping to lane id to an unbounded queue of + endpoints. The only drawback of this is that it would increase + the footprint of TAO since a new kind of map would be required. + To circumvent this issue, the map is going to be a parameterized + with strings. This kind of map is already used in TAO so no + footprint increase will occur. The endpoints will be + concatinated into one big string, and then when needed, + converted into an unbounded queue of endpoints. + + The following methods were effected by this change: + + - endpoints(string) is now add_endpoints(). + - endpoints(void) is now get_endpoint_set(). + - add_endpoint() is removed. + - parse_endpoints() is now parse_and_add_endpoints() + + * tao/Acceptor_Registry.{h,cpp} (open): + + - The Acceptor Registry no longer looks up the <endpoint_set> it + is going to use. This set is now passed into open(). + + - Evaluation and parsing of the TAO_ORBENDPOINT environment + variable is now conducted in ORB_init() instead of in open() + since this environment variable only effects the ORB endpoints + of the default lane. + + - No need to call reset() on the endpoint set. This is done + automatically done in the destructor. + + - <ignore_address> was changed to a bool from an int. + + * tao/ORB_Core.cpp (init): + + - -ORBEndpoint and -ORBListenEndpoints options only apply to the + default lane. + + - -ORBLaneEndpoint and -ORBLaneListenEndpoints options apply to + the thread lanes. + + - Evaluation and parsing of the TAO_ORBENDPOINT environment + variable is now conducted in ORB_init() instead of in the + Acceptor Registry since this environment variable only effects + the ORB endpoints of the default lane. + + * tao/RTPortableServer/RT_Policy_Validator.cpp: + + - TAO_POA_RT_Policy_Validator::extract_acceptor_registry() was + flawed for thread pools with multiple lanes. It picked the + Acceptor Registry from the first lane on the assumption that all + lanes had similar acceptor registries. This assumption is no + longer true. + + - <acceptor_registry_> is no longer kept as a member. Also note + that though <thread_pool_> is kept as a member, it is + reevaluated every time policies are parsed. + + - validate_lifespan() is removed since thread pools now support + specification of endpoint and hence persistent references. + + - In validate_server_protocol(), if the server protocol policy + has not been specified, then add a server policy that reflects + the protocols supported by the acceptor registries of the POA's + thread pool. + + - In validate_server_protocol(), acceptor registries in all the + thread lanes should be evaluated. + + - server_protocol_policy_from_thread_pool() and + server_protocol_policy_from_acceptor_registry() were added. + + * tao/RTCORBA/Thread_Pool.cpp (open): + + Look up the endpoints for a lane. If endpoints are not specified + for a lane, use the endpoints specified for the default lane but + ignore their addresses. If endpoints are specified for a lane, + use them with their addresses. + + * tao/PortableServer/Object_Adapter.cpp (open): + + Validation of Root POA policies was missing. It was added. + + * tao/Default_Thread_Lane_Resources_Manager.cpp (open_default_resources): + * tao/RTCORBA/RT_Thread_Lane_Resources_Manager.cpp (open_default_resources): + + Look of endpoints for the default lane is moved here instead of + being done in the Acceptor Registry. + + * tao/Protocols_Hooks.h: + * tao/Default_Protocols_Hooks.{h,cpp}: + * tao/RTCORBA/RT_Protocols_Hooks.{h,cpp}: + * tao/PortableServer/Object_Adapter.{h,cpp} (open): + + It doesn't make sense to set a server protocol policy as an ORB + default since each POA's default server protocol should be the + protocols supported by its Acceptor Registry. Therefore, + set_default_server_protocol_policy() is no longer needed and is + removed. + + * tao/RTPortableServer/RT_POA.cpp (key_to_stub_i): + + Removal of the flawed function + TAO_POA_RT_Policy_Validator::extract_acceptor_registry() forced + a rewrite of some code here. + + * tao\orbconf.h (TAO_DEFAULT_LANE): + + Macro for the default lane name used when storing endpoints. + + * tao/RTCORBA/RT_Policy_i.cpp (_tao_scope): + + The TAO_POLICY_CLIENT_EXPOSED scope of PriorityModelPolicy was + removed. The following comment in the _tao_scope() states the + issue correctly: + + // Note that this policy is propogated to the client even though + // it is not specified here. The reason for this is that the + // server priority field is set dynamically depending on the model + // and the servant's priority. Therefore, it can't be simply + // copied to the list of client exposed policies. + + So I am not sure why I added this scope back in Aug 2002. With + this addition, the PriorityModelPolicy gets added twice, with + one of the additions being incorrect. + + * tao/Strategies/DIOP_Acceptor.cpp (open_default): + + ACE_DEFAULT_SERVER_PORT should not be fixed. 0 should be used, + similar to what happens in IIOP. + + * tao/PortableServer/Object_Adapter.cpp: + + Service name of TAO_Object_Adapter_Factory was changed from + "TAO_POA" to "PortableServer". + + * tao/RTPortableServer/RT_Object_Adapter_Factory.cpp: + + Service name of TAO_RT_Object_Adapter_Factory was changed from + "TAO_RT_POA" to "RTPortableServer". + + * tests/RTCORBA/Server_Protocol: + + Server policy is checked at the Root POA instead of ORB default + policies. + + * tests/RTCORBA/Persistent_IOR: + + Updated test to check that persistent POAs are properly + supported even when being used with thread pools and lanes. + + * docs/Options.html: + + Updated documentation to explain new -ORBLaneListenEndpoints and + -ORBLaneEndpoint options. + Thu Oct 21 13:20:59 2004 Iliyan Jeliazkov <jeliazkov_i@ociweb.com> * tests/Big_Reply/Client_Task.cpp: diff --git a/TAO/docs/Options.html b/TAO/docs/Options.html index baa2dc38466..2bd6e938d69 100644 --- a/TAO/docs/Options.html +++ b/TAO/docs/Options.html @@ -453,40 +453,97 @@ since domain names are the standard address notation for IORs.</td> </tr> <tr> <td><code>-ORBEndpoint</code> <em>endpoint</em></td> - <td><a name="-ORBEndpoint"></a>This option is similar to the <code>-ORBListenEndPoints</code> -option described below. <font color="red">This option will be -deprecated in later versions on TAO since the CORBA specification now -defines the <code>-ORBListenEndpoints</code> option instead. </font> </td> + <td><a name="-ORBEndpoint"></a>This option is same as the <a + href="#-ORBListenEndpoints"><code>-ORBListenEndPoints</code></a> + option described below. <font color="red">This option will be + deprecated in later versions on TAO since the CORBA + specification now defines the <code>-ORBListenEndpoints</code> + option instead. </font> </td> </tr> <tr> <td><code>-ORBListenEndpoints</code> <em>endpoint</em></td> <td><a name="-ORBListenEndpoints"></a> This option was -introduced with the CORBA <a - href="http://cgi.omg.org/docs/orbos/01-01-04.pdf"> ORT </a> (Object -Reference Template) specification. It instructs a server ORB to listen -for requests on the interface specified by <code>endpoint</code>. TAO <a - href="ORBEndpoint.html"> endpoints</a> are specified using a URL style -format. An endpoint has the form: - <blockquote><code>protocol://V.v@addr1,...,W.w@addrN </code></blockquote> -where <code>V.v</code> and <code>W.w</code> are optional protocol -versions for each address. An example of an IIOP endpoint is: + introduced with the CORBA <a + href="http://cgi.omg.org/docs/orbos/01-01-04.pdf"> ORT </a> + (Object Reference Template) specification. It instructs a + server ORB to listen for requests on the interface specified + by <code>endpoint</code>. When used with RT-CORBA, the option + specifies the endpoints that the default thread pool listens + to. TAO endpoints are specified using a URL style format. An + endpoint has the form: + <blockquote><code>protocol://V.v@addr1,...,W.w@addrN + </code></blockquote> where <code>V.v</code> and + <code>W.w</code> are optional protocol versions for each + address. An example of an IIOP endpoint is: <blockquote><code>iiop://<i><em>hostname</em></i>:<i><em>port</em></i> - </code></blockquote> -Sets of endpoints may be specified using multiple <code>-ORBEndpoint</code> -options or by delimiting endpoints with a semi-colon (;). For example, - <blockquote><code>-ORBEndpoint iiop://localhost:9999 --ORBEndpoint uiop:///tmp/mylocalsock -ORBEndpoint shmiop://10002 </code></blockquote> -is equivalent to: - <blockquote><code>-ORBEndpoint -'iiop://localhost:9999;uiop:///tmp/mylocalsock;shmiop://10002' </code></blockquote> -Notice the single quotes (') in the latter option specification. Single -quotes are needed to prevent the shell from interpreting text after the -semi-colon as another command to run. - <p>If an endpoint is specified without an <code>addr</code> -such as the following: </p> - <blockquote><code>-ORBEndpoint uiop:// -ORBEndpoint shmiop:// </code></blockquote> -then a default endpoint will be created for the specified protocol. - <p></p> + </code></blockquote> + + Sets of endpoints may be specified using multiple + <code>-ORBListenEndpoints</code> options or by delimiting + endpoints with a semi-colon (;). For example, + <blockquote><code>-ORBListenEndpoints iiop://localhost:9999 + -ORBListenEndpoints uiop:///tmp/mylocalsock + -ORBListenEndpoints shmiop://10002 </code></blockquote> is + equivalent to: <blockquote><code>-ORBListenEndpoints + 'iiop://localhost:9999;uiop:///tmp/mylocalsock;shmiop://10002' + </code></blockquote> Notice the single quotes (') in the + latter option specification. Single quotes are needed to + prevent the shell from interpreting text after the semi-colon + as another command to run. <p>If an endpoint is specified + without an <code>addr</code> such as the following: </p> + <blockquote><code>-ORBListenEndpoints uiop:// + -ORBListenEndpoints shmiop:// </code></blockquote> then a + default endpoint will be created for the specified + protocol. <p> + + Click <a href="ORBEndpoint.html"> here</a> for much more on + how to specify endpoints. + </td> + </tr> + <tr> + <td><code>-ORBLaneEndpoint</code> <em>endpoint</em></td> + <td><a name="-ORBLaneEndpoint"></a>This option is same as the + <a + href="#-ORBLaneListenEndpoints"><code>-ORBLaneListenEndPoints</code></a> + option described below. <font color="red">This option will be + deprecated in later versions on TAO.</font> + </td> + </tr> + <tr> + <td><code>-ORBLaneListenEndpoints</code> + <em>thread-pool-id:thread-lane-id endpoint</em></td> <td><a + name="-ORBLaneListenEndpoints"></a> This option allows the + user to specify endpoints for thread pools and lanes. This + option is only meaningful when used with RT-CORBA and only + makes sense when the thread pools and lanes are created in the + same order across server incarnations. See <a + href="#-ORBListenEndpoints"><code>-ORBListenEndPoints</code></a> + option on how to specify endpoints. An example is: + <blockquote><code>2:3 iiop://localhost:2345 + </code></blockquote> where <code>2</code> specifies the second + thread pool created by the process and <code>3</code> + specifies the third lane of that thread pool. Note that + <code>0</code> should be used for the lane when specifying + endpoints for thread pools without lanes. + + <p>Sets of endpoints may be specified using multiple + <code>-ORBLaneListenEndpoints</code> options or by delimiting + endpoints with a semi-colon (;). For example, + <blockquote><code>-ORBLaneListenEndpoints 1:4 + iiop://localhost:9999 -ORBLaneListenEndpoints 1:4 + uiop:///tmp/mylocalsock -ORBLaneListenEndpoints 1:4 + shmiop://10002 </code></blockquote> is equivalent to: + <blockquote><code>-ORBLaneListenEndpoints 1:4 + 'iiop://localhost:9999;uiop:///tmp/mylocalsock;shmiop://10002' + </code></blockquote> Notice the single quotes (') in the + latter option specification. Single quotes are needed to + prevent the shell from interpreting text after the semi-colon + as another command to run. <p>If an endpoint is specified + without an <code>addr</code> such as the following: </p> + <blockquote><code>-ORBLaneListenEndpoints 2:3 uiop:// + -ORBLaneListenEndpoints 2:3 shmiop:// </code></blockquote> + then a default endpoint will be created for the specified + protocol. </td> </tr> <tr> diff --git a/TAO/tao/Acceptor_Registry.cpp b/TAO/tao/Acceptor_Registry.cpp index 0508d97bbc8..df425a921c5 100644 --- a/TAO/tao/Acceptor_Registry.cpp +++ b/TAO/tao/Acceptor_Registry.cpp @@ -117,21 +117,10 @@ TAO_Acceptor_Registry::get_acceptor (CORBA::ULong tag) int TAO_Acceptor_Registry::open (TAO_ORB_Core *orb_core, ACE_Reactor *reactor, - int ignore_address + const TAO_EndpointSet &endpoint_set, + bool ignore_address ACE_ENV_ARG_DECL) { - // protocol_factories is in the following form - // IOP1://addr1,addr2,...,addrN/;IOP2://addr1,...addrM/;... - TAO_EndpointSet endpoint_set = orb_core->orb_params ()->endpoints (); - - // Check to see if there is an additional endpoint value defined - // as an environment property. - ACE_CString env_endpoint = ACE_OS::getenv ("TAO_ORBENDPOINT"); - if (ACE_OS::strcmp (env_endpoint.c_str(), "") != 0) - { - endpoint_set.enqueue_tail (env_endpoint); - } - if (endpoint_set.is_empty () // No endpoints were specified, we let each protocol pick its // own default. @@ -151,7 +140,7 @@ TAO_Acceptor_Registry::open (TAO_ORB_Core *orb_core, // Count the maximum number of endpoints in the set. This will be // the maximum number of acceptors that need to be created. size_t acceptor_count = 0; - TAO_EndpointSetIterator endpts = endpoint_set.begin (); + TAO_EndpointSetIterator endpts (endpoint_set); for (ACE_CString *ep = 0; endpts.next (ep) != 0; @@ -212,7 +201,7 @@ TAO_Acceptor_Registry::open (TAO_ORB_Core *orb_core, ACE_CHECK_RETURN (-1); } - TAO_EndpointSetIterator endpoints = endpoint_set.begin (); + TAO_EndpointSetIterator endpoints (endpoint_set); for (ACE_CString *endpoint = 0; endpoints.next (endpoint) != 0; @@ -304,11 +293,6 @@ TAO_Acceptor_Registry::open (TAO_ORB_Core *orb_core, } } - // No longer need the endpoint set since all associated acceptors - // have been opened by now. Reclaim the memory used by the endpoint - // set. - endpoint_set.reset (); - return 0; } @@ -506,8 +490,8 @@ TAO_Acceptor_Registry::open_i (TAO_ORB_Core *orb_core, ACE_Reactor *reactor, ACE_CString &addrs, TAO_ProtocolFactorySetItor &factory, - int ignore_address - ACE_ENV_ARG_DECL) + bool ignore_address + ACE_ENV_ARG_DECL) { ACE_CString options_tmp; this->extract_endpoint_options (addrs, diff --git a/TAO/tao/Acceptor_Registry.h b/TAO/tao/Acceptor_Registry.h index 6c3e0694ffa..3ee4358174b 100644 --- a/TAO/tao/Acceptor_Registry.h +++ b/TAO/tao/Acceptor_Registry.h @@ -25,6 +25,7 @@ #include "tao/TAO_Export.h" #include "tao/Exception.h" +#include "tao/params.h" // Forward declarations. class ACE_Addr; @@ -67,7 +68,8 @@ public: /// Initialize all registered acceptors. Return -1 on error. int open (TAO_ORB_Core *orb_core, ACE_Reactor *reactor, - int ignore_address + const TAO_EndpointSet &endpoint_set, + bool ignore_address ACE_ENV_ARG_DECL); /// Close all open acceptors. @@ -119,7 +121,7 @@ private: ACE_Reactor *reactor, ACE_CString &address, TAO_ProtocolFactorySetItor &factory, - int ignore_address + bool ignore_address ACE_ENV_ARG_DECL); private: diff --git a/TAO/tao/Default_Protocols_Hooks.cpp b/TAO/tao/Default_Protocols_Hooks.cpp index 063dcc289e3..4d63fe196be 100644 --- a/TAO/tao/Default_Protocols_Hooks.cpp +++ b/TAO/tao/Default_Protocols_Hooks.cpp @@ -86,13 +86,6 @@ TAO_Default_Protocols_Hooks::set_thread_native_priority (CORBA::Short return 0; } -int -TAO_Default_Protocols_Hooks::set_default_server_protocol_policy (TAO_Acceptor_Registry & - ACE_ENV_ARG_DECL_NOT_USED) -{ - return 0; -} - void TAO_Default_Protocols_Hooks::rt_service_context (TAO_Stub *, TAO_Service_Context &, @@ -101,7 +94,7 @@ TAO_Default_Protocols_Hooks::rt_service_context (TAO_Stub *, { } -CORBA::Boolean +CORBA::Boolean TAO_Default_Protocols_Hooks::set_client_network_priority (IOP::ProfileId, TAO_Stub * ACE_ENV_ARG_DECL_NOT_USED) @@ -109,7 +102,7 @@ TAO_Default_Protocols_Hooks::set_client_network_priority (IOP::ProfileId, return false; } -CORBA::Boolean +CORBA::Boolean TAO_Default_Protocols_Hooks::set_server_network_priority (IOP::ProfileId, CORBA::Policy * ACE_ENV_ARG_DECL_NOT_USED) diff --git a/TAO/tao/Default_Protocols_Hooks.h b/TAO/tao/Default_Protocols_Hooks.h index 21bfb4c26d4..8f3af3eca6f 100644 --- a/TAO/tao/Default_Protocols_Hooks.h +++ b/TAO/tao/Default_Protocols_Hooks.h @@ -34,7 +34,7 @@ public: 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); @@ -45,63 +45,63 @@ public: void server_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void client_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void server_protocol_properties_at_orb_level (TAO_UIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void client_protocol_properties_at_orb_level (TAO_UIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void server_protocol_properties_at_orb_level (TAO_SHMIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void client_protocol_properties_at_orb_level (TAO_SHMIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void server_protocol_properties_at_orb_level (TAO_DIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void client_protocol_properties_at_orb_level (TAO_DIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void server_protocol_properties_at_orb_level (TAO_SCIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void client_protocol_properties_at_orb_level (TAO_SCIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + CORBA::Long get_dscp_codepoint (void); - + void rt_service_context (TAO_Stub *stub, TAO_Service_Context &service_context, CORBA::Boolean restart ACE_ENV_ARG_DECL); - + void add_rt_service_context_hook (TAO_Service_Context &service_context, CORBA::Policy *model_policy, CORBA::Short &client_priority ACE_ENV_ARG_DECL); - + void get_selector_hook (CORBA::Policy *model_policy, CORBA::Boolean &is_client_propagated, CORBA::Short &server_priority); - + void get_selector_bands_policy_hook (CORBA::Policy *bands_policy, CORBA::Short p, CORBA::Short &min_priority, CORBA::Short &max_priority, int &in_range); - + int get_thread_CORBA_priority (CORBA::Short & ACE_ENV_ARG_DECL); - + int get_thread_native_priority (CORBA::Short & ACE_ENV_ARG_DECL); - + int get_thread_CORBA_and_native_priority (CORBA::Short &, CORBA::Short & ACE_ENV_ARG_DECL); @@ -111,10 +111,6 @@ public: int set_thread_native_priority (CORBA::Short ACE_ENV_ARG_DECL); - - int set_default_server_protocol_policy (TAO_Acceptor_Registry &acceptor_registry - ACE_ENV_ARG_DECL); - }; #if defined (__ACE_INLINE__) diff --git a/TAO/tao/Default_Thread_Lane_Resources_Manager.cpp b/TAO/tao/Default_Thread_Lane_Resources_Manager.cpp index c799e6be17f..03875d6d3dd 100644 --- a/TAO/tao/Default_Thread_Lane_Resources_Manager.cpp +++ b/TAO/tao/Default_Thread_Lane_Resources_Manager.cpp @@ -4,6 +4,7 @@ #include "Thread_Lane_Resources.h" #include "Exception.h" #include "Environment.h" +#include "ORB_Core.h" #include "ace/Log_Msg.h" @@ -34,8 +35,19 @@ TAO_Default_Thread_Lane_Resources_Manager::~TAO_Default_Thread_Lane_Resources_Ma int TAO_Default_Thread_Lane_Resources_Manager::open_default_resources (ACE_ENV_SINGLE_ARG_DECL) { + TAO_ORB_Parameters *params = + this->orb_core_->orb_params (); + + TAO_EndpointSet endpoint_set; + + params->get_endpoint_set (TAO_DEFAULT_LANE, + endpoint_set); + + bool ignore_address = false; + int result = - this->lane_resources_->open_acceptor_registry (0 + this->lane_resources_->open_acceptor_registry (endpoint_set, + ignore_address ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index 1e189fc7623..b13cf85ba93 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -344,34 +344,6 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) arg_shifter.consume_arg (); } else if ((current_arg = arg_shifter.get_the_parameter - (ACE_TEXT("-ORBEndpoint")))) - { - // Each "endpoint" is of the form: - // - // protocol://V.v@addr1,addr2,...,addrN - // - // or: - // - // protocol://addr1,addr2,...,addrN - // - // where "V.v" is an optional protocol version for each - // addr. All endpoint strings should be of the above - // form(s). - // - // Multiple sets of endpoint may be seperated by a semi-colon `;'. - // For example: - // - // corbaloc:space:2001,1.2@odyssey:2010;uiop://foo,bar - // - // All endpoint strings should be of the above form(s). - - this->set_endpoint_helper (ACE_TEXT_ALWAYS_CHAR(current_arg) - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (-1); - - arg_shifter.consume_arg (); - } - else if ((current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ORBNameServicePort")))) { // Specify the port number for the NameService. @@ -785,6 +757,35 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) arg_shifter.consume_arg (); } else if ((current_arg = arg_shifter.get_the_parameter + (ACE_TEXT("-ORBEndpoint")))) + { + // Each "endpoint" is of the form: + // + // protocol://V.v@addr1,addr2,...,addrN + // + // or: + // + // protocol://addr1,addr2,...,addrN + // + // where "V.v" is an optional protocol version for each + // addr. All endpoint strings should be of the above + // form(s). + // + // Multiple sets of endpoint may be seperated by a semi-colon `;'. + // For example: + // + // corbaloc:space:2001,1.2@odyssey:2010;uiop://foo,bar + // + // All endpoint strings should be of the above form(s). + + this->set_endpoint_helper (ACE_TEXT_ALWAYS_CHAR (TAO_DEFAULT_LANE), + ACE_TEXT_ALWAYS_CHAR (current_arg) + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + + arg_shifter.consume_arg (); + } + else if ((current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ORBListenEndpoints")))) { // This option is similar to the -ORBEndPoint option. May be @@ -792,13 +793,39 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) // now, I (Priyanka) am leaving so that both options can be // used. - this->set_endpoint_helper (ACE_TEXT_ALWAYS_CHAR(current_arg) + this->set_endpoint_helper (ACE_TEXT_ALWAYS_CHAR (TAO_DEFAULT_LANE), + ACE_TEXT_ALWAYS_CHAR (current_arg) ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); arg_shifter.consume_arg (); } else if ((current_arg = arg_shifter.get_the_parameter + (ACE_TEXT("-ORBLaneEndpoint"))) || + (current_arg = arg_shifter.get_the_parameter + (ACE_TEXT("-ORBLaneListenEndpoints")))) + { + // This option is similar to the -ORBEndPoint option but + // specifies endpoints for each lane. + + if (arg_shifter.is_option_next ()) + return -1; + + ACE_CString lane (ACE_TEXT_ALWAYS_CHAR (current_arg)); + arg_shifter.consume_arg (); + + if(arg_shifter.is_option_next ()) + return -1; + + ACE_CString endpoints (ACE_TEXT_ALWAYS_CHAR (arg_shifter.get_current ())); + arg_shifter.consume_arg (); + + this->set_endpoint_helper (lane, + endpoints + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (-1); + } + else if ((current_arg = arg_shifter.get_the_parameter (ACE_TEXT("-ORBNoProprietaryActivation")))) { // This option can be used to set to not use any proprietary @@ -871,6 +898,34 @@ TAO_ORB_Core::init (int &argc, char *argv[] ACE_ENV_ARG_DECL) arg_shifter.ignore_arg (); } + const char *env_endpoint = + ACE_OS::getenv ("TAO_ORBENDPOINT"); + + if (env_endpoint != 0) + { + int result = + this->orb_params ()->add_endpoints (TAO_DEFAULT_LANE, + env_endpoint); + + if (result != 0) + { + if (TAO_debug_level > 0) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ERROR: Environment variable TAO_ORBENDPOINT set to invalid value ") + ACE_TEXT ("<%s>.\n"), + env_endpoint)); + } + + ACE_THROW_RETURN (CORBA::BAD_PARAM ( + CORBA::SystemException::_tao_minor_code ( + TAO_ORB_CORE_INIT_LOCATION_CODE, + EINVAL), + CORBA::COMPLETED_NO), + -1); + } + } + #if defined (SIGPIPE) && !defined (ACE_LACKS_UNIX_SIGNALS) // There's really no way to deal with this in a portable manner, so // we just have to suck it up and get preprocessor conditional and @@ -2172,17 +2227,17 @@ TAO_ORB_Core::resolve_ior_table_i (ACE_ENV_SINGLE_ARG_DECL) } int -TAO_ORB_Core::set_endpoint_helper (const char *current_arg +TAO_ORB_Core::set_endpoint_helper (const ACE_CString &lane, + const ACE_CString &endpoints ACE_ENV_ARG_DECL) { - ACE_CString endpts (current_arg); - - if (this->orb_params ()->endpoints (endpts) != 0) + if (this->orb_params ()->add_endpoints (lane, + endpoints) != 0) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t)\n") ACE_TEXT ("Invalid endpoint(s) specified:\n%s\n"), - ACE_TEXT_CHAR_TO_TCHAR(endpts.c_str ()))); + ACE_TEXT_CHAR_TO_TCHAR(endpoints.c_str ()))); ACE_THROW_RETURN (CORBA::BAD_PARAM ( CORBA::SystemException::_tao_minor_code ( TAO_ORB_CORE_INIT_LOCATION_CODE, diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index 3dcfb388a0b..54330c25851 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -1054,7 +1054,8 @@ protected: /// Pointer to the list of protocol loaded into this ORB instance. /// Helper method to hold the common code part for -ORBEndpoint and /// -ORBListenEndpoint options. - int set_endpoint_helper (const char *current_arg + int set_endpoint_helper (const ACE_CString &lane, + const ACE_CString &endpoints ACE_ENV_ARG_DECL); private: diff --git a/TAO/tao/PortableServer/Object_Adapter.cpp b/TAO/tao/PortableServer/Object_Adapter.cpp index 93c226157b8..f50ea9fa9df 100644 --- a/TAO/tao/PortableServer/Object_Adapter.cpp +++ b/TAO/tao/PortableServer/Object_Adapter.cpp @@ -591,10 +591,6 @@ TAO_Object_Adapter::open (ACE_ENV_SINGLE_ARG_DECL) this->orb_core_.thread_lane_resources_manager ().open_default_resources (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; - // Set the default Server Protocol Policy. - this->set_default_server_protocol_policy (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; - TAO_POA_Policy_Set policies (this->default_poa_policies ()); #if (TAO_HAS_MINIMUM_POA == 0) @@ -615,6 +611,17 @@ TAO_Object_Adapter::open (ACE_ENV_SINGLE_ARG_DECL) ACE_ENV_ARG_PARAMETER); ACE_CHECK; + // If any of the policy objects specified are not valid for the ORB + // implementation, if conflicting policy objects are specified, or + // if any of the specified policy objects require prior + // administrative action that has not been performed, an + // InvalidPolicy exception is raised containing the index in the + // policies parameter value of the first offending policy object. + policies.validate_policies (this->validator (), + this->orb_core_ + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + // Construct a new POA TAO_POA::String root_poa_name (TAO_DEFAULT_ROOTPOA_NAME); this->root_ = @@ -651,23 +658,6 @@ TAO_Object_Adapter::open (ACE_ENV_SINGLE_ARG_DECL) } void -TAO_Object_Adapter::set_default_server_protocol_policy (ACE_ENV_SINGLE_ARG_DECL) -{ - TAO_Thread_Lane_Resources &default_lane_resources = - this->orb_core_.thread_lane_resources_manager ().default_lane_resources (); - - TAO_Acceptor_Registry &acceptor_registry = - default_lane_resources.acceptor_registry (); - - TAO_Protocols_Hooks *protocols_hooks = - this->orb_core_.get_protocols_hooks (); - - protocols_hooks->set_default_server_protocol_policy (acceptor_registry - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; -} - -void TAO_Object_Adapter::close (int wait_for_completion ACE_ENV_ARG_DECL) { @@ -997,7 +987,7 @@ TAO_Object_Adapter_Factory::init (int /* argc */, ACE_FACTORY_DEFINE (TAO_PortableServer, TAO_Object_Adapter_Factory) ACE_STATIC_SVC_DEFINE (TAO_Object_Adapter_Factory, - ACE_TEXT ("TAO_POA"), + ACE_TEXT ("PortableServer"), ACE_SVC_OBJ_T, &ACE_SVC_NAME (TAO_Object_Adapter_Factory), ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, diff --git a/TAO/tao/PortableServer/Object_Adapter.h b/TAO/tao/PortableServer/Object_Adapter.h index a14c04293dc..2f245dedd04 100644 --- a/TAO/tao/PortableServer/Object_Adapter.h +++ b/TAO/tao/PortableServer/Object_Adapter.h @@ -377,8 +377,6 @@ protected: int unbind_persistent_poa (const poa_name &folded_name, const poa_name &system_name); - void set_default_server_protocol_policy (ACE_ENV_SINGLE_ARG_DECL); - static ACE_Lock *create_lock (int enable_locking, TAO_SYNCH_MUTEX &thread_lock); diff --git a/TAO/tao/Protocols_Hooks.h b/TAO/tao/Protocols_Hooks.h index c8056809e19..9fba62f8f91 100644 --- a/TAO/tao/Protocols_Hooks.h +++ b/TAO/tao/Protocols_Hooks.h @@ -202,12 +202,6 @@ public: ACE_ENV_ARG_DECL) = 0; //@} - - /// Sets the default ServerProtocolPolicy. - virtual int set_default_server_protocol_policy ( - TAO_Acceptor_Registry &acceptor_registry - ACE_ENV_ARG_DECL) = 0; - }; #include /**/ "ace/post.h" diff --git a/TAO/tao/RTCORBA/RT_Policy_i.cpp b/TAO/tao/RTCORBA/RT_Policy_i.cpp index 61f01e8784f..df7b05453db 100644 --- a/TAO/tao/RTCORBA/RT_Policy_i.cpp +++ b/TAO/tao/RTCORBA/RT_Policy_i.cpp @@ -148,8 +148,7 @@ TAO_PriorityModelPolicy::_tao_scope (void) const // copied to the list of client exposed policies. return ACE_static_cast (TAO_Policy_Scope, TAO_POLICY_ORB_SCOPE | - TAO_POLICY_POA_SCOPE | - TAO_POLICY_CLIENT_EXPOSED); + TAO_POLICY_POA_SCOPE); } // **************************************************************** diff --git a/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp b/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp index e45afce4c75..8297bf7951d 100644 --- a/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp +++ b/TAO/tao/RTCORBA/RT_Protocols_Hooks.cpp @@ -817,64 +817,6 @@ TAO_RT_Protocols_Hooks::set_thread_native_priority ( return 0; } -int -TAO_RT_Protocols_Hooks::set_default_server_protocol_policy ( - TAO_Acceptor_Registry &acceptor_registry - ACE_ENV_ARG_DECL - ) -{ - RTCORBA::ProtocolList protocols; - - TAO_AcceptorSetIterator end = - acceptor_registry.end (); - - for (TAO_AcceptorSetIterator acceptor = - acceptor_registry.begin (); - acceptor != end; - ++acceptor) - { - if (*acceptor == 0) - continue; - - CORBA::ULong current_length = - protocols.length (); - - protocols.length (current_length + 1); - - protocols[current_length].protocol_type = - (*acceptor)->tag (); - - protocols[current_length].orb_protocol_properties = - RTCORBA::ProtocolProperties::_nil (); - - // @@ Later, we will likely migrate to using RTCORBA protocol - // policies for configuration of protocols in nonRT use cases. - // Then, the code below will change to each protocol factory - // being responsible for creation of its own default protocol - // properties. - protocols[current_length].transport_protocol_properties = - TAO_Protocol_Properties_Factory::create_transport_protocol_property ((*acceptor)->tag (), - this->orb_core_); - } - - // Set ServerProtocolPolicy. - TAO_ServerProtocolPolicy *server_protocol_policy = 0; - ACE_NEW_RETURN (server_protocol_policy, - TAO_ServerProtocolPolicy (protocols), - -1); - - RTCORBA::ServerProtocolPolicy_var safe_server_protocol_policy = - server_protocol_policy; - - this->orb_core_->get_default_policies ()->set_policy ( - server_protocol_policy - ACE_ENV_ARG_PARAMETER - ); - ACE_CHECK_RETURN (-1); - - return 0; -} - ACE_STATIC_SVC_DEFINE (TAO_RT_Protocols_Hooks, ACE_TEXT ("RT_Protocols_Hooks"), ACE_SVC_OBJ_T, diff --git a/TAO/tao/RTCORBA/RT_Protocols_Hooks.h b/TAO/tao/RTCORBA/RT_Protocols_Hooks.h index a61a34826f4..5d5e33a5cee 100644 --- a/TAO/tao/RTCORBA/RT_Protocols_Hooks.h +++ b/TAO/tao/RTCORBA/RT_Protocols_Hooks.h @@ -55,34 +55,34 @@ public: void server_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void client_protocol_properties_at_orb_level (TAO_IIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void server_protocol_properties_at_orb_level (TAO_UIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void client_protocol_properties_at_orb_level (TAO_UIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void server_protocol_properties_at_orb_level (TAO_SHMIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void client_protocol_properties_at_orb_level (TAO_SHMIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void server_protocol_properties_at_orb_level (TAO_DIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void client_protocol_properties_at_orb_level (TAO_DIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void server_protocol_properties_at_orb_level (TAO_SCIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + void client_protocol_properties_at_orb_level (TAO_SCIOP_Protocol_Properties &protocol_properties ACE_ENV_ARG_DECL); - + CORBA::Long get_dscp_codepoint (void); void rt_service_context (TAO_Stub *stub, @@ -94,7 +94,7 @@ public: CORBA::Policy *model_policy, CORBA::Short &client_priority ACE_ENV_ARG_DECL); - + void get_selector_hook (CORBA::Policy *model_policy, CORBA::Boolean &is_client_propagated, @@ -114,24 +114,21 @@ public: //@{ int get_thread_CORBA_priority (CORBA::Short & ACE_ENV_ARG_DECL); - + int get_thread_native_priority (CORBA::Short & ACE_ENV_ARG_DECL); - + int get_thread_CORBA_and_native_priority (CORBA::Short &, CORBA::Short & ACE_ENV_ARG_DECL); - + int set_thread_CORBA_priority (CORBA::Short ACE_ENV_ARG_DECL); - + int set_thread_native_priority (CORBA::Short ACE_ENV_ARG_DECL); - - //@} - int set_default_server_protocol_policy (TAO_Acceptor_Registry &acceptor_registry - ACE_ENV_ARG_DECL); + //@} protected: @@ -160,19 +157,19 @@ protected: void extract_protocol_properties (TAO_UIOP_Protocol_Properties &to, RTCORBA::ProtocolProperties_ptr from ACE_ENV_ARG_DECL); - + void extract_protocol_properties (TAO_SHMIOP_Protocol_Properties &to, RTCORBA::ProtocolProperties_ptr from ACE_ENV_ARG_DECL); - + void extract_protocol_properties (TAO_DIOP_Protocol_Properties &to, RTCORBA::ProtocolProperties_ptr from ACE_ENV_ARG_DECL); - + void extract_protocol_properties (TAO_SCIOP_Protocol_Properties &to, RTCORBA::ProtocolProperties_ptr from ACE_ENV_ARG_DECL); - + CORBA::Boolean set_network_priority (IOP::ProfileId protocol_tag, RTCORBA::ProtocolProperties_ptr protocol_properties ACE_ENV_ARG_DECL); diff --git a/TAO/tao/RTCORBA/RT_Thread_Lane_Resources_Manager.cpp b/TAO/tao/RTCORBA/RT_Thread_Lane_Resources_Manager.cpp index 134c253e80f..8e7d5b0d627 100644 --- a/TAO/tao/RTCORBA/RT_Thread_Lane_Resources_Manager.cpp +++ b/TAO/tao/RTCORBA/RT_Thread_Lane_Resources_Manager.cpp @@ -4,8 +4,8 @@ #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 -ACE_RCSID (RTCORBA, - RT_Thread_Lane_Resources_Manager, +ACE_RCSID (RTCORBA, + RT_Thread_Lane_Resources_Manager, "$Id$") #include "tao/ORB_Core.h" @@ -46,8 +46,19 @@ TAO_RT_Thread_Lane_Resources_Manager::~TAO_RT_Thread_Lane_Resources_Manager (voi int TAO_RT_Thread_Lane_Resources_Manager::open_default_resources (ACE_ENV_SINGLE_ARG_DECL) { + TAO_ORB_Parameters *params = + this->orb_core_->orb_params (); + + TAO_EndpointSet endpoint_set; + + params->get_endpoint_set (TAO_DEFAULT_LANE, + endpoint_set); + + bool ignore_address = false; + int result = - this->default_lane_resources_->open_acceptor_registry (0 + this->default_lane_resources_->open_acceptor_registry (endpoint_set, + ignore_address ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); diff --git a/TAO/tao/RTCORBA/Thread_Pool.cpp b/TAO/tao/RTCORBA/Thread_Pool.cpp index d49742a5f7c..488480ceba6 100644 --- a/TAO/tao/RTCORBA/Thread_Pool.cpp +++ b/TAO/tao/RTCORBA/Thread_Pool.cpp @@ -217,10 +217,45 @@ TAO_Thread_Lane::open (ACE_ENV_SINGLE_ARG_DECL) this->validate_and_map_priority (ACE_ENV_SINGLE_ARG_PARAMETER); ACE_CHECK; + // Create a string with the pool:thread id. + char pool_lane_id[10]; + ACE_OS::sprintf (pool_lane_id, + "%d:%d", + this->pool ().id (), + this->id ()); + + TAO_ORB_Parameters *params = + this->pool ().manager ().orb_core ().orb_params (); + + TAO_EndpointSet endpoint_set; + bool ignore_address; + + // Get the endpoints for this lane. + params->get_endpoint_set (pool_lane_id, + endpoint_set); + + if (endpoint_set.is_empty ()) + { + // If endpoints are not specified for this lane, use the + // endpoints specified for the default lane but ignore their + // addresses. + params->get_endpoint_set (TAO_DEFAULT_LANE, + endpoint_set); + + ignore_address = true; + } + else + { + // If endpoints are specified for this lane, use them with thier + // addresses. + ignore_address = false; + } + // Open the acceptor registry. int result = 0; result = - this->resources_.open_acceptor_registry (1 + this->resources_.open_acceptor_registry (endpoint_set, + ignore_address ACE_ENV_ARG_PARAMETER); ACE_CHECK; diff --git a/TAO/tao/RTPortableServer/RT_Object_Adapter_Factory.cpp b/TAO/tao/RTPortableServer/RT_Object_Adapter_Factory.cpp index 7034fb69872..dcb8445d49d 100644 --- a/TAO/tao/RTPortableServer/RT_Object_Adapter_Factory.cpp +++ b/TAO/tao/RTPortableServer/RT_Object_Adapter_Factory.cpp @@ -61,7 +61,7 @@ TAO_RT_Object_Adapter_Factory::create (TAO_ORB_Core *orb_core) ACE_FACTORY_DEFINE (TAO_RTPortableServer, TAO_RT_Object_Adapter_Factory) ACE_STATIC_SVC_DEFINE (TAO_RT_Object_Adapter_Factory, - ACE_TEXT ("TAO_RT_POA"), + ACE_TEXT ("RTPortableServer"), ACE_SVC_OBJ_T, &ACE_SVC_NAME (TAO_RT_Object_Adapter_Factory), ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, diff --git a/TAO/tao/RTPortableServer/RT_POA.cpp b/TAO/tao/RTPortableServer/RT_POA.cpp index e39f9a6c0d5..10c586283d2 100644 --- a/TAO/tao/RTPortableServer/RT_POA.cpp +++ b/TAO/tao/RTPortableServer/RT_POA.cpp @@ -17,6 +17,8 @@ #include "tao/RTCORBA/Thread_Pool.h" #include "tao/Thread_Lane_Resources.h" #include "tao/Acceptor_Registry.h" +#include "tao/Thread_Lane_Resources.h" +#include "tao/Thread_Lane_Resources_Manager.h" #include "tao/RTCORBA/RT_Policy_i.h" @@ -276,9 +278,30 @@ TAO_RT_POA::key_to_stub_i (const TAO::ObjectKey &object_key, if (this->thread_pool_ == 0 || !this->thread_pool_->with_lanes ()) { - TAO_Acceptor_Registry *acceptor_registry = - TAO_POA_RT_Policy_Validator::extract_acceptor_registry (this->orb_core_, - this->thread_pool_); + TAO_Acceptor_Registry *acceptor_registry = 0; + + if (this->thread_pool_ == 0) + { + TAO_Thread_Lane_Resources_Manager &thread_lane_resources_manager = + this->orb_core_.thread_lane_resources_manager (); + + TAO_Thread_Lane_Resources &resources = + thread_lane_resources_manager.default_lane_resources (); + + acceptor_registry = + &resources.acceptor_registry (); + } + else + { + TAO_Thread_Lane **lanes = + this->thread_pool_->lanes (); + + TAO_Thread_Lane_Resources &resources = + lanes[0]->resources (); + + acceptor_registry = + &resources.acceptor_registry (); + } return this->TAO_POA::create_stub_object (object_key, diff --git a/TAO/tao/RTPortableServer/RT_Policy_Validator.cpp b/TAO/tao/RTPortableServer/RT_Policy_Validator.cpp index 464b0dca8df..345af1c16bc 100644 --- a/TAO/tao/RTPortableServer/RT_Policy_Validator.cpp +++ b/TAO/tao/RTPortableServer/RT_Policy_Validator.cpp @@ -23,7 +23,6 @@ ACE_RCSID (RTPortableServer, TAO_POA_RT_Policy_Validator::TAO_POA_RT_Policy_Validator (TAO_ORB_Core &orb_core) : TAO_Policy_Validator (orb_core), - acceptor_registry_ (0), thread_pool_ (0) { // No-Op. @@ -34,16 +33,6 @@ 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 ACE_ENV_ARG_DECL) @@ -51,9 +40,6 @@ TAO_POA_RT_Policy_Validator::validate_impl (TAO_Policy_Set &policies this->validate_thread_pool (policies ACE_ENV_ARG_PARAMETER); ACE_CHECK; - this->validate_lifespan (policies ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - this->validate_server_protocol (policies ACE_ENV_ARG_PARAMETER); ACE_CHECK; @@ -83,6 +69,23 @@ TAO_POA_RT_Policy_Validator::validate_server_protocol (TAO_Policy_Set &policies ACE_ENV_ARG_PARAMETER); ACE_CHECK; + if (CORBA::is_nil (protocol.in ())) + { + // If the server protocol policy has not been specified, then + // add a server policy that reflects the protocols supported by + // the acceptor registries of the POA's thread pool. + protocol = + TAO_POA_RT_Policy_Validator::server_protocol_policy_from_thread_pool (this->thread_pool_, + this->orb_core_); + + if (!CORBA::is_nil (protocol.in ())) + { + // If so, we'll use that policy. + policies.set_policy (protocol.in () ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + } + } + RTCORBA::ServerProtocolPolicy_var server_protocol_policy = RTCORBA::ServerProtocolPolicy::_narrow (protocol.in () ACE_ENV_ARG_PARAMETER); @@ -95,28 +98,64 @@ TAO_POA_RT_Policy_Validator::validate_server_protocol (TAO_Policy_Set &policies RTCORBA::ProtocolList &protocols = server_protocol->protocols_rep (); - 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 = acceptor_registry->begin (); - a != acceptor_registry->end (); - ++a) + + if (this->thread_pool_) { - if ((*a)->tag () == protocol_type) + TAO_Thread_Lane **lanes = + this->thread_pool_->lanes (); + + for (CORBA::ULong i = 0; + i != this->thread_pool_->number_of_lanes (); + ++i) { - found = 1; - break; + TAO_Thread_Lane_Resources &resources = + lanes[i]->resources (); + + TAO_Acceptor_Registry &acceptor_registry = + resources.acceptor_registry (); + + for (TAO_AcceptorSetIterator a = acceptor_registry.begin (); + a != acceptor_registry.end (); + ++a) + { + if ((*a)->tag () == protocol_type) + { + found = 1; + break; + } + } + } + } + else + { + TAO_Thread_Lane_Resources_Manager &thread_lane_resources_manager = + this->orb_core_.thread_lane_resources_manager (); + + TAO_Thread_Lane_Resources &resources = + thread_lane_resources_manager.default_lane_resources (); + + TAO_Acceptor_Registry &acceptor_registry = + resources.acceptor_registry (); + + for (TAO_AcceptorSetIterator a = acceptor_registry.begin (); + a != acceptor_registry.end (); + ++a) + { + if ((*a)->tag () == protocol_type) + { + found = 1; + break; + } } } if (!found) ACE_THROW (PortableServer::POA::InvalidPolicy ()); } - } void @@ -336,36 +375,6 @@ TAO_POA_RT_Policy_Validator::validate_thread_pool (TAO_Policy_Set &policies } void -TAO_POA_RT_Policy_Validator::validate_lifespan (TAO_Policy_Set &policies - ACE_ENV_ARG_DECL) -{ - // If this POA is using a RTCORBA thread pool, make sure the - // lifespan policy is not persistent since we cannot support it - // right now. - if (this->thread_pool_ != 0) - { - CORBA::Policy_var policy = - policies.get_cached_policy (TAO_CACHED_POLICY_LIFESPAN - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - PortableServer::LifespanPolicy_var lifespan_policy = - PortableServer::LifespanPolicy::_narrow (policy.in () - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - PortableServer::LifespanPolicyValue lifespan = - lifespan_policy->value (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; - - if (lifespan == PortableServer::PERSISTENT) - { - ACE_THROW (PortableServer::POA::InvalidPolicy ()); - } - } -} - -void TAO_POA_RT_Policy_Validator::merge_policies_impl (TAO_Policy_Set &policies ACE_ENV_ARG_DECL) { @@ -441,6 +450,106 @@ TAO_POA_RT_Policy_Validator::merge_policies_impl (TAO_Policy_Set &policies } /* static */ +RTCORBA::ServerProtocolPolicy_ptr +TAO_POA_RT_Policy_Validator::server_protocol_policy_from_thread_pool (TAO_Thread_Pool *thread_pool, + TAO_ORB_Core &orb_core) +{ + RTCORBA::ProtocolList protocols; + + if (thread_pool) + { + TAO_Thread_Lane **lanes = + thread_pool->lanes (); + + for (CORBA::ULong i = 0; + i != thread_pool->number_of_lanes (); + ++i) + { + TAO_Thread_Lane_Resources &resources = + lanes[i]->resources (); + + TAO_Acceptor_Registry &acceptor_registry = + resources.acceptor_registry (); + + TAO_POA_RT_Policy_Validator::server_protocol_policy_from_acceptor_registry (protocols, + acceptor_registry, + orb_core); + } + } + else + { + 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 (); + + TAO_Acceptor_Registry &acceptor_registry = + resources.acceptor_registry (); + + TAO_POA_RT_Policy_Validator::server_protocol_policy_from_acceptor_registry (protocols, + acceptor_registry, + orb_core); + } + + // Set ServerProtocolPolicy. + TAO_ServerProtocolPolicy *server_protocol_policy = 0; + ACE_NEW_RETURN (server_protocol_policy, + TAO_ServerProtocolPolicy (protocols), + 0); + + return server_protocol_policy; +} + +/* static */ +void +TAO_POA_RT_Policy_Validator::server_protocol_policy_from_acceptor_registry (RTCORBA::ProtocolList &protocols, + TAO_Acceptor_Registry &acceptor_registry, + TAO_ORB_Core &orb_core) +{ + TAO_AcceptorSetIterator end = + acceptor_registry.end (); + + for (TAO_AcceptorSetIterator acceptor = + acceptor_registry.begin (); + acceptor != end; + ++acceptor) + { + if (*acceptor == 0) + continue; + + CORBA::ULong current_length = + protocols.length (); + + // Make sure that this protocol is not already in the protocol + // list. + bool protocol_already_present = false; + for (CORBA::ULong i = 0; + i < current_length && !protocol_already_present; + ++i) + { + if (protocols[i].protocol_type == (*acceptor)->tag ()) + protocol_already_present = true; + } + + if (protocol_already_present) + continue; + + protocols.length (current_length + 1); + + protocols[current_length].protocol_type = + (*acceptor)->tag (); + + protocols[current_length].orb_protocol_properties = + RTCORBA::ProtocolProperties::_nil (); + + protocols[current_length].transport_protocol_properties = + TAO_Protocol_Properties_Factory::create_transport_protocol_property ((*acceptor)->tag (), + &orb_core); + } +} + +/* static */ TAO_Thread_Pool * TAO_POA_RT_Policy_Validator::extract_thread_pool (TAO_ORB_Core &orb_core, TAO_Policy_Set &policies @@ -496,41 +605,4 @@ TAO_POA_RT_Policy_Validator::extract_thread_pool (TAO_ORB_Core &orb_core, 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) - { - TAO_Thread_Lane **lanes = - thread_pool->lanes (); - - // 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; -} - #endif /* TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 */ diff --git a/TAO/tao/RTPortableServer/RT_Policy_Validator.h b/TAO/tao/RTPortableServer/RT_Policy_Validator.h index a8c07df255d..2c282de4271 100644 --- a/TAO/tao/RTPortableServer/RT_Policy_Validator.h +++ b/TAO/tao/RTPortableServer/RT_Policy_Validator.h @@ -26,6 +26,7 @@ #include "rtportableserver_export.h" #include "tao/Policy_Validator.h" +#include "tao/RTCORBA/RTCORBA.h" class TAO_ORB_Core; class TAO_Acceptor_Registry; @@ -41,13 +42,17 @@ public: /// Destructor. ~TAO_POA_RT_Policy_Validator (void); + static RTCORBA::ServerProtocolPolicy_ptr server_protocol_policy_from_thread_pool (TAO_Thread_Pool *thread_pool, + TAO_ORB_Core &orb_core); + + static void server_protocol_policy_from_acceptor_registry (RTCORBA::ProtocolList &protocols, + TAO_Acceptor_Registry &acceptor_registry, + TAO_ORB_Core &orb_core); + static TAO_Thread_Pool *extract_thread_pool (TAO_ORB_Core &orb_core, TAO_Policy_Set &policies ACE_ENV_ARG_DECL); - static TAO_Acceptor_Registry *extract_acceptor_registry (TAO_ORB_Core &orb_core, - TAO_Thread_Pool *thread_pool); - protected: /** @@ -80,13 +85,6 @@ private: void validate_thread_pool (TAO_Policy_Set &policies ACE_ENV_ARG_DECL); - void validate_lifespan (TAO_Policy_Set &policies - ACE_ENV_ARG_DECL); - - TAO_Acceptor_Registry *acceptor_registry (void); - - TAO_Acceptor_Registry *acceptor_registry_; - TAO_Thread_Pool *thread_pool_; }; diff --git a/TAO/tao/Strategies/DIOP_Acceptor.cpp b/TAO/tao/Strategies/DIOP_Acceptor.cpp index 6764dde74e4..1130801d00d 100644 --- a/TAO/tao/Strategies/DIOP_Acceptor.cpp +++ b/TAO/tao/Strategies/DIOP_Acceptor.cpp @@ -378,7 +378,7 @@ TAO_DIOP_Acceptor::open_default (TAO_ORB_Core *orb_core, // address. ACE_INET_Addr addr; - if (addr.set (ACE_DEFAULT_SERVER_PORT, + if (addr.set (static_cast<unsigned short> (0), ACE_static_cast(ACE_UINT32, INADDR_ANY), 1) != 0) return -1; @@ -409,11 +409,25 @@ TAO_DIOP_Acceptor::open_i (const ACE_INET_Addr& addr, // Connection handler ownership now belongs to the Reactor. this->connection_handler_->remove_reference (); + ACE_INET_Addr address; + + // We do this make sure the port number the endpoint is listening on + // gets set in the addr. + if (this->connection_handler_->dgram ().get_local_addr (address) != 0) + { + if (TAO_debug_level > 0) + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("TAO (%P|%t) DIOP_Acceptor::open_i ") + ACE_TEXT ("- %p"), + ACE_TEXT ("cannot get local addr\n"))); + return -1; + } + // Set the port for each addr. If there is more than one network // interface then the endpoint created on each interface will be on // the same port. This is how a wildcard socket bind() is supposed // to work. - u_short port = addr.get_port_number (); + u_short port = address.get_port_number (); for (size_t j = 0; j < this->endpoint_count_; ++j) this->addrs_[j].set_port_number (port, 1); diff --git a/TAO/tao/Thread_Lane_Resources.cpp b/TAO/tao/Thread_Lane_Resources.cpp index 1ca22a258e7..2357bf457f7 100644 --- a/TAO/tao/Thread_Lane_Resources.cpp +++ b/TAO/tao/Thread_Lane_Resources.cpp @@ -348,7 +348,8 @@ TAO_Thread_Lane_Resources::ami_response_handler_allocator (void) } int -TAO_Thread_Lane_Resources::open_acceptor_registry (int ignore_address +TAO_Thread_Lane_Resources::open_acceptor_registry (const TAO_EndpointSet &endpoint_set, + bool ignore_address ACE_ENV_ARG_DECL) { // Access the acceptor registry. @@ -357,6 +358,7 @@ TAO_Thread_Lane_Resources::open_acceptor_registry (int ignore_address // Open it. int result = ar.open (&this->orb_core_, this->leader_follower ().reactor (), + endpoint_set, ignore_address ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); diff --git a/TAO/tao/Thread_Lane_Resources.h b/TAO/tao/Thread_Lane_Resources.h index d3a92da8d45..eef311676c8 100644 --- a/TAO/tao/Thread_Lane_Resources.h +++ b/TAO/tao/Thread_Lane_Resources.h @@ -24,6 +24,7 @@ #include "tao/TAO_Export.h" #include "tao/orbconf.h" +#include "params.h" class ACE_Allocator; class TAO_ORB_Core; @@ -63,7 +64,8 @@ public: int is_collocated (const TAO_MProfile &mprofile); /// Open the acceptor registry. - int open_acceptor_registry (int ignore_address + int open_acceptor_registry (const TAO_EndpointSet &endpoint_set, + bool ignore_address ACE_ENV_ARG_DECL); /// Finalize resources. diff --git a/TAO/tao/orbconf.h b/TAO/tao/orbconf.h index 49564b39bdc..6a11dd3481a 100644 --- a/TAO/tao/orbconf.h +++ b/TAO/tao/orbconf.h @@ -319,6 +319,11 @@ const size_t TAO_DEFAULT_VALUE_FACTORY_TABLE_SIZE = 128; #define TAO_DEFAULT_ROOTPOA_NAME "" #endif /* TAO_DEFAULT_ROOTPOA_NAME */ +// The default lane name used when storing endpoints. +#if !defined (TAO_DEFAULT_LANE) +#define TAO_DEFAULT_LANE "default lane" +#endif /* TAO_DEFAULT_LANE */ + // Minimum CORBA #if !defined (TAO_HAS_MINIMUM_CORBA) # define TAO_HAS_MINIMUM_CORBA 0 diff --git a/TAO/tao/params.cpp b/TAO/tao/params.cpp index 1d19ecf5aac..1add777ba58 100644 --- a/TAO/tao/params.cpp +++ b/TAO/tao/params.cpp @@ -15,7 +15,7 @@ ACE_RCSID (tao, TAO_ORB_Parameters::TAO_ORB_Parameters (void) - : endpoints_list_ (), + : endpoints_map_ (10), mcast_discovery_endpoint_ (), default_init_ref_ (TAO_DEFAULT_INIT_REFERENCE_INITIALIZER), sock_rcvbuf_size_ (ACE_DEFAULT_MAX_SOCKET_BUFSIZ), @@ -41,9 +41,72 @@ TAO_ORB_Parameters::~TAO_ORB_Parameters (void) { } +void +TAO_ORB_Parameters::get_endpoint_set (const ACE_CString &lane, + TAO_EndpointSet &endpoint_set) +{ + ACE_CString endpoints; + + // Look for the lane in the endpoints map. + int result = + this->endpoints_map_.find (lane, endpoints); + + // If lane is not in the map, <endpoint_set> remains empty + if (result != 0) + return; + + // At this point, the parsing should not fail since they have been + // parsed successfully before. + result = + this->parse_and_add_endpoints (endpoints, + endpoint_set); + ACE_ASSERT (result == 0); +} + +int +TAO_ORB_Parameters::add_endpoints (const ACE_CString &lane, + const ACE_CString &additional_endpoints) +{ + TAO_EndpointSet endpoint_set; + + // Parse the additional endpoints. + int result = + this->parse_and_add_endpoints (additional_endpoints, + endpoint_set); + + // Parse failure. + if (result != 0) + return result; + + // Look for the lane in the endpoints map. + ACE_CString existing_endpoints; + result = + this->endpoints_map_.find (lane, existing_endpoints); + + // Create the resultant endpoints string. + ACE_CString new_endpoints; + if (result == 0) + new_endpoints = + existing_endpoints + + ";" + + additional_endpoints; + else + new_endpoints = + additional_endpoints; + + result = + this->endpoints_map_.rebind (lane, + new_endpoints); + + if (result == -1) + return result; + + return 0; +} + int -TAO_ORB_Parameters::parse_endpoints (ACE_CString &endpoints, - TAO_EndpointSet &endpoints_list) +TAO_ORB_Parameters::parse_and_add_endpoints (const ACE_CString &endpoints, + TAO_EndpointSet &endpoint_set) { // Parse the string into seperate endpoints, where `endpoints' is of // the form: @@ -106,7 +169,7 @@ TAO_ORB_Parameters::parse_endpoints (ACE_CString &endpoints, if (check_offset > 0 && check_offset != endpt.npos) { - endpoints_list.enqueue_tail (endpt); + endpoint_set.enqueue_tail (endpt); // Insert endpoint into list } else diff --git a/TAO/tao/params.h b/TAO/tao/params.h index 2394f5ee9e9..186f11360f4 100644 --- a/TAO/tao/params.h +++ b/TAO/tao/params.h @@ -16,6 +16,8 @@ #include /**/ "ace/pre.h" #include "ace/Unbounded_Queue.h" +#include "ace/Hash_Map_Manager.h" +#include "ace/Synch.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once @@ -38,7 +40,13 @@ class TAO_Reverse_Active_Object_Map_Impl; // in ACE so we do not have to worry about increasing TAO's // footprint by using this container. typedef ACE_Unbounded_Queue<ACE_CString> TAO_EndpointSet; -typedef ACE_Unbounded_Queue_Iterator<ACE_CString> TAO_EndpointSetIterator; +typedef ACE_Unbounded_Queue_Const_Iterator<ACE_CString> TAO_EndpointSetIterator; +typedef ACE_Hash_Map_Manager_Ex<ACE_CString, + ACE_CString, + ACE_Hash<ACE_CString>, + ACE_Equal_To<ACE_CString>, + ACE_Null_Mutex> + TAO_EndpointMap; // ------------------------------------------------------------------- @@ -66,9 +74,10 @@ public: /// Specifies the endpoints on which this server is willing to /// listen for requests. - int endpoints (ACE_CString &endpoints); - TAO_EndpointSet &endpoints (void); - void add_endpoint (ACE_CString &endpoint); + int add_endpoints (const ACE_CString &lane, + const ACE_CString &endpoints); + void get_endpoint_set (const ACE_CString &lane, + TAO_EndpointSet &endpoint_set); /// Set/Get the port of services locatable through multicast. CORBA::UShort service_port (TAO_MCAST_SERVICEID service_id) const; @@ -176,16 +185,14 @@ private: // iiop://space:2001,odyssey:2010;uiop://foo,bar // // All preconnect or endpoint strings should be of the above form(s). - - int parse_endpoints (ACE_CString &endpoints, - TAO_EndpointSet &endpoints_list); + int parse_and_add_endpoints (const ACE_CString &endpoints, + TAO_EndpointSet &endpoint_set); /// List of endpoints used to pre-establish connections. // TAO_EndpointSet preconnects_list_; - /// List of endpoints this server is willing to accept requests - /// on. - TAO_EndpointSet endpoints_list_; + /// Map of endpoints this server is willing to accept requests on. + TAO_EndpointMap endpoints_map_; /// Port numbers of the configured services. CORBA::UShort service_port_[TAO_NO_OF_MCAST_SERVICES]; diff --git a/TAO/tao/params.i b/TAO/tao/params.i index f82bd737255..0a5190d8912 100644 --- a/TAO/tao/params.i +++ b/TAO/tao/params.i @@ -1,23 +1,5 @@ // -*- C++ -*- // $Id$ -ACE_INLINE TAO_EndpointSet & -TAO_ORB_Parameters::endpoints (void) -{ - return this->endpoints_list_; -} - -ACE_INLINE int -TAO_ORB_Parameters::endpoints (ACE_CString &endpoints) -{ - return this->parse_endpoints (endpoints, this->endpoints ()); -} - -ACE_INLINE void -TAO_ORB_Parameters::add_endpoint (ACE_CString &endpoint) -{ - this->endpoints ().enqueue_tail (endpoint); -} - ACE_INLINE int TAO_ORB_Parameters::sock_rcvbuf_size (void) const { diff --git a/TAO/tests/RTCORBA/Persistent_IOR/README b/TAO/tests/RTCORBA/Persistent_IOR/README index e1789a6b204..c5c2d19824d 100644 --- a/TAO/tests/RTCORBA/Persistent_IOR/README +++ b/TAO/tests/RTCORBA/Persistent_IOR/README @@ -8,7 +8,8 @@ This test makes sure that: -ORBEndpoint option. - Makes sure that if the user tries to combine thread pools and -persistence, an InvalidPolicy exception is thrown. +persistence, an InvalidPolicy exception is no longer thrown since this +feature is now supported with the -ORBLaneEndpoint option. - Makes sure that for POAs using thread pools, the user can specify the protocol selection, protocol version, and other protocol specific diff --git a/TAO/tests/RTCORBA/Persistent_IOR/run_test.pl b/TAO/tests/RTCORBA/Persistent_IOR/run_test.pl index 40c25a52a47..08a8fed4db6 100755 --- a/TAO/tests/RTCORBA/Persistent_IOR/run_test.pl +++ b/TAO/tests/RTCORBA/Persistent_IOR/run_test.pl @@ -9,32 +9,37 @@ use lib '../../../../bin'; use PerlACE::Run_Test; $iiop_port = 27532; +$tp_iiop_port = 27533; -$extra_server_args = "-d 1 -ORBobjrefstyle url -ORBEndpoint iiop://1.0\@:$iiop_port"; +$extra_server_args = "-d 1 -ORBobjrefstyle url -ORBEndpoint iiop://1.0\@:$iiop_port -ORBLaneEndpoint 2:0 iiop://1.0\@:$tp_iiop_port"; @iorfiles = ( + "not_used_ior_1", + "not_used_ior_2", "persistent_ior", "transient_ior", - "not_used_ior", + "tp_persistent_ior", ); @configurations = ( { - iorfiles => [ "persistent_ior", "transient_ior" ], - server => "-p persistent_ior -t transient_ior $extra_server_args", - clients => [ "-k file://persistent_ior", "-k file://transient_ior -x" ], + iorfiles => [ "persistent_ior", "tp_persistent_ior", "transient_ior" ], + server => "-a tp_persistent_ior -p persistent_ior -t transient_ior $extra_server_args", + clients => [ "-k file://tp_persistent_ior", "-k file://persistent_ior", "-k file://transient_ior -x" ], }, { - iorfiles => [ "persistent_ior", "transient_ior", "not_used_ior" ], - server => "-p not_used_ior -t transient_ior $extra_server_args", - clients => [ "-k file://not_used_ior", "-k file://transient_ior -x" ], + iorfiles => [ "not_used_ior_1", "not_used_ior_2", "transient_ior" ], + server => "-a not_used_ior_1 -p not_used_ior_2 -t transient_ior $extra_server_args", + clients => [ "-k file://tp_persistent_ior", "-k file://persistent_ior", "-k file://transient_ior -x" ], }, ); sub run_client { + print "\nRunning client with the following args: @_\n\n"; + $CL = new PerlACE::Process ("client", @_); $CL->Spawn (); @@ -55,6 +60,8 @@ sub run_server my $args = $parms[0]; my $iorfiles = $parms[1]; + print "\nRunning server with the following args: $args\n\n"; + $SV = new PerlACE::Process ("server", $args); $SV->Spawn (); diff --git a/TAO/tests/RTCORBA/Persistent_IOR/server.cpp b/TAO/tests/RTCORBA/Persistent_IOR/server.cpp index 2a81402f7ec..a56182609fd 100644 --- a/TAO/tests/RTCORBA/Persistent_IOR/server.cpp +++ b/TAO/tests/RTCORBA/Persistent_IOR/server.cpp @@ -63,6 +63,7 @@ test_i::_default_POA (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) static const char *persistent_ior = "persistent_ior"; static const char *transient_ior = "transient_ior"; +static const char *tp_persistent_ior = "tp_persistent_ior"; static int debug = 0; static CORBA::ULong stacksize = 0; @@ -76,12 +77,16 @@ static CORBA::ULong max_request_buffer_size = 0; int parse_args (int argc, char *argv[]) { - ACE_Get_Opt get_opts (argc, argv, "p:t:d:"); + ACE_Get_Opt get_opts (argc, argv, "a:p:t:d:"); int c; while ((c = get_opts ()) != -1) switch (c) { + case 'a': + tp_persistent_ior = get_opts.opt_arg (); + break; + case 'p': persistent_ior = get_opts.opt_arg (); break; @@ -98,6 +103,7 @@ parse_args (int argc, char *argv[]) default: ACE_ERROR_RETURN ((LM_ERROR, "usage: %s " + "-a <tp persistent ior file> " "-p <persistent ior file> " "-t <transient ior file> " "-d <debug> " @@ -127,7 +133,8 @@ write_iors_to_file (CORBA::Object_ptr object, if (debug) ACE_DEBUG ((LM_DEBUG, - "%s\n", + "%s: %s\n", + filename, ior.in ())); u_int result = 0; @@ -261,67 +268,76 @@ create_poa_and_servant_with_tp_policy (CORBA::ORB_ptr orb, } void -create_poa_with_tp_and_persistent_policy (RTCORBA::RTORB_ptr rt_orb, - PortableServer::POA_ptr root_poa +create_poa_with_tp_and_persistent_policy (CORBA::ORB_ptr orb, + RTCORBA::RTORB_ptr rt_orb, + PortableServer::POA_ptr root_poa, + PortableServer::POAManager_ptr poa_manager ACE_ENV_ARG_DECL) { - ACE_TRY - { - CORBA::PolicyList policies; - - RTCORBA::ThreadpoolId threadpool_id = - rt_orb->create_threadpool (stacksize, - static_threads, - dynamic_threads, - default_thread_priority, - allow_request_buffering, - max_buffered_requests, - max_request_buffer_size - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + RTCORBA::ThreadpoolId threadpool_id = + rt_orb->create_threadpool (stacksize, + static_threads, + dynamic_threads, + default_thread_priority, + allow_request_buffering, + max_buffered_requests, + max_request_buffer_size + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; - CORBA::Policy_var threadpool_policy = - rt_orb->create_threadpool_policy (threadpool_id - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + CORBA::Policy_var threadpool_policy = + rt_orb->create_threadpool_policy (threadpool_id + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; - CORBA::Policy_var lifespan_policy = - root_poa->create_lifespan_policy (PortableServer::PERSISTENT - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; + CORBA::Policy_var implicit_activation_policy = + root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; - policies.length (policies.length () + 1); - policies[policies.length () - 1] = - lifespan_policy; + CORBA::Policy_var lifespan_policy = + root_poa->create_lifespan_policy (PortableServer::PERSISTENT + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; - policies.length (policies.length () + 1); - policies[policies.length () - 1] = - threadpool_policy; + CORBA::PolicyList policies; - PortableServer::POA_var invalid_poa = - root_poa->create_POA ("invalid", - PortableServer::POAManager::_nil (), - policies - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + policies.length (policies.length () + 1); + policies[policies.length () - 1] = + implicit_activation_policy; - // This next line of code should not run because an exception - // should have been raised. - ACE_DEBUG ((LM_DEBUG, "ERROR: no exception caught\n")); - } - ACE_CATCH (PortableServer::POA::InvalidPolicy, ex) - { - // Expected exception. - ACE_DEBUG ((LM_DEBUG, - "InvalidPolicy exception is caught as expected.\n")); - } - ACE_CATCHANY - { - // Unexpected exception. - ACE_DEBUG ((LM_DEBUG, "ERROR: unexpected exception caught\n")); - ACE_RE_THROW; - } - ACE_ENDTRY; + policies.length (policies.length () + 1); + policies[policies.length () - 1] = + threadpool_policy; + + policies.length (policies.length () + 1); + policies[policies.length () - 1] = + lifespan_policy; + + PortableServer::POA_var poa = + root_poa->create_POA ("tp_persistent_child", + poa_manager, + policies + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + test_i *servant = 0; + ACE_NEW_THROW_EX (servant, + test_i (orb, + poa.in ()), + CORBA::NO_MEMORY ()); + ACE_CHECK; + + PortableServer::ServantBase_var safe_servant (servant); + + test_var test = + servant->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_CHECK; + + write_iors_to_file (test.in (), + orb, + tp_persistent_ior + ACE_ENV_ARG_PARAMETER); ACE_CHECK; } @@ -393,8 +409,10 @@ main (int argc, char **argv) ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - create_poa_with_tp_and_persistent_policy (rt_orb.in (), - root_poa.in () + create_poa_with_tp_and_persistent_policy (orb.in (), + rt_orb.in (), + root_poa.in (), + poa_manager.in () ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; diff --git a/TAO/tests/RTCORBA/Server_Protocol/README b/TAO/tests/RTCORBA/Server_Protocol/README index 53c1f2216da..b8e889ab6f9 100644 --- a/TAO/tests/RTCORBA/Server_Protocol/README +++ b/TAO/tests/RTCORBA/Server_Protocol/README @@ -10,7 +10,7 @@ and configured with Server Protocol Policy containing a single protocol specified with <-p> (see options section below). The object is registered with child POA if one was created (root poa otherwise) and the server waits for requests. -The client obtains server IOR and makes a single incocation, causing +The client obtains server IOR and makes a single invocation, causing server process to shut down its orb and exit. To run (on Unix): diff --git a/TAO/tests/RTCORBA/Server_Protocol/run_test.pl b/TAO/tests/RTCORBA/Server_Protocol/run_test.pl index a930bec5b03..6e1cafa833b 100755 --- a/TAO/tests/RTCORBA/Server_Protocol/run_test.pl +++ b/TAO/tests/RTCORBA/Server_Protocol/run_test.pl @@ -44,12 +44,12 @@ $server_reverse_nt_conf = PerlACE::LocalFile ("server_reverse_nt$PerlACE::svcco # UIOP only available on Unix. Substitute with alternative tests on Windows. if ($^O eq "MSWin32") { @server_opts = - ("-ORBendpoint iiop://", + ("-ORBSndSock 54321 -ORBendpoint iiop://", "-ORBsvcconf $server_reverse_nt_conf " ."-ORBEndpoint shmiop:// -ORBendpoint iiop://", - "-ORBsvcconf $server_iiop_shmiop_conf " + "-ORBRcvSock 12345 -ORBsvcconf $server_iiop_shmiop_conf " ."-ORBEndpoint iiop:// -ORBEndpoint shmiop:// " ."-p 1413566210"); diff --git a/TAO/tests/RTCORBA/Server_Protocol/server.cpp b/TAO/tests/RTCORBA/Server_Protocol/server.cpp index f9ada095627..3a4be65d625 100644 --- a/TAO/tests/RTCORBA/Server_Protocol/server.cpp +++ b/TAO/tests/RTCORBA/Server_Protocol/server.cpp @@ -7,6 +7,7 @@ #include "tao/ORB_Core.h" #include "tao/Policy_Set.h" #include "ace/Get_Opt.h" +#include "tao/PortableServer/POA.h" class Test_i : public POA_Test { @@ -85,16 +86,22 @@ parse_args (int argc, char *argv[]) } int -check_default_server_protocol (CORBA::ORB_ptr orb - ACE_ENV_ARG_DECL) +check_server_protocol_at_root_poa (CORBA::ORB_ptr orb, + PortableServer::POA_ptr poa + ACE_ENV_ARG_DECL) { // Users should never write code like below. // It is for testing purposes only! (Unfortunately, there - // is no standard way to access ORB default policies). + // is no standard way to access POA policies). + TAO_POA &tao_poa = + dynamic_cast<TAO_POA &> (*poa); + + TAO_POA_Policy_Set &policies = + tao_poa.policies (); + CORBA::Policy_var server_protocol = - orb->orb_core ()->get_default_policies ()->get_policy ( - RTCORBA::SERVER_PROTOCOL_POLICY_TYPE - ACE_ENV_ARG_PARAMETER); + policies.get_cached_policy (TAO_CACHED_POLICY_RT_SERVER_PROTOCOL + ACE_ENV_ARG_PARAMETER); ACE_CHECK_RETURN (-1); RTCORBA::ServerProtocolPolicy_var policy = @@ -112,7 +119,7 @@ check_default_server_protocol (CORBA::ORB_ptr orb ACE_CHECK_RETURN (-1); ACE_DEBUG ((LM_DEBUG, - "\nORB default for ServerProtocolPolicy " + "\nRoot POA ServerProtocolPolicy " "contains %u protocols:\n", protocols->length ())); for (CORBA::ULong i = 0; i < protocols->length (); ++i) @@ -267,9 +274,10 @@ main (int argc, char *argv[]) ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - // Check ORB default ServerProtocol configuration. - int result = check_default_server_protocol (orb.in () - ACE_ENV_ARG_PARAMETER); + // Check ServerProtocol configurations. + int result = check_server_protocol_at_root_poa (orb.in (), + root_poa.in () + ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; if (result != 0) return -1; |