diff options
author | bala <balanatarajan@users.noreply.github.com> | 2002-04-12 19:43:25 +0000 |
---|---|---|
committer | bala <balanatarajan@users.noreply.github.com> | 2002-04-12 19:43:25 +0000 |
commit | 7b3700a7c380f1533b4367d999a303a9bfcba841 (patch) | |
tree | e7e885faf0922dc4062ebfc5041aa964e36aa88f | |
parent | d1ba71698652c9c25edd26dadb0a2f7a947323a0 (diff) | |
download | ATCD-7b3700a7c380f1533b4367d999a303a9bfcba841.tar.gz |
ChangeLogTag: Fri Apr 12 14:14:01 2002 Balachandran Natarajan <bala@cs.wustl.edu>
-rw-r--r-- | TAO/tao/ChangeLog | 33 | ||||
-rw-r--r-- | TAO/tao/Connector_Registry.cpp | 2 | ||||
-rw-r--r-- | TAO/tao/Connector_Registry.h | 11 | ||||
-rw-r--r-- | TAO/tao/Connector_Registry.i | 5 | ||||
-rw-r--r-- | TAO/tao/IIOP_Connector.cpp | 223 | ||||
-rw-r--r-- | TAO/tao/IIOP_Connector.h | 7 | ||||
-rw-r--r-- | TAO/tao/Invocation.cpp | 8 | ||||
-rw-r--r-- | TAO/tao/Strategies/DIOP_Connector.cpp | 7 | ||||
-rw-r--r-- | TAO/tao/Strategies/DIOP_Connector.h | 7 | ||||
-rw-r--r-- | TAO/tao/Strategies/SHMIOP_Connector.cpp | 130 | ||||
-rw-r--r-- | TAO/tao/Strategies/SHMIOP_Connector.h | 8 | ||||
-rw-r--r-- | TAO/tao/Strategies/UIOP_Connector.cpp | 124 | ||||
-rw-r--r-- | TAO/tao/Strategies/UIOP_Connector.h | 7 | ||||
-rw-r--r-- | TAO/tao/Transport_Connector.cpp | 37 | ||||
-rw-r--r-- | TAO/tao/Transport_Connector.h | 17 |
15 files changed, 330 insertions, 296 deletions
diff --git a/TAO/tao/ChangeLog b/TAO/tao/ChangeLog index 94c8469e0fc..d50a9cb9616 100644 --- a/TAO/tao/ChangeLog +++ b/TAO/tao/ChangeLog @@ -1,3 +1,36 @@ +Fri Apr 12 14:14:01 2002 Balachandran Natarajan <bala@cs.wustl.edu> + + * tao/Connector_Registry.cpp: + * tao/Connector_Registry.h: + * tao/Connector_Registry.i: Added a new method, get_connector () + which returns a TAO_Connector based on a TAO_Endpoint. Need to + deprecate connect (). The connector registry should not be + involved in doing active connects. + + * tao/Invocation.cpp: Used the connector_registry's get_connector + () to retrieve a connector before calling a connect on it. + + * tao/Transport_Connector.cpp: + * tao/Transport_Connector.h: Consolidated some of the code from + different protocols. All the transports before setting up a + connection look for a connection in cache. That part of the code + that looks for a connection in the cache has been moved in + here. If a connection is not found in cache, the control is + transferred to the underlying transports to set up a + connection. + + * tao/IIOP_Connector.cpp: + * tao/IIOP_Connector.h: + * tao/Strategies/DIOP_Connector.cpp: + * tao/Strategies/DIOP_Connector.h: + * tao/Strategies/SHMIOP_Connector.cpp: + * tao/Strategies/SHMIOP_Connector.h: + * tao/Strategies/UIOP_Connector.cpp: + * tao/Strategies/UIOP_Connector.h : Renamed connect () to be + make_connect (). This method now exclusively sets up an active + connection from the client and adds the connection in cache. + + Thu Apr 11 17:26:21 2002 Balachandran Natarajan <bala@cs.wustl.edu> * tao/Strategies/SHMIOP_Connector.cpp: diff --git a/TAO/tao/Connector_Registry.cpp b/TAO/tao/Connector_Registry.cpp index 0b5625ea62c..94b9c251c55 100644 --- a/TAO/tao/Connector_Registry.cpp +++ b/TAO/tao/Connector_Registry.cpp @@ -54,6 +54,8 @@ TAO_Connector_Registry::get_connector (CORBA::ULong tag) return 0; } + + int TAO_Connector_Registry::open (TAO_ORB_Core *orb_core) { diff --git a/TAO/tao/Connector_Registry.h b/TAO/tao/Connector_Registry.h index db921bd8a18..481b1281a37 100644 --- a/TAO/tao/Connector_Registry.h +++ b/TAO/tao/Connector_Registry.h @@ -18,13 +18,13 @@ #define TAO_CONNECTOR_REGISTRY_H #include "ace/pre.h" -#include "tao/corbafwd.h" +#include "corbafwd.h" #if !defined (ACE_LACKS_PRAGMA_ONCE) # pragma once #endif /* ACE_LACKS_PRAGMA_ONCE */ -#include "params.h" +#include "Endpoint.h" // Forward declarations. class ACE_Addr; @@ -65,7 +65,8 @@ public: ~TAO_Connector_Registry (void); /// Return the connector bridges - TAO_Connector *get_connector (CORBA::ULong tag); + TAO_Connector *get_connector (CORBA::ULong tag); + TAO_Connector *get_connector (TAO_Endpoint *ep); /// Initialize all registered connectors. int open (TAO_ORB_Core *orb_core); @@ -74,8 +75,10 @@ public: int close_all (void); - /** + * @@ todo: This method needs to be removed. There should be no need + * for the registry to establish connections. + * * This is where the transport protocol is selected based on some * policy. This member will call the connect member of the * TAO_Connector class which in turn will call the concrete diff --git a/TAO/tao/Connector_Registry.i b/TAO/tao/Connector_Registry.i index f2f5cfd2047..e7c870db957 100644 --- a/TAO/tao/Connector_Registry.i +++ b/TAO/tao/Connector_Registry.i @@ -1,5 +1,10 @@ // -*- C++ -*- // $Id$ +ACE_INLINE TAO_Connector * +TAO_Connector_Registry::get_connector (TAO_Endpoint *ep) +{ + return this->get_connector (ep->tag ()); +} ACE_INLINE TAO_ConnectorSetIterator TAO_Connector_Registry::begin (void) diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp index 6ef748bb3e5..ff5a3c56f2e 100644 --- a/TAO/tao/IIOP_Connector.cpp +++ b/TAO/tao/IIOP_Connector.cpp @@ -106,9 +106,8 @@ TAO_IIOP_Connector::close (void) } int -TAO_IIOP_Connector::connect (TAO_GIOP_Invocation *invocation, - TAO_Transport_Descriptor_Interface *desc - ACE_ENV_ARG_DECL_NOT_USED) +TAO_IIOP_Connector::make_connect (TAO_GIOP_Invocation *invocation, + TAO_Transport_Descriptor_Interface *desc) { TAO_Transport *&transport = invocation->transport (); ACE_Time_Value *max_wait_time = invocation->max_wait_time (); @@ -117,123 +116,107 @@ TAO_IIOP_Connector::connect (TAO_GIOP_Invocation *invocation, if (endpoint->tag () != TAO_TAG_IIOP_PROFILE) return -1; - TAO_IIOP_Endpoint *iiop_endpoint = - ACE_dynamic_cast (TAO_IIOP_Endpoint *, - endpoint ); - if (iiop_endpoint == 0) - return -1; - - const ACE_INET_Addr &remote_address = - iiop_endpoint->object_addr (); - - // Verify that the remote ACE_INET_Addr was initialized properly. - // Failure can occur if hostname lookup failed when initializing the - // remote ACE_INET_Addr. - if (remote_address.get_type () != AF_INET) - { - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("TAO (%P|%t) IIOP connection failed.\n") - ACE_LIB_TEXT ("TAO (%P|%t) This is most likely ") - ACE_LIB_TEXT ("due to a hostname lookup ") - ACE_LIB_TEXT ("failure.\n"))); - } - - return -1; - } - - int result = 0; - TAO_IIOP_Connection_Handler *svc_handler = 0; - TAO_Transport *base_transport = 0; - - // Check the Cache first for connections - // If transport found, reference count is incremented on assignment - if (this->orb_core ()->lane_resources ().transport_cache ().find_transport (desc, - base_transport) == 0) - { - if (TAO_debug_level > 2) - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("(%P|%t) IIOP_Connector::connect - ") - ACE_LIB_TEXT ("got an existing transport with id %d\n"), - base_transport->id ())); - } - else - { - if (TAO_debug_level > 2) - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("(%P|%t) IIOP_Connector::connect - ") - ACE_LIB_TEXT ("making a new connection\n"))); - - // Purge connections (if necessary) - this->orb_core ()->lane_resources ().transport_cache ().purge (); - - // @@ This needs to change in the next round when we implement a - // policy that will not allow new connections when a connection - // is busy. - if (max_wait_time != 0) - { - ACE_Synch_Options synch_options (ACE_Synch_Options::USE_TIMEOUT, - *max_wait_time); - - // We obtain the transport in the <svc_handler> variable. As - // we know now that the connection is not available in Cache - // we can make a new connection - result = this->base_connector_.connect (svc_handler, - remote_address, - synch_options); - } - else - { - // We obtain the transport in the <svc_handler> variable. As - // we know now that the connection is not available in Cache - // we can make a new connection - result = this->base_connector_.connect (svc_handler, - remote_address); - } - - if (result == -1) - { - // Give users a clue to the problem. - if (TAO_debug_level) - { - ACE_DEBUG ((LM_ERROR, - ACE_LIB_TEXT ("(%P|%t) %s:%u, connection to ") - ACE_LIB_TEXT ("%s:%d failed (%p)\n"), - ACE_TEXT_CHAR_TO_TCHAR(__FILE__), - __LINE__, - ACE_TEXT_CHAR_TO_TCHAR(iiop_endpoint->host ()), - iiop_endpoint->port (), - ACE_LIB_TEXT ("errno"))); - } - return -1; - } - - if (TAO_debug_level > 2) - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("(%P|%t) IIOP_Connector::connect - ") - ACE_LIB_TEXT ("new connection on HANDLE %d\n"), - svc_handler->peer ().get_handle ())); - - base_transport = TAO_Transport::_duplicate (svc_handler->transport ()); - // Add the handler to Cache - int retval = - this->orb_core ()->lane_resources ().transport_cache ().cache_transport (desc, - base_transport); - - if (retval != 0 && TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_LIB_TEXT ("(%P|%t) IIOP_Connector::connect ") - ACE_LIB_TEXT ("could not add the new connection to Cache \n"))); - } - } - - // No need to _duplicate and release since base_transport - // is going out of scope. transport now has control of base_transport. - transport = base_transport; - - return 0; + TAO_IIOP_Endpoint *iiop_endpoint = + ACE_dynamic_cast (TAO_IIOP_Endpoint *, + endpoint ); + if (iiop_endpoint == 0) + return -1; + + const ACE_INET_Addr &remote_address = + iiop_endpoint->object_addr (); + + // Verify that the remote ACE_INET_Addr was initialized properly. + // Failure can occur if hostname lookup failed when initializing the + // remote ACE_INET_Addr. + if (remote_address.get_type () != AF_INET) + { + if (TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("TAO (%P|%t) IIOP connection failed.\n") + ACE_LIB_TEXT ("TAO (%P|%t) This is most likely ") + ACE_LIB_TEXT ("due to a hostname lookup ") + ACE_LIB_TEXT ("failure.\n"))); + } + + return -1; + } + + int result = 0; + TAO_IIOP_Connection_Handler *svc_handler = 0; + TAO_Transport *base_transport; + + if (TAO_debug_level > 2) + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("(%P|%t) IIOP_Connector::connect - ") + ACE_LIB_TEXT ("making a new connection\n"))); + + // Purge connections (if necessary) + // @@TODO: This is not the right place for this! + this->orb_core ()->lane_resources ().transport_cache ().purge (); + + // @@todo: Need to add code for non-blocking connects.. + if (max_wait_time != 0) + { + ACE_Synch_Options synch_options (ACE_Synch_Options::USE_TIMEOUT, + *max_wait_time); + + // We obtain the transport in the <svc_handler> variable. As + // we know now that the connection is not available in Cache + // we can make a new connection + result = this->base_connector_.connect (svc_handler, + remote_address, + synch_options); + } + else + { + // We obtain the transport in the <svc_handler> variable. As + // we know now that the connection is not available in Cache + // we can make a new connection + result = this->base_connector_.connect (svc_handler, + remote_address); + } + + if (result == -1) + { + // Give users a clue to the problem. + if (TAO_debug_level) + { + ACE_DEBUG ((LM_ERROR, + ACE_LIB_TEXT ("(%P|%t) %s:%u, connection to ") + ACE_LIB_TEXT ("%s:%d failed (%p)\n"), + ACE_TEXT_CHAR_TO_TCHAR(__FILE__), + __LINE__, + ACE_TEXT_CHAR_TO_TCHAR(iiop_endpoint->host ()), + iiop_endpoint->port (), + ACE_LIB_TEXT ("errno"))); + } + return -1; + } + + if (TAO_debug_level > 2) + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("(%P|%t) IIOP_Connector::connect - ") + ACE_LIB_TEXT ("new connection on HANDLE %d\n"), + svc_handler->peer ().get_handle ())); + + base_transport = TAO_Transport::_duplicate (svc_handler->transport ()); + + // Add the handler to Cache + int retval = + this->orb_core ()->lane_resources ().transport_cache ().cache_transport (desc, + base_transport); + + if (retval != 0 && TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("(%P|%t) IIOP_Connector::connect ") + ACE_LIB_TEXT ("could not add the new connection to Cache \n"))); + } + + transport = base_transport; + + return 0; } diff --git a/TAO/tao/IIOP_Connector.h b/TAO/tao/IIOP_Connector.h index ce4d7ee9c0a..da69ea9e24d 100644 --- a/TAO/tao/IIOP_Connector.h +++ b/TAO/tao/IIOP_Connector.h @@ -56,9 +56,6 @@ public: // Transport_Connector.h int open (TAO_ORB_Core *orb_core); int close (void); - int connect (TAO_GIOP_Invocation *invocation, - TAO_Transport_Descriptor_Interface *desc - ACE_ENV_ARG_DECL); TAO_Profile *create_profile (TAO_InputCDR& cdr); virtual int check_prefix (const char *endpoint); @@ -66,6 +63,10 @@ public: virtual char object_key_delimiter (void) const; protected: + // = The TAO_Connector methods, please check the documentation on + // Transport_Connector.h + int make_connect (TAO_GIOP_Invocation *invocation, + TAO_Transport_Descriptor_Interface *desc); /// More TAO_Connector methods, please check the documentation on /// Transport_Connector.h diff --git a/TAO/tao/Invocation.cpp b/TAO/tao/Invocation.cpp index f9cacfbd200..ebf3fdf7fa9 100644 --- a/TAO/tao/Invocation.cpp +++ b/TAO/tao/Invocation.cpp @@ -14,6 +14,7 @@ #include "Transport_Mux_Strategy.h" #include "Bind_Dispatcher_Guard.h" #include "Endpoint.h" +#include "Transport_Connector.h" #include "GIOP_Utils.h" #include "ORB_Core.h" @@ -247,10 +248,9 @@ TAO_GIOP_Invocation::perform_call (TAO_Transport_Descriptor_Interface &desc } // Obtain a connection. - int result = conn_reg->connect (this, - &desc - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (1); + int result = + conn_reg->get_connector (desc.endpoint ())->connect (this, + &desc); if (result == 0) { diff --git a/TAO/tao/Strategies/DIOP_Connector.cpp b/TAO/tao/Strategies/DIOP_Connector.cpp index 8a08d9a9a9b..f28e087cfd5 100644 --- a/TAO/tao/Strategies/DIOP_Connector.cpp +++ b/TAO/tao/Strategies/DIOP_Connector.cpp @@ -93,12 +93,11 @@ TAO_DIOP_Connector::close (void) } int -TAO_DIOP_Connector::connect (TAO_GIOP_Invocation *invocation, - TAO_Transport_Descriptor_Interface *desc - ACE_ENV_ARG_DECL_NOT_USED) +TAO_DIOP_Connector::make_connect (TAO_GIOP_Invocation *invocation, + TAO_Transport_Descriptor_Interface *desc) { TAO_Transport *&transport = invocation->transport (); - // ACE_Time_Value *max_wait_time = invocation->max_wait_time (); + TAO_Endpoint *endpoint = desc->endpoint (); if (endpoint->tag () != TAO_TAG_UDP_PROFILE) diff --git a/TAO/tao/Strategies/DIOP_Connector.h b/TAO/tao/Strategies/DIOP_Connector.h index 2e1f2ce3d93..35c9ea6f73c 100644 --- a/TAO/tao/Strategies/DIOP_Connector.h +++ b/TAO/tao/Strategies/DIOP_Connector.h @@ -52,9 +52,7 @@ public: // Pluggable.h int open (TAO_ORB_Core *orb_core); int close (void); - int connect (TAO_GIOP_Invocation *invocation, - TAO_Transport_Descriptor_Interface *desc - ACE_ENV_ARG_DECL); + TAO_Profile *create_profile (TAO_InputCDR& cdr); virtual int check_prefix (const char *endpoint); @@ -65,6 +63,9 @@ protected: /// = More TAO_Connector methods, please check the documentation on /// Pluggable.h + int make_connect (TAO_GIOP_Invocation *invocation, + TAO_Transport_Descriptor_Interface *desc); + virtual TAO_Profile * make_profile (ACE_ENV_SINGLE_ARG_DECL); /// Obtain tcp properties that must be used by this connector, i.e., diff --git a/TAO/tao/Strategies/SHMIOP_Connector.cpp b/TAO/tao/Strategies/SHMIOP_Connector.cpp index 14983eebd08..8b6f21e84c9 100644 --- a/TAO/tao/Strategies/SHMIOP_Connector.cpp +++ b/TAO/tao/Strategies/SHMIOP_Connector.cpp @@ -116,9 +116,8 @@ TAO_SHMIOP_Connector::close (void) } int -TAO_SHMIOP_Connector::connect (TAO_GIOP_Invocation *invocation, - TAO_Transport_Descriptor_Interface *desc - ACE_ENV_ARG_DECL_NOT_USED) +TAO_SHMIOP_Connector::make_connect (TAO_GIOP_Invocation *invocation, + TAO_Transport_Descriptor_Interface *desc) { if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, @@ -163,88 +162,71 @@ TAO_SHMIOP_Connector::connect (TAO_GIOP_Invocation *invocation, TAO_SHMIOP_Connection_Handler *svc_handler = 0; TAO_Transport *base_transport = 0; - // Check the Cache first for connections - // If transport found, reference count is incremented on assignment - if (this->orb_core ()->lane_resources ().transport_cache ().find_transport (desc, - base_transport) == 0) + if (TAO_debug_level > 2) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) SHMIOP_Connector::connect ") + ACE_TEXT ("making a new connection \n"))); + + // Purge connections (if necessary) + this->orb_core ()->lane_resources ().transport_cache ().purge (); + + if (max_wait_time != 0) { - if (TAO_debug_level > 5) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) SHMIOP_Connector::connect ") - ACE_TEXT ("got an existing transport with id %d \n"), - base_transport->id ())); + ACE_Synch_Options synch_options (ACE_Synch_Options::USE_TIMEOUT, + *max_wait_time); + + // We obtain the transport in the <svc_handler> variable. As + // we know now that the connection is not available in Cache + // we can make a new connection + result = this->base_connector_.connect (svc_handler, + remote_address, + synch_options); } else { - if (TAO_debug_level > 2) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) SHMIOP_Connector::connect ") - ACE_TEXT ("making a new connection \n"))); - - // Purge connections (if necessary) - this->orb_core ()->lane_resources ().transport_cache ().purge (); - - // @@ This needs to change in the next round when we implement a - // policy that will not allow new connections when a connection - // is busy. - if (max_wait_time != 0) - { - ACE_Synch_Options synch_options (ACE_Synch_Options::USE_TIMEOUT, - *max_wait_time); + // We obtain the transport in the <svc_handler> variable. As + // we know now that the connection is not available in Cache + // we can make a new connection + result = this->base_connector_.connect (svc_handler, + remote_address); + } - // We obtain the transport in the <svc_handler> variable. As - // we know now that the connection is not available in Cache - // we can make a new connection - result = this->base_connector_.connect (svc_handler, - remote_address, - synch_options); - } - else - { - // We obtain the transport in the <svc_handler> variable. As - // we know now that the connection is not available in Cache - // we can make a new connection - result = this->base_connector_.connect (svc_handler, - remote_address); - } + if (TAO_debug_level > 4) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) SHMIOP_Connector::connect ") + ACE_TEXT ("The result is <%d> \n"), result)); - if (TAO_debug_level > 4) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) SHMIOP_Connector::connect ") - ACE_TEXT ("The result is <%d> \n"), result)); + if (result == -1) + { + char buffer [MAXNAMELEN * 2]; + endpoint->addr_to_string (buffer, + (MAXNAMELEN * 2) - 1); - if (result == -1) + // Give users a clue to the problem. + if (TAO_debug_level > 0) { - char buffer [MAXNAMELEN * 2]; - endpoint->addr_to_string (buffer, - (MAXNAMELEN * 2) - 1); - - // Give users a clue to the problem. - if (TAO_debug_level > 0) - { - ACE_DEBUG ((LM_ERROR, - ACE_TEXT ("(%P|%t) %s:%u, connection to ") - ACE_TEXT ("%s failed (%p)\n"), - __FILE__, - __LINE__, - buffer, - ACE_TEXT ("errno"))); - } - return -1; + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("(%P|%t) %s:%u, connection to ") + ACE_TEXT ("%s failed (%p)\n"), + __FILE__, + __LINE__, + buffer, + ACE_TEXT ("errno"))); } + return -1; + } - base_transport = TAO_Transport::_duplicate (svc_handler->transport ()); - // Add the handler to Cache - int retval = - this->orb_core ()->lane_resources ().transport_cache ().cache_transport (desc, - svc_handler->transport ()); + base_transport = TAO_Transport::_duplicate (svc_handler->transport ()); + // Add the handler to Cache + int retval = + this->orb_core ()->lane_resources ().transport_cache ().cache_transport (desc, + svc_handler->transport ()); - if (retval != 0 && TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) SHMIOP_Connector::connect ") - ACE_TEXT ("could not add the new connection to Cache \n"))); - } + if (retval != 0 && TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) SHMIOP_Connector::connect ") + ACE_TEXT ("could not add the new connection to Cache \n"))); } // No need to _duplicate and release since base_transport diff --git a/TAO/tao/Strategies/SHMIOP_Connector.h b/TAO/tao/Strategies/SHMIOP_Connector.h index 6262183722a..fce2a5e587e 100644 --- a/TAO/tao/Strategies/SHMIOP_Connector.h +++ b/TAO/tao/Strategies/SHMIOP_Connector.h @@ -58,9 +58,7 @@ public: // Pluggable.h int open (TAO_ORB_Core *orb_core); int close (void); - int connect (TAO_GIOP_Invocation *invocation, - TAO_Transport_Descriptor_Interface *desc - ACE_ENV_ARG_DECL); + TAO_Profile *create_profile (TAO_InputCDR& cdr); virtual int check_prefix (const char *endpoint); @@ -68,9 +66,11 @@ public: virtual char object_key_delimiter (void) const; protected: - // = More TAO_Connector methods, please check the documentation on // Pluggable.h + int make_connect (TAO_GIOP_Invocation *invocation, + TAO_Transport_Descriptor_Interface *desc); + virtual TAO_Profile *make_profile (ACE_ENV_SINGLE_ARG_DECL); public: diff --git a/TAO/tao/Strategies/UIOP_Connector.cpp b/TAO/tao/Strategies/UIOP_Connector.cpp index 3dff3014fc8..77279113a86 100644 --- a/TAO/tao/Strategies/UIOP_Connector.cpp +++ b/TAO/tao/Strategies/UIOP_Connector.cpp @@ -113,9 +113,8 @@ TAO_UIOP_Connector::close (void) int -TAO_UIOP_Connector::connect (TAO_GIOP_Invocation *invocation, - TAO_Transport_Descriptor_Interface *desc - ACE_ENV_ARG_DECL_NOT_USED) +TAO_UIOP_Connector::make_connect (TAO_GIOP_Invocation *invocation, + TAO_Transport_Descriptor_Interface *desc) { if (TAO_debug_level > 0) ACE_DEBUG ((LM_DEBUG, @@ -150,84 +149,67 @@ TAO_UIOP_Connector::connect (TAO_GIOP_Invocation *invocation, TAO_UIOP_Connection_Handler *svc_handler = 0; TAO_Transport *base_transport = 0; - // Check the Cache first for connections - // If transport found, reference count is incremented on assignment - if (this->orb_core ()->lane_resources ().transport_cache ().find_transport (desc, - base_transport) == 0) + if (TAO_debug_level > 2) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) UIOP_Connector::connect ") + ACE_TEXT ("making a new connection \n"))); + + // Purge connections (if necessary) + this->orb_core ()->lane_resources ().transport_cache ().purge (); + + if (max_wait_time != 0) { - if (TAO_debug_level > 5) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) UIOP_Connector::connect ") - ACE_TEXT ("got an existing transport with id %d \n"), - base_transport->id ())); + ACE_Synch_Options synch_options (ACE_Synch_Options::USE_TIMEOUT, + *max_wait_time); + + // We obtain the transport in the <svc_handler> variable. As + // we know now that the connection is not available in Cache + // we can make a new connection + result = this->base_connector_.connect (svc_handler, + remote_address, + synch_options); } else { - if (TAO_debug_level > 2) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) UIOP_Connector::connect ") - ACE_TEXT ("making a new connection \n"))); - - // Purge connections (if necessary) - this->orb_core ()->lane_resources ().transport_cache ().purge (); - - // @@ This needs to change in the next round when we implement a - // policy that will not allow new connections when a connection - // is busy. - if (max_wait_time != 0) - { - ACE_Synch_Options synch_options (ACE_Synch_Options::USE_TIMEOUT, - *max_wait_time); - - // We obtain the transport in the <svc_handler> variable. As - // we know now that the connection is not available in Cache - // we can make a new connection - result = this->base_connector_.connect (svc_handler, - remote_address, - synch_options); - } - else - { - // We obtain the transport in the <svc_handler> variable. As - // we know now that the connection is not available in Cache - // we can make a new connection - result = this->base_connector_.connect (svc_handler, - remote_address); - } + // We obtain the transport in the <svc_handler> variable. As + // we know now that the connection is not available in Cache + // we can make a new connection + result = this->base_connector_.connect (svc_handler, + remote_address); + } - if (TAO_debug_level > 0) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) UIOP_Connector::connect ") - ACE_TEXT ("The result is <%d> \n"), result)); + if (TAO_debug_level > 0) + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) UIOP_Connector::connect ") + ACE_TEXT ("The result is <%d> \n"), result)); - if (result == -1) + if (result == -1) + { + // Give users a clue to the problem. + if (TAO_debug_level) { - // Give users a clue to the problem. - if (TAO_debug_level) - { - ACE_DEBUG ((LM_ERROR, - ACE_TEXT ("(%P|%t) %s:%u, connection to ") - ACE_TEXT ("%s failed (%p)\n"), - __FILE__, - __LINE__, - uiop_endpoint->rendezvous_point (), - ACE_TEXT ("errno"))); - } - return -1; + ACE_DEBUG ((LM_ERROR, + ACE_TEXT ("(%P|%t) %s:%u, connection to ") + ACE_TEXT ("%s failed (%p)\n"), + __FILE__, + __LINE__, + uiop_endpoint->rendezvous_point (), + ACE_TEXT ("errno"))); } + return -1; + } - base_transport = TAO_Transport::_duplicate (svc_handler->transport ()); - // Add the handler to Cache - int retval = - this->orb_core ()->lane_resources ().transport_cache ().cache_transport (desc, - base_transport); + base_transport = TAO_Transport::_duplicate (svc_handler->transport ()); + // Add the handler to Cache + int retval = + this->orb_core ()->lane_resources ().transport_cache ().cache_transport (desc, + base_transport); - if (retval != 0 && TAO_debug_level > 0) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) UIOP_Connector::connect ") - ACE_TEXT ("could not add the new connection to Cache \n"))); - } + if (retval != 0 && TAO_debug_level > 0) + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) UIOP_Connector::connect ") + ACE_TEXT ("could not add the new connection to Cache \n"))); } // No need to _duplicate and release since base_transport diff --git a/TAO/tao/Strategies/UIOP_Connector.h b/TAO/tao/Strategies/UIOP_Connector.h index 3bc631d9423..3a4d3e4311d 100644 --- a/TAO/tao/Strategies/UIOP_Connector.h +++ b/TAO/tao/Strategies/UIOP_Connector.h @@ -62,9 +62,7 @@ public: //@{ int open (TAO_ORB_Core *orb_core); int close (void); - int connect (TAO_GIOP_Invocation *invocation, - TAO_Transport_Descriptor_Interface *desc - ACE_ENV_ARG_DECL); + TAO_Profile *create_profile (TAO_InputCDR& cdr); virtual int check_prefix (const char *endpoint); @@ -80,6 +78,9 @@ protected: * Please check the documentation in Pluggable.h. */ //@{ + int make_connect (TAO_GIOP_Invocation *invocation, + TAO_Transport_Descriptor_Interface *desc); + virtual TAO_Profile *make_profile (ACE_ENV_SINGLE_ARG_DECL); /// Obtains uiop properties that must be used by this connector, i.e., diff --git a/TAO/tao/Transport_Connector.cpp b/TAO/tao/Transport_Connector.cpp index ff25e1c675a..6cb3dc997bd 100644 --- a/TAO/tao/Transport_Connector.cpp +++ b/TAO/tao/Transport_Connector.cpp @@ -1,7 +1,11 @@ #include "Transport_Connector.h" +#include "Transport.h" +#include "ORB_Core.h" +#include "Invocation.h" #include "MProfile.h" #include "Profile.h" #include "Environment.h" +#include "Thread_Lane_Resources.h" #include "debug.h" @@ -197,3 +201,36 @@ TAO_Connector::make_mprofile (const char *string, return 0; // Success } + +int +TAO_Connector::connect (TAO_GIOP_Invocation *invocation, + TAO_Transport_Descriptor_Interface *desc + ACE_ENV_ARG_DECL_NOT_USED) +{ + TAO_Transport *base_transport = 0; + + // Check the Cache first for connections + // If transport found, reference count is incremented on assignment + if (this->orb_core ()->lane_resources ().transport_cache ().find_transport (desc, + base_transport) == 0) + { + if (TAO_debug_level > 2) + ACE_DEBUG ((LM_DEBUG, + ACE_LIB_TEXT ("(%P|%t) IIOP_Connector::connect - ") + ACE_LIB_TEXT ("got an existing transport with id %d\n"), + base_transport->id ())); + + TAO_Transport *&transport = invocation->transport (); + + // No need to _duplicate and release since base_transport + // is going out of scope. Transport now has control of + // base_transport. + transport = base_transport; + + // Succesful + return 0; + } + + return this->make_connect (invocation, + desc); +} diff --git a/TAO/tao/Transport_Connector.h b/TAO/tao/Transport_Connector.h index 8a39565d65e..9773a82f756 100644 --- a/TAO/tao/Transport_Connector.h +++ b/TAO/tao/Transport_Connector.h @@ -70,13 +70,13 @@ public: virtual int close (void) = 0; /** - * To support pluggable we need to abstract away the connect() - * method so it can be called from the GIOP code independant of the - * actual transport protocol in use. + * To support pluggable we need to abstract away the details of the + * connect () method so it can be called from the invocation code + * independent of the actual transport protocol in use. */ - virtual int connect (TAO_GIOP_Invocation *invocation, - TAO_Transport_Descriptor_Interface *desc - ACE_ENV_ARG_DECL) = 0; + int connect (TAO_GIOP_Invocation *invocation, + TAO_Transport_Descriptor_Interface *desc + ACE_ENV_ARG_DECL); /// Initial set of connections to be established. /* @@ -101,6 +101,11 @@ protected: /// Create a profile with a given endpoint. virtual TAO_Profile *make_profile (ACE_ENV_SINGLE_ARG_DECL) = 0; + /// Do an actual connect using the underlying transport to make a + /// connection + virtual int make_connect (TAO_GIOP_Invocation *invocation, + TAO_Transport_Descriptor_Interface *desc) = 0; + /// Set the ORB Core pointer void orb_core (TAO_ORB_Core *orb_core); |