#include <UIPMC_Connection_Handler.h>
Inheritance diagram for TAO_UIPMC_Connection_Handler:
Public Member Functions | |
TAO_UIPMC_Connection_Handler (ACE_Thread_Manager *t=0) | |
TAO_UIPMC_Connection_Handler (TAO_ORB_Core *orb_core) | |
~TAO_UIPMC_Connection_Handler (void) | |
Destructor. | |
int | close (u_long=0) |
int | add_transport_to_cache (void) |
Add ourselves to Cache. | |
int | set_dscp_codepoint (CORBA::Boolean set_network_priority) |
Set Diff-Serv codepoint on outgoing packets. | |
int | set_dscp_codepoint (CORBA::Long dscp_codepoint) |
const ACE_INET_Addr & | addr (void) |
void | addr (const ACE_INET_Addr &addr) |
const ACE_INET_Addr & | local_addr (void) |
void | local_addr (const ACE_INET_Addr &addr) |
ssize_t | send (const iovec iov[], int n, const ACE_Addr &addr, int flags=0) const |
Connection Handler overloads | |
virtual int | open_handler (void *v) |
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) |
virtual int | open (void *) |
Protected Member Functions | |
int | set_tos (int tos) |
TAO_Connection Handler overloads | |
virtual int | release_os_resources (void) |
Protected Attributes | |
ACE_INET_Addr | addr_ |
ACE_INET_Addr | local_addr_ |
Private Attributes | |
int | dscp_codepoint_ |
Stores the type of service value. |
Since MIOP is asymmetric then this Connection handler is for only use in the Connector.
Definition at line 57 of file UIPMC_Connection_Handler.h.
|
Definition at line 28 of file UIPMC_Connection_Handler.cpp. References ACE_ASSERT, IPDSFIELD_DSCP_DEFAULT, and TAO_UIPMC_SVC_HANDLER.
00029 : TAO_UIPMC_SVC_HANDLER (t, 0 , 0), 00030 TAO_Connection_Handler (0), 00031 dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2) 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. parameter is used by the Acceptor to pass the protocol configuration properties for this connection. Definition at line 41 of file UIPMC_Connection_Handler.cpp. References ACE_NEW, IPDSFIELD_DSCP_DEFAULT, TAO_UIPMC_SVC_HANDLER, TAO_Connection_Handler::transport(), and UIPMC_TRANSPORT.
00042 : TAO_UIPMC_SVC_HANDLER (orb_core->thr_mgr (), 0, 0), 00043 TAO_Connection_Handler (orb_core), 00044 dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2) 00045 { 00046 UIPMC_TRANSPORT* specific_transport = 0; 00047 ACE_NEW(specific_transport, 00048 UIPMC_TRANSPORT (this, orb_core)); 00049 00050 // store this pointer (indirectly increment ref count) 00051 this->transport (specific_transport); 00052 } |
|
Destructor.
Definition at line 54 of file UIPMC_Connection_Handler.cpp. References ACE_ERROR, ACE_TEXT, LM_ERROR, release_os_resources(), TAO_debug_level, and TAO_Connection_Handler::transport().
00055 { 00056 delete this->transport (); 00057 int const result = 00058 this->release_os_resources (); 00059 00060 if (result == -1 && TAO_debug_level) 00061 { 00062 ACE_ERROR ((LM_ERROR, 00063 ACE_TEXT("TAO (%P|%t) - UIPMC_Connection_Handler::") 00064 ACE_TEXT("~UIPMC_Connection_Handler, ") 00065 ACE_TEXT("release_os_resources() failed %m\n"))); 00066 } 00067 } |
|
Add ourselves to Cache.
Definition at line 215 of file UIPMC_Connection_Handler.cpp. References TAO::Transport_Cache_Manager::cache_transport(), TAO_ORB_Core::lane_resources(), TAO_Connection_Handler::orb_core(), and TAO_Thread_Lane_Resources::transport_cache().
00216 { 00217 ACE_INET_Addr addr; 00218 00219 // This function is called by the acceptor to add this 00220 // transport to the transport cache. This is really 00221 // important for proper shutdown. The address used 00222 // is irrelevent, since UIPMC is connectionless. 00223 00224 // Construct a UIPMC_Endpoint object. 00225 TAO_UIPMC_Endpoint endpoint (addr); 00226 00227 // Construct a property object 00228 TAO_Base_Transport_Property prop (&endpoint); 00229 00230 // Add the handler to Cache 00231 return this->orb_core ()->lane_resources () 00232 .transport_cache ().cache_transport (&prop, 00233 this->transport ()); 00234 } |
|
Definition at line 76 of file UIPMC_Connection_Handler.cpp.
00077 { 00078 this->addr_ = addr; 00079 } |
|
Definition at line 70 of file UIPMC_Connection_Handler.cpp. Referenced by TAO_UIPMC_Connector::make_connection().
00071 { 00072 return this->addr_; 00073 } |
|
Close called by the Acceptor or Connector when connection establishment fails. Reimplemented from ACE_Svc_Handler<, >. Definition at line 203 of file UIPMC_Connection_Handler.cpp. References TAO_Connection_Handler::close_handler(). Referenced by handle_timeout(), and TAO_UIPMC_Connector::make_connection().
00204 { 00205 return this->close_handler (); 00206 } |
|
Implements TAO_Connection_Handler. Definition at line 141 of file UIPMC_Connection_Handler.cpp. References TAO_Connection_Handler::close_connection_eh(). Referenced by handle_output().
00142 { 00143 return this->close_connection_eh (this); 00144 } |
|
Reimplemented from ACE_Svc_Handler<, >. Definition at line 191 of file UIPMC_Connection_Handler.cpp.
00193 { 00194 // No asserts here since the handler is registered with the Reactor 00195 // and the handler ownership is given to the Reactor. When the 00196 // Reactor closes, it will call handle_close() on the handler. It 00197 // is however important to overwrite handle_close() to do nothing 00198 // since the base class does too much. 00199 return 0; 00200 } |
|
Implements TAO_Connection_Handler. Definition at line 147 of file UIPMC_Connection_Handler.cpp. References TAO_Connection_Handler::handle_input_eh().
00148 { 00149 return this->handle_input_eh (h, this); 00150 } |
|
Reimplemented from ACE_Event_Handler. Definition at line 153 of file UIPMC_Connection_Handler.cpp. References close_connection(), and TAO_Connection_Handler::handle_output_eh().
00154 { 00155 int result = 00156 this->handle_output_eh (handle, this); 00157 00158 if (result == -1) 00159 { 00160 this->close_connection (); 00161 return 0; 00162 } 00163 00164 return result; 00165 } |
|
Reimplemented from ACE_Svc_Handler<, >. Definition at line 168 of file UIPMC_Connection_Handler.cpp. References close(), and TAO_LF_Event::reset_state().
00170 { 00171 // Using this to ensure this instance will be deleted (if necessary) 00172 // only after reset_state(). Without this, when this refcount==1 - 00173 // the call to close() will cause a call to remove_reference() which 00174 // will delete this. At that point this->reset_state() is in no 00175 // man's territory and that causes SEGV on some platforms (Windows!) 00176 00177 TAO_Auto_Reference<TAO_UIPMC_Connection_Handler> safeguard (*this); 00178 00179 // NOTE: Perhaps not the best solution, as it feels like the upper 00180 // layers should be responsible for this? 00181 00182 // We don't use this upcall for I/O. This is only used by the 00183 // Connector to indicate that the connection timedout. Therefore, 00184 // we should call close(). 00185 int ret = this->close (); 00186 this->reset_state (TAO_LF_Event::LFS_TIMEOUT); 00187 return ret; 00188 } |
|
Definition at line 88 of file UIPMC_Connection_Handler.cpp.
00089 { 00090 local_addr_ = addr; 00091 } |
|
Definition at line 82 of file UIPMC_Connection_Handler.cpp. Referenced by TAO_UIPMC_Connector::make_connection(), and set_tos().
00083 { 00084 return local_addr_; 00085 } |
|
Reimplemented from ACE_Svc_Handler<, >. Definition at line 109 of file UIPMC_Connection_Handler.cpp. References ACE_DEBUG, ACE_TEXT, ACE_INET_Addr::get_port_number(), LM_DEBUG, ACE_Svc_Handler<, >::peer(), TAO_Transport::post_open(), TAO_LF_Event::state_changed(), TAO_debug_level, and TAO_Connection_Handler::transport(). Referenced by TAO_UIPMC_Connector::make_connection(), and open_handler().
00110 { 00111 this->peer ().open (this->local_addr_); 00112 00113 if (TAO_debug_level > 5) 00114 { 00115 ACE_DEBUG ((LM_DEBUG, 00116 ACE_TEXT("TAO (%P|%t) - UIPMC_Connection_Handler::open, ") 00117 ACE_TEXT("listening on: <%s:%u>\n"), 00118 this->local_addr_.get_host_addr (), 00119 this->local_addr_.get_port_number ())); 00120 } 00121 00122 // Set that the transport is now connected, if fails we return -1 00123 // Use C-style cast b/c otherwise we get warnings on lots of 00124 // compilers 00125 if (!this->transport ()->post_open ((size_t) this->peer ().get_handle ())) 00126 return -1; 00127 00128 this->state_changed (TAO_LF_Event::LFS_SUCCESS, 00129 this->orb_core ()->leader_follower ()); 00130 00131 return 0; 00132 } |
|
Implements TAO_Connection_Handler. Definition at line 103 of file UIPMC_Connection_Handler.cpp. References open().
00104 { 00105 return this->open (v); 00106 } |
|
Reimplemented from TAO_Connection_Handler. Definition at line 209 of file UIPMC_Connection_Handler.cpp. References ACE_Svc_Handler<, >::peer(). Referenced by ~TAO_UIPMC_Connection_Handler().
00210 { 00211 return this->peer ().close (); 00212 } |
|
Reimplemented from ACE_Event_Handler. Definition at line 135 of file UIPMC_Connection_Handler.cpp.
00136 { 00137 return ACE_Event_Handler::ACE_APPLICATION_RESUMES_HANDLER; 00138 } |
|
This is only to be able to use client and server connection handlers in the same way in transport. Definition at line 94 of file UIPMC_Connection_Handler.cpp. References ACE_Svc_Handler<, >::peer().
00098 { 00099 return this->peer ().send (iov, n, addr, flags); 00100 } |
|
Reimplemented from TAO_Connection_Handler. Definition at line 293 of file UIPMC_Connection_Handler.cpp. References IPDSFIELD_DSCP_DEFAULT, and set_tos().
00294 { 00295 int tos = IPDSFIELD_DSCP_DEFAULT << 2; 00296 00297 CORBA::Long codepoint = dscp_codepoint; 00298 00299 tos = static_cast<int> (codepoint) << 2; 00300 00301 this->set_tos (tos); 00302 00303 return 0; 00304 } |
|
Set Diff-Serv codepoint on outgoing packets.
Reimplemented from TAO_Connection_Handler. Definition at line 307 of file UIPMC_Connection_Handler.cpp. References TAO_Protocols_Hooks::get_dscp_codepoint(), TAO_ORB_Core::get_protocols_hooks(), IPDSFIELD_DSCP_DEFAULT, TAO_Connection_Handler::orb_core(), and set_tos().
00308 { 00309 int tos = IPDSFIELD_DSCP_DEFAULT << 2; 00310 00311 if (set_network_priority) 00312 { 00313 TAO_Protocols_Hooks *tph = 00314 this->orb_core ()->get_protocols_hooks (); 00315 00316 if (tph != 0 ) 00317 { 00318 CORBA::Long codepoint = 00319 tph->get_dscp_codepoint (); 00320 00321 tos = static_cast<int> (codepoint) << 2; 00322 this->set_tos (tos); 00323 } 00324 } 00325 00326 return 0; 00327 } |
|
Definition at line 237 of file UIPMC_Connection_Handler.cpp. References ACE_DEBUG, ACE_Addr::get_type(), IPPROTO_IP, LM_DEBUG, local_addr(), ACE_Svc_Handler<, >::peer(), and TAO_debug_level. Referenced by set_dscp_codepoint().
00238 { 00239 // Since only client can send data over MIOP 00240 // then dscp is only applicable to client socket. 00241 if (tos != this->dscp_codepoint_) 00242 { 00243 int result = 0; 00244 #if defined (ACE_HAS_IPV6) 00245 ACE_INET_Addr local_addr; 00246 if (this->peer ().get_local_addr (local_addr) == -1) 00247 return -1; 00248 else if (local_addr.get_type () == AF_INET6) 00249 # if !defined (IPV6_TCLASS) 00250 // IPv6 defines option IPV6_TCLASS for specifying traffic class/priority 00251 // but not many implementations yet (very new;-). 00252 { 00253 if (TAO_debug_level) 00254 { 00255 ACE_DEBUG ((LM_DEBUG, 00256 "TAO (%P|%t) - UIPMC_Connection_Handler::" 00257 "set_dscp_codepoint -> IPV6_TCLASS not supported yet\n")); 00258 } 00259 return 0; 00260 } 00261 # else /* !IPV6_TCLASS */ 00262 result = this->peer ().set_option (IPPROTO_IPV6, 00263 IPV6_TCLASS, 00264 (int *) &tos, 00265 (int) sizeof (tos)); 00266 else 00267 # endif /* IPV6_TCLASS */ 00268 #endif /* ACE_HAS_IPV6 */ 00269 result = this->peer ().set_option (IPPROTO_IP, 00270 IP_TOS, 00271 (int *) &tos, 00272 (int) sizeof (tos)); 00273 00274 if (TAO_debug_level) 00275 { 00276 ACE_DEBUG ((LM_DEBUG, 00277 "TAO (%P|%t) - UIPMC_Connection_Handler::" 00278 "set_dscp_codepoint -> dscp: %x; result: %d; %s\n", 00279 tos, 00280 result, 00281 result == -1 ? "try running as superuser" : "")); 00282 } 00283 00284 // On successful setting of TOS field. 00285 if (result == 0) 00286 this->dscp_codepoint_ = tos; 00287 } 00288 00289 return 0; 00290 } |
|
Definition at line 126 of file UIPMC_Connection_Handler.h. |
|
Stores the type of service value.
Definition at line 147 of file UIPMC_Connection_Handler.h. |
|
Definition at line 129 of file UIPMC_Connection_Handler.h. |