#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) | |
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.
TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_SHMIOP_Connection_Handler::TAO_SHMIOP_Connection_Handler | ( | ACE_Thread_Manager * | t = 0 |
) |
Constructor.
Definition at line 29 of file SHMIOP_Connection_Handler.cpp.
References ACE_ASSERT.
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 }
TAO_SHMIOP_Connection_Handler::TAO_SHMIOP_Connection_Handler | ( | TAO_ORB_Core * | orb_core | ) |
Constructor.
Definition at line 42 of file SHMIOP_Connection_Handler.cpp.
References ACE_NEW, TAO_Connection_Handler::orb_core(), and TAO_Connection_Handler::transport().
00043 : TAO_SHMIOP_SVC_HANDLER (orb_core->thr_mgr (), 0, 0), 00044 TAO_Connection_Handler (orb_core) 00045 { 00046 TAO_SHMIOP_Transport* specific_transport = 0; 00047 ACE_NEW (specific_transport, 00048 TAO_SHMIOP_Transport(this, orb_core)); 00049 00050 // store this pointer (indirectly increment ref count) 00051 this->transport (specific_transport); 00052 }
TAO_SHMIOP_Connection_Handler::~TAO_SHMIOP_Connection_Handler | ( | void | ) |
Destructor.
Definition at line 55 of file SHMIOP_Connection_Handler.cpp.
References ACE_ERROR, ACE_TEXT, LM_ERROR, release_os_resources(), TAO_debug_level, and TAO_Connection_Handler::transport().
00056 { 00057 delete this->transport (); 00058 int const result = 00059 this->release_os_resources (); 00060 00061 if (result == -1 && TAO_debug_level) 00062 { 00063 ACE_ERROR ((LM_ERROR, 00064 ACE_TEXT("TAO (%P|%t) - SHMIOP_Connection_Handler::") 00065 ACE_TEXT("~SHMIOP_Connection_Handler, ") 00066 ACE_TEXT("release_os_resources() failed %m\n"))); 00067 } 00068 00069 }
int TAO_SHMIOP_Connection_Handler::add_transport_to_cache | ( | void | ) |
Add ourselves to Cache.
Definition at line 246 of file SHMIOP_Connection_Handler.cpp.
References TAO_ORB_Core::lane_resources(), TAO_Connection_Handler::orb_core(), and TAO_Thread_Lane_Resources::transport_cache().
00247 { 00248 ACE_INET_Addr addr; 00249 00250 // Get the peername. 00251 if (this->peer ().get_remote_addr (addr) == -1) 00252 return -1; 00253 00254 // Construct an SHMIOP_Endpoint object 00255 TAO_SHMIOP_Endpoint endpoint ( 00256 addr, 00257 this->orb_core()->orb_params()->use_dotted_decimal_addresses ()); 00258 00259 // Construct a property object 00260 TAO_Base_Transport_Property prop (&endpoint); 00261 00262 TAO::Transport_Cache_Manager &cache = 00263 this->orb_core ()->lane_resources ().transport_cache (); 00264 00265 // Add the handler to Cache 00266 return cache.cache_idle_transport (&prop, 00267 this->transport ()); 00268 }
int TAO_SHMIOP_Connection_Handler::close | ( | u_long | = 0 |
) | [virtual] |
Close called by the Acceptor or Connector when connection establishment fails.
Reimplemented from ACE_Svc_Handler< ACE_MEM_STREAM, ACE_NULL_SYNCH >.
Definition at line 234 of file SHMIOP_Connection_Handler.cpp.
References TAO_Connection_Handler::close_handler().
Referenced by handle_timeout(), and TAO_SHMIOP_Connector::make_connection().
00235 { 00236 return this->close_handler (); 00237 }
int TAO_SHMIOP_Connection_Handler::close_connection | ( | void | ) | [virtual] |
Implements TAO_Connection_Handler.
Definition at line 176 of file SHMIOP_Connection_Handler.cpp.
References TAO_Connection_Handler::close_connection_eh().
Referenced by handle_output().
00177 { 00178 return this->close_connection_eh (this); 00179 }
int TAO_SHMIOP_Connection_Handler::handle_close | ( | ACE_HANDLE | , | |
ACE_Reactor_Mask | ||||
) | [virtual] |
Reimplemented from ACE_Svc_Handler< ACE_MEM_STREAM, ACE_NULL_SYNCH >.
Definition at line 226 of file SHMIOP_Connection_Handler.cpp.
References ACE_ASSERT.
00228 { 00229 ACE_ASSERT (0); 00230 return 0; 00231 }
int TAO_SHMIOP_Connection_Handler::handle_input | ( | ACE_HANDLE | ) | [virtual] |
Implements TAO_Connection_Handler.
Definition at line 182 of file SHMIOP_Connection_Handler.cpp.
References TAO_Connection_Handler::handle_input_eh().
00183 { 00184 return this->handle_input_eh (h, this); 00185 }
int TAO_SHMIOP_Connection_Handler::handle_output | ( | ACE_HANDLE | ) | [virtual] |
Reimplemented from ACE_Event_Handler.
Definition at line 188 of file SHMIOP_Connection_Handler.cpp.
References close_connection(), and TAO_Connection_Handler::handle_output_eh().
00189 { 00190 int result = 00191 this->handle_output_eh (handle, this); 00192 00193 if (result == -1) 00194 { 00195 this->close_connection (); 00196 return 0; 00197 } 00198 00199 return result; 00200 }
int TAO_SHMIOP_Connection_Handler::handle_timeout | ( | const ACE_Time_Value & | current_time, | |
const void * | act = 0 | |||
) | [virtual] |
Reimplemented from ACE_Svc_Handler< ACE_MEM_STREAM, ACE_NULL_SYNCH >.
Definition at line 203 of file SHMIOP_Connection_Handler.cpp.
References close(), TAO_LF_Event::LFS_TIMEOUT, and TAO_LF_Event::reset_state().
00205 { 00206 // Using this to ensure this instance will be deleted (if necessary) 00207 // only after reset_state(). Without this, when this refcount==1 - 00208 // the call to close() will cause a call to remove_reference() which 00209 // will delete this. At that point this->reset_state() is in no 00210 // man's territory and that causes SEGV on some platforms (Windows!) 00211 00212 TAO_Auto_Reference<TAO_SHMIOP_Connection_Handler> safeguard (*this); 00213 00214 // NOTE: Perhaps not the best solution, as it feels like the upper 00215 // layers should be responsible for this? 00216 00217 // We don't use this upcall for I/O. This is only used by the 00218 // Connector to indicate that the connection timedout. Therefore, 00219 // we should call close(). 00220 int ret = this->close (); 00221 this->reset_state (TAO_LF_Event::LFS_TIMEOUT); 00222 return ret; 00223 }
int TAO_SHMIOP_Connection_Handler::open | ( | void * | ) | [virtual] |
Called by the <Strategy_Acceptor> when the handler is completely connected. Argument is unused.
Reimplemented from ACE_Svc_Handler< ACE_MEM_STREAM, ACE_NULL_SYNCH >.
Definition at line 78 of file SHMIOP_Connection_Handler.cpp.
References ACE_DEBUG, ACE_IPPROTO_TCP, ACE_NONBLOCK, ACE_TEXT, ACE_INET_Addr::addr_to_string(), TAO_Protocols_Hooks::client_protocol_properties_at_orb_level(), TAO_ORB_Core::get_protocols_hooks(), TAO_LF_Event::LFS_SUCCESS, LM_DEBUG, MAXHOSTNAMELEN, TAO_SHMIOP_Protocol_Properties::no_delay_, TAO_ORB_Parameters::nodelay(), TAO_Connection_Handler::orb_core(), TAO_ORB_Core::orb_params(), TAO_SHMIOP_Protocol_Properties::recv_buffer_size_, TAO_SHMIOP_Protocol_Properties::send_buffer_size_, TAO_Protocols_Hooks::server_protocol_properties_at_orb_level(), TAO_ORB_Parameters::sock_rcvbuf_size(), TAO_ORB_Parameters::sock_sndbuf_size(), TAO_LF_Event::state_changed(), TAO::TAO_CLIENT_ROLE, TAO_debug_level, and TCP_NODELAY.
Referenced by open_handler().
00079 { 00080 if (this->shared_open() == -1) 00081 return -1; 00082 00083 TAO_SHMIOP_Protocol_Properties protocol_properties; 00084 00085 // Initialize values from ORB params. 00086 protocol_properties.send_buffer_size_ = 00087 this->orb_core ()->orb_params ()->sock_sndbuf_size (); 00088 protocol_properties.recv_buffer_size_ = 00089 this->orb_core ()->orb_params ()->sock_rcvbuf_size (); 00090 protocol_properties.no_delay_ = 00091 this->orb_core ()->orb_params ()->nodelay (); 00092 00093 TAO_Protocols_Hooks *tph = this->orb_core ()->get_protocols_hooks (); 00094 00095 if (tph != 0) 00096 { 00097 try 00098 { 00099 if (this->transport ()->opened_as () == TAO::TAO_CLIENT_ROLE) 00100 { 00101 tph->client_protocol_properties_at_orb_level (protocol_properties); 00102 } 00103 else 00104 { 00105 tph->server_protocol_properties_at_orb_level (protocol_properties); 00106 } 00107 } 00108 catch (const ::CORBA::Exception&) 00109 { 00110 return -1; 00111 } 00112 } 00113 00114 if (this->set_socket_option (this->peer (), 00115 protocol_properties.send_buffer_size_, 00116 protocol_properties.recv_buffer_size_) == -1) 00117 return -1; 00118 00119 #if !defined (ACE_LACKS_TCP_NODELAY) 00120 if (this->peer ().set_option (ACE_IPPROTO_TCP, 00121 TCP_NODELAY, 00122 (void *) &protocol_properties.no_delay_, 00123 sizeof (protocol_properties.no_delay_)) == -1) 00124 return -1; 00125 00126 #endif /* ! ACE_LACKS_TCP_NODELAY */ 00127 00128 if (this->transport ()->wait_strategy ()->non_blocking ()) 00129 { 00130 if (this->peer ().enable (ACE_NONBLOCK) == -1) 00131 return -1; 00132 } 00133 00134 // Called by the <Strategy_Acceptor> when the handler is 00135 // completely connected. 00136 ACE_INET_Addr addr; 00137 00138 ACE_TCHAR local_as_string[MAXHOSTNAMELEN + 16]; 00139 00140 // Get the peername. 00141 if (this->peer ().get_remote_addr (addr) == -1) 00142 return -1; 00143 00144 // Verify that we can resolve the peer hostname. 00145 else if (addr.addr_to_string (local_as_string, sizeof (local_as_string)) == -1) 00146 return -1; 00147 00148 if (TAO_debug_level > 0) 00149 { 00150 ACE_DEBUG ((LM_DEBUG, 00151 ACE_TEXT ("TAO (%P|%t) - SHMIOP connection from client") 00152 ACE_TEXT ("<%s> on %d\n"), 00153 local_as_string, this->peer ().get_handle ())); 00154 } 00155 00156 // Set that the transport is now connected, if fails we return -1 00157 // Use C-style cast b/c otherwise we get warnings on lots of 00158 // compilers 00159 if (!this->transport ()->post_open ((size_t) this->get_handle ())) 00160 return -1; 00161 00162 // Not needed, anyway 00163 this->state_changed (TAO_LF_Event::LFS_SUCCESS, 00164 this->orb_core ()->leader_follower ()); 00165 00166 return 0; 00167 }
int TAO_SHMIOP_Connection_Handler::open_handler | ( | void * | ) | [virtual] |
Connection_Handler overloads
Implements TAO_Connection_Handler.
Definition at line 72 of file SHMIOP_Connection_Handler.cpp.
References open().
00073 { 00074 return this->open (v); 00075 }
int TAO_SHMIOP_Connection_Handler::release_os_resources | ( | void | ) | [protected, virtual] |
Reimplemented from TAO_Connection_Handler.
Definition at line 240 of file SHMIOP_Connection_Handler.cpp.
References ACE_Svc_Handler< ACE_MEM_STREAM, ACE_NULL_SYNCH >::peer().
Referenced by ~TAO_SHMIOP_Connection_Handler().
00241 { 00242 return this->peer().close (); 00243 }
int TAO_SHMIOP_Connection_Handler::resume_handler | ( | void | ) | [virtual] |
Reimplemented from ACE_Event_Handler.
Definition at line 170 of file SHMIOP_Connection_Handler.cpp.
References ACE_Event_Handler::ACE_APPLICATION_RESUMES_HANDLER.
00171 { 00172 return ACE_Event_Handler::ACE_APPLICATION_RESUMES_HANDLER; 00173 }
int TAO_SHMIOP_Connection_Handler::resume_flag_ [private] |
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 101 of file SHMIOP_Connection_Handler.h.