#include <SHMIOP_Connection_Handler.h>
Inheritance diagram for TAO_SHMIOP_Connection_Handler:
Public Member Functions | |
TAO_SHMIOP_Connection_Handler (ACE_Thread_Manager *t=0) | |
Constructor. | |
TAO_SHMIOP_Connection_Handler (TAO_ORB_Core *orb_core, CORBA::Boolean flag) | |
Constructor. | |
~TAO_SHMIOP_Connection_Handler (void) | |
Destructor. | |
virtual int | open (void *) |
int | close (u_long=0) |
int | add_transport_to_cache (void) |
Add ourselves to Cache. | |
virtual int | open_handler (void *) |
Event Handler overloads | |
virtual int | resume_handler (void) |
virtual int | close_connection (void) |
virtual int | handle_input (ACE_HANDLE) |
virtual int | handle_output (ACE_HANDLE) |
virtual int | handle_close (ACE_HANDLE, ACE_Reactor_Mask) |
virtual int | handle_timeout (const ACE_Time_Value ¤t_time, const void *act=0) |
Protected Member Functions | |
TAO_Connection Handler overloads | |
virtual int | release_os_resources (void) |
Private Attributes | |
int | resume_flag_ |
The Connection handler which is common for the Acceptor and the Connector
Definition at line 44 of file SHMIOP_Connection_Handler.h.
|
Constructor.
Definition at line 29 of file SHMIOP_Connection_Handler.cpp. References ACE_ASSERT, and TAO_SHMIOP_SVC_HANDLER.
00030 : TAO_SHMIOP_SVC_HANDLER (t, 0 , 0), 00031 TAO_Connection_Handler (0) 00032 { 00033 // This constructor should *never* get called, it is just here to 00034 // make the compiler happy: the default implementation of the 00035 // Creation_Strategy requires a constructor with that signature, we 00036 // don't use that implementation, but some (most?) compilers 00037 // instantiate it anyway. 00038 ACE_ASSERT (0); 00039 } |
|
Constructor.
Definition at line 42 of file SHMIOP_Connection_Handler.cpp. References ACE_NEW, TAO_SHMIOP_SVC_HANDLER, and TAO_Connection_Handler::transport().
00044 : TAO_SHMIOP_SVC_HANDLER (orb_core->thr_mgr (), 0, 0), 00045 TAO_Connection_Handler (orb_core) 00046 { 00047 TAO_SHMIOP_Transport* specific_transport = 0; 00048 ACE_NEW (specific_transport, 00049 TAO_SHMIOP_Transport(this, orb_core, flag)); 00050 00051 // store this pointer (indirectly increment ref count) 00052 this->transport (specific_transport); 00053 } |
|
Destructor.
Definition at line 56 of file SHMIOP_Connection_Handler.cpp. References TAO_Connection_Handler::transport().
00057 { 00058 delete this->transport (); 00059 } |
|
Add ourselves to Cache.
Definition at line 231 of file SHMIOP_Connection_Handler.cpp. References TAO::Transport_Cache_Manager::cache_idle_transport(), TAO_ORB_Core::lane_resources(), TAO_Connection_Handler::orb_core(), ACE_Svc_Handler<, >::peer(), and TAO_Thread_Lane_Resources::transport_cache().
00232 { 00233 ACE_INET_Addr addr; 00234 00235 // Get the peername. 00236 if (this->peer ().get_remote_addr (addr) == -1) 00237 return -1; 00238 00239 // Construct an SHMIOP_Endpoint object 00240 TAO_SHMIOP_Endpoint endpoint ( 00241 addr, 00242 this->orb_core()->orb_params()->use_dotted_decimal_addresses ()); 00243 00244 // Construct a property object 00245 TAO_Base_Transport_Property prop (&endpoint); 00246 00247 TAO::Transport_Cache_Manager &cache = 00248 this->orb_core ()->lane_resources ().transport_cache (); 00249 00250 // Add the handler to Cache 00251 return cache.cache_idle_transport (&prop, 00252 this->transport ()); 00253 } |
|
Close called by the Acceptor or Connector when connection establishment fails. Reimplemented from ACE_Svc_Handler<, >. Definition at line 219 of file SHMIOP_Connection_Handler.cpp. References TAO_Connection_Handler::close_handler(). Referenced by handle_timeout(), and TAO_SHMIOP_Connector::make_connection().
00220 { 00221 return this->close_handler (); 00222 } |
|
Implements TAO_Connection_Handler. Definition at line 174 of file SHMIOP_Connection_Handler.cpp. References TAO_Connection_Handler::close_connection_eh(). Referenced by handle_output().
00175 { 00176 return this->close_connection_eh (this); 00177 } |
|
Reimplemented from ACE_Svc_Handler<, >. Definition at line 211 of file SHMIOP_Connection_Handler.cpp. References ACE_ASSERT.
00213 { 00214 ACE_ASSERT (0); 00215 return 0; 00216 } |
|
Implements TAO_Connection_Handler. Definition at line 180 of file SHMIOP_Connection_Handler.cpp. References TAO_Connection_Handler::handle_input_eh().
00181 { 00182 return this->handle_input_eh (h, this); 00183 } |
|
Reimplemented from ACE_Event_Handler. Definition at line 186 of file SHMIOP_Connection_Handler.cpp. References close_connection(), and TAO_Connection_Handler::handle_output_eh().
00187 { 00188 int result = 00189 this->handle_output_eh (handle, this); 00190 00191 if (result == -1) 00192 { 00193 this->close_connection (); 00194 return 0; 00195 } 00196 00197 return result; 00198 } |
|
Reimplemented from ACE_Svc_Handler<, >. Definition at line 201 of file SHMIOP_Connection_Handler.cpp. References close().
00203 { 00204 // We don't use this upcall for I/O. This is only used by the 00205 // Connector to indicate that the connection timedout. Therefore, 00206 // we should call close(). 00207 return this->close (); 00208 } |
|
Called by the when the handler is completely connected. Argument is unused. Reimplemented from ACE_Svc_Handler<, >. Definition at line 68 of file SHMIOP_Connection_Handler.cpp. References ACE_CATCHANY, ACE_CHECK_RETURN, ACE_DEBUG, ACE_DECLARE_NEW_CORBA_ENV, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_IPPROTO_TCP, ACE_NONBLOCK, ACE_TCHAR, ACE_TEXT, ACE_TRY, ACE_TRY_CHECK, ACE_INET_Addr::addr_to_string(), TAO_Protocols_Hooks::client_protocol_properties_at_orb_level(), TAO_ORB_Core::get_protocols_hooks(), LM_DEBUG, MAXHOSTNAMELEN, TAO_SHMIOP_Protocol_Properties::no_delay_, TAO_ORB_Parameters::nodelay(), TAO_Wait_Strategy::non_blocking(), TAO_Transport::opened_as(), TAO_Connection_Handler::orb_core(), TAO_ORB_Core::orb_params(), ACE_Svc_Handler<, >::peer(), TAO_Transport::post_open(), TAO_SHMIOP_Protocol_Properties::recv_buffer_size_, TAO_SHMIOP_Protocol_Properties::send_buffer_size_, TAO_Protocols_Hooks::server_protocol_properties_at_orb_level(), TAO_Connection_Handler::set_socket_option(), TAO_ORB_Parameters::sock_rcvbuf_size(), TAO_ORB_Parameters::sock_sndbuf_size(), TAO_LF_Event::state_changed(), TAO_debug_level, TAO_Connection_Handler::transport(), and TAO_Transport::wait_strategy(). Referenced by open_handler().
00069 { 00070 TAO_SHMIOP_Protocol_Properties protocol_properties; 00071 00072 // Initialize values from ORB params. 00073 protocol_properties.send_buffer_size_ = 00074 this->orb_core ()->orb_params ()->sock_sndbuf_size (); 00075 protocol_properties.recv_buffer_size_ = 00076 this->orb_core ()->orb_params ()->sock_rcvbuf_size (); 00077 protocol_properties.no_delay_ = 00078 this->orb_core ()->orb_params ()->nodelay (); 00079 00080 TAO_Protocols_Hooks *tph = 00081 this->orb_core ()->get_protocols_hooks (); 00082 00083 bool client = 00084 this->transport ()->opened_as () == TAO::TAO_CLIENT_ROLE;; 00085 00086 ACE_DECLARE_NEW_CORBA_ENV; 00087 00088 ACE_TRY 00089 { 00090 if (client) 00091 { 00092 tph->client_protocol_properties_at_orb_level ( 00093 protocol_properties 00094 ACE_ENV_ARG_PARAMETER); 00095 ACE_TRY_CHECK; 00096 } 00097 else 00098 { 00099 tph->server_protocol_properties_at_orb_level ( 00100 protocol_properties 00101 ACE_ENV_ARG_PARAMETER); 00102 ACE_TRY_CHECK; 00103 } 00104 } 00105 ACE_CATCHANY 00106 { 00107 return -1; 00108 } 00109 ACE_ENDTRY; 00110 ACE_CHECK_RETURN (-1); 00111 00112 if (this->set_socket_option (this->peer (), 00113 protocol_properties.send_buffer_size_, 00114 protocol_properties.recv_buffer_size_) == -1) 00115 return -1; 00116 00117 #if !defined (ACE_LACKS_TCP_NODELAY) 00118 if (this->peer ().set_option (ACE_IPPROTO_TCP, 00119 TCP_NODELAY, 00120 (void *) &protocol_properties.no_delay_, 00121 sizeof (protocol_properties.no_delay_)) == -1) 00122 return -1; 00123 00124 #endif /* ! ACE_LACKS_TCP_NODELAY */ 00125 00126 if (this->transport ()->wait_strategy ()->non_blocking ()) 00127 { 00128 if (this->peer ().enable (ACE_NONBLOCK) == -1) 00129 return -1; 00130 } 00131 00132 // Called by the <Strategy_Acceptor> when the handler is 00133 // completely connected. 00134 ACE_INET_Addr addr; 00135 00136 ACE_TCHAR local_as_string[MAXHOSTNAMELEN + 16]; 00137 00138 // Get the peername. 00139 if (this->peer ().get_remote_addr (addr) == -1) 00140 return -1; 00141 00142 // Verify that we can resolve the peer hostname. 00143 else if (addr.addr_to_string (local_as_string, sizeof (local_as_string)) == -1) 00144 return -1; 00145 00146 if (TAO_debug_level > 0) 00147 { 00148 ACE_DEBUG ((LM_DEBUG, 00149 ACE_TEXT ("TAO (%P|%t) - SHMIOP connection from client") 00150 ACE_TEXT ("<%s> on %d\n"), 00151 local_as_string, this->peer ().get_handle ())); 00152 } 00153 00154 // Set that the transport is now connected, if fails we return -1 00155 // Use C-style cast b/c otherwise we get warnings on lots of 00156 // compilers 00157 if (!this->transport ()->post_open ((size_t) this->get_handle ())) 00158 return -1; 00159 00160 // Not needed, anyway 00161 this->state_changed (TAO_LF_Event::LFS_SUCCESS, 00162 this->orb_core ()->leader_follower ()); 00163 00164 return 0; 00165 } |
|
Connection_Handler overloads Implements TAO_Connection_Handler. Definition at line 62 of file SHMIOP_Connection_Handler.cpp.
00063 { 00064 return this->open (v); 00065 } |
|
Reimplemented from TAO_Connection_Handler. Definition at line 225 of file SHMIOP_Connection_Handler.cpp. References ACE_Svc_Handler<, >::peer().
00226 { 00227 return this->peer().close (); 00228 } |
|
Reimplemented from ACE_Event_Handler. Definition at line 168 of file SHMIOP_Connection_Handler.cpp.
00169 { 00170 return ACE_Event_Handler::ACE_APPLICATION_RESUMES_HANDLER; 00171 } |
|
Flag that we will be passing to the event handler to indicate whether the handle will be resumed by the method or not. Definition at line 102 of file SHMIOP_Connection_Handler.h. |