TAO_SCIOP_Connection_Handler Class Reference

Handles requests on a single connection. More...

#include <SCIOP_Connection_Handler.h>

Inheritance diagram for TAO_SCIOP_Connection_Handler:

Inheritance graph
[legend]
Collaboration diagram for TAO_SCIOP_Connection_Handler:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 TAO_SCIOP_Connection_Handler (ACE_Thread_Manager *t=0)
 TAO_SCIOP_Connection_Handler (TAO_ORB_Core *orb_core, CORBA::Boolean flag)
 Constructor.

 ~TAO_SCIOP_Connection_Handler (void)
 Destructor.

virtual int open (void *)
int close (u_long=0)
int add_transport_to_cache (void)
 Add ourselves to Cache.

int process_listen_point_list (IIOP::ListenPointList &listen_list)
 Process the .

int set_dscp_codepoint (CORBA::Boolean set_network_priority)
 Set Diff-Serv codepoint on outgoing packets.

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 &current_time, const void *act=0)

Protected Member Functions

 TAO_SCIOP_Connection_Handler (TAO_ORB_Core *orb_core)
 Constructor that could be used by the derived classes.

TAO_Connection Handler overloads
virtual int release_os_resources (void)

Private Attributes

int dscp_codepoint_
 Stores the type of service value.


Detailed Description

Handles requests on a single connection.

The Connection handler which is common for the Acceptor and the Connector

Definition at line 60 of file SCIOP_Connection_Handler.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_SCIOP_Connection_Handler::TAO_SCIOP_Connection_Handler ACE_Thread_Manager t = 0  ) 
 

Definition at line 37 of file SCIOP_Connection_Handler.cpp.

References ACE_ASSERT, IPDSFIELD_DSCP_DEFAULT, and TAO_SCIOP_SVC_HANDLER.

00038   : TAO_SCIOP_SVC_HANDLER (t, 0 , 0),
00039     TAO_Connection_Handler (0),
00040     dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2)
00041 {
00042   // This constructor should *never* get called, it is just here to
00043   // make the compiler happy: the default implementation of the
00044   // Creation_Strategy requires a constructor with that signature, we
00045   // don't use that implementation, but some (most?) compilers
00046   // instantiate it anyway.
00047   ACE_ASSERT (0);
00048 }

TAO_SCIOP_Connection_Handler::TAO_SCIOP_Connection_Handler TAO_ORB_Core orb_core,
CORBA::Boolean  flag
 

Constructor.

Definition at line 51 of file SCIOP_Connection_Handler.cpp.

References ACE_NEW, IPDSFIELD_DSCP_DEFAULT, TAO_SCIOP_SVC_HANDLER, and TAO_Connection_Handler::transport().

00053   : TAO_SCIOP_SVC_HANDLER (orb_core->thr_mgr (), 0, 0),
00054     TAO_Connection_Handler (orb_core),
00055     dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2)
00056 {
00057   TAO_SCIOP_Transport* specific_transport = 0;
00058   ACE_NEW (specific_transport,
00059            TAO_SCIOP_Transport (this, orb_core, flag));
00060 
00061   // store this pointer (indirectly increment ref count)
00062   this->transport (specific_transport);
00063 }

TAO_SCIOP_Connection_Handler::~TAO_SCIOP_Connection_Handler void   ) 
 

Destructor.

Definition at line 73 of file SCIOP_Connection_Handler.cpp.

References TAO_Connection_Handler::transport().

00074 {
00075   delete this->transport ();
00076 }

TAO_SCIOP_Connection_Handler::TAO_SCIOP_Connection_Handler TAO_ORB_Core orb_core  )  [protected]
 

Constructor that could be used by the derived classes.

Sometimes new pluggbale protocols which have similarties with IIOP may be tempted to this class for their use. Classical example being that of IIOP_SSL_Connection_Handler. This constructor just initializes its base class and sets all of its contents to the default value, if any

Definition at line 65 of file SCIOP_Connection_Handler.cpp.

References IPDSFIELD_DSCP_DEFAULT, and TAO_SCIOP_SVC_HANDLER.

00066   : TAO_SCIOP_SVC_HANDLER (orb_core->thr_mgr (), 0, 0),
00067     TAO_Connection_Handler (orb_core),
00068     dscp_codepoint_ (IPDSFIELD_DSCP_DEFAULT << 2)
00069 {
00070 }


Member Function Documentation

int TAO_SCIOP_Connection_Handler::add_transport_to_cache void   ) 
 

Add ourselves to Cache.

Definition at line 277 of file SCIOP_Connection_Handler.cpp.

References TAO::Transport_Cache_Manager::cache_idle_transport(), TAO_ORB_Core::lane_resources(), TAO_Connection_Handler::orb_core(), and TAO_Thread_Lane_Resources::transport_cache().

00278 {
00279   ACE_INET_Addr addr;
00280 
00281   // Get the peername.
00282   if (this->peer ().get_remote_addr (addr) == -1)
00283     return -1;
00284 
00285   // Construct an  SCIOP_Endpoint object
00286   TAO_SCIOP_Endpoint endpoint (
00287       addr,
00288       this->orb_core()->orb_params()->use_dotted_decimal_addresses ());
00289 
00290   // Construct a property object
00291   TAO_Base_Transport_Property prop (&endpoint);
00292 
00293   TAO::Transport_Cache_Manager &cache =
00294     this->orb_core ()->lane_resources ().transport_cache ();
00295 
00296   // Idle the transport..
00297   return cache.cache_idle_transport (&prop,
00298                                      this->transport ());
00299 
00300 }

int TAO_SCIOP_Connection_Handler::close u_long  = 0  ) 
 

Close called by the Acceptor or Connector when connection establishment fails.

Definition at line 265 of file SCIOP_Connection_Handler.cpp.

References TAO_Connection_Handler::close_handler().

Referenced by handle_timeout(), and TAO_SCIOP_Connector::make_connection_i().

00266 {
00267   return this->close_handler ();
00268 }

int TAO_SCIOP_Connection_Handler::close_connection void   )  [virtual]
 

Implements TAO_Connection_Handler.

Definition at line 220 of file SCIOP_Connection_Handler.cpp.

References TAO_Connection_Handler::close_connection_eh().

Referenced by handle_output().

00221 {
00222   return this->close_connection_eh (this);
00223 }

int TAO_SCIOP_Connection_Handler::handle_close ACE_HANDLE  ,
ACE_Reactor_Mask 
[virtual]
 

Definition at line 257 of file SCIOP_Connection_Handler.cpp.

References ACE_ASSERT.

00259 {
00260   ACE_ASSERT (0);
00261   return 0;
00262 }

int TAO_SCIOP_Connection_Handler::handle_input ACE_HANDLE   )  [virtual]
 

Implements TAO_Connection_Handler.

Definition at line 226 of file SCIOP_Connection_Handler.cpp.

References TAO_Connection_Handler::handle_input_eh().

00227 {
00228   return this->handle_input_eh (h, this);
00229 }

int TAO_SCIOP_Connection_Handler::handle_output ACE_HANDLE   )  [virtual]
 

Definition at line 232 of file SCIOP_Connection_Handler.cpp.

References close_connection(), and TAO_Connection_Handler::handle_output_eh().

00233 {
00234   int const result =
00235     this->handle_output_eh (handle, this);
00236 
00237   if (result == -1)
00238     {
00239       this->close_connection ();
00240       return 0;
00241     }
00242 
00243   return result;
00244 }

int TAO_SCIOP_Connection_Handler::handle_timeout const ACE_Time_Value current_time,
const void *  act = 0
[virtual]
 

Definition at line 247 of file SCIOP_Connection_Handler.cpp.

References close().

00249 {
00250   // We don't use this upcall for I/O.  This is only used by the
00251   // Connector to indicate that the connection timedout.  Therefore,
00252   // we should call close().
00253   return this->close ();
00254 }

int TAO_SCIOP_Connection_Handler::open void *   )  [virtual]
 

Called by the when the handler is completely connected. Argument is unused.

Definition at line 85 of file SCIOP_Connection_Handler.cpp.

References ACE_CATCHANY, ACE_CHECK_RETURN, ACE_DEBUG, ACE_DECLARE_NEW_CORBA_ENV, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_ERROR, 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(), ACE_INET_Addr::get_ip_address(), ACE_INET_Addr::get_port_number(), TAO_ORB_Core::get_protocols_hooks(), LM_DEBUG, LM_ERROR, MAXHOSTNAMELEN, TAO_SCIOP_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(), TAO_Transport::post_open(), TAO_SCIOP_Protocol_Properties::recv_buffer_size_, TAO_SCIOP_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().

00086 {
00087   TAO_SCIOP_Protocol_Properties protocol_properties;
00088 
00089   // Initialize values from ORB params.
00090   protocol_properties.send_buffer_size_ =
00091     this->orb_core ()->orb_params ()->sock_sndbuf_size ();
00092   protocol_properties.recv_buffer_size_ =
00093     this->orb_core ()->orb_params ()->sock_rcvbuf_size ();
00094   protocol_properties.no_delay_ =
00095     this->orb_core ()->orb_params ()->nodelay ();
00096 
00097   TAO_Protocols_Hooks *tph =
00098     this->orb_core ()->get_protocols_hooks ();
00099 
00100   bool client =
00101     this->transport ()->opened_as () == TAO::TAO_CLIENT_ROLE;;
00102 
00103   ACE_DECLARE_NEW_CORBA_ENV;
00104 
00105   ACE_TRY
00106     {
00107       if (client)
00108         {
00109           tph->client_protocol_properties_at_orb_level (
00110             protocol_properties
00111             ACE_ENV_ARG_PARAMETER);
00112           ACE_TRY_CHECK;
00113         }
00114       else
00115         {
00116           tph->server_protocol_properties_at_orb_level (
00117             protocol_properties
00118             ACE_ENV_ARG_PARAMETER);
00119           ACE_TRY_CHECK;
00120         }
00121     }
00122   ACE_CATCHANY
00123     {
00124       return -1;
00125     }
00126   ACE_ENDTRY;
00127   ACE_CHECK_RETURN (-1);
00128 
00129   if (this->set_socket_option (this->peer (),
00130                                protocol_properties.send_buffer_size_,
00131                                protocol_properties.recv_buffer_size_) == -1)
00132     return -1;
00133 
00134 #if !defined (ACE_LACKS_TCP_NODELAY)
00135   if (this->peer ().set_option (IPPROTO_SCTP,
00136                                 SCTP_NODELAY,
00137                                 (void *) &protocol_properties.no_delay_,
00138                                 sizeof (protocol_properties.no_delay_)) == -1)
00139     return -1;
00140 #endif /* ! ACE_LACKS_TCP_NODELAY */
00141 
00142   if (this->transport ()->wait_strategy ()->non_blocking ())
00143     {
00144       if (this->peer ().enable (ACE_NONBLOCK) == -1)
00145         return -1;
00146     }
00147 
00148   // Called by the <Strategy_Acceptor> when the handler is
00149   // completely connected.
00150 
00151   ACE_INET_Addr remote_addr;
00152   if (this->peer ().get_remote_addr (remote_addr) == -1)
00153     return -1;
00154 
00155   ACE_INET_Addr local_addr;
00156   if (this->peer ().get_local_addr (local_addr) == -1)
00157     return -1;
00158 
00159 
00160   if (TAO_debug_level > 2)
00161     ACE_DEBUG ((LM_DEBUG,
00162                 ACE_TEXT("TAO(%P|%t) - SCIOP_Connection_Handler::open, ")
00163                 ACE_TEXT("The local addr is (%s) \n"),
00164                 local_addr. get_host_addr ()));
00165 
00166   if (local_addr.get_ip_address () == remote_addr.get_ip_address ()
00167       && local_addr.get_port_number () == remote_addr.get_port_number ())
00168     {
00169       if (TAO_debug_level > 0)
00170         {
00171           ACE_TCHAR remote_as_string[MAXHOSTNAMELEN + 16];
00172           ACE_TCHAR local_as_string[MAXHOSTNAMELEN + 16];
00173 
00174           (void) remote_addr.addr_to_string (remote_as_string,
00175                                              sizeof(remote_as_string));
00176           (void) local_addr.addr_to_string (local_as_string,
00177                                             sizeof(local_as_string));
00178           ACE_ERROR ((LM_ERROR,
00179                       ACE_TEXT("TAO(%P|%t) - TAO_SCIOP_Connection_Handler::open, ")
00180                       ACE_TEXT("Holy Cow! The remote addr and ")
00181                       ACE_TEXT("local addr are identical (%s == %s)\n"),
00182                       remote_as_string, local_as_string));
00183         }
00184       return -1;
00185     }
00186 
00187   if (TAO_debug_level > 0)
00188     {
00189       ACE_TCHAR client[MAXHOSTNAMELEN + 16];
00190 
00191       // Verify that we can resolve the peer hostname.
00192       if (remote_addr.addr_to_string (client, sizeof (client)) == -1)
00193         return -1;
00194 
00195       ACE_DEBUG ((LM_DEBUG,
00196                   ACE_TEXT ("TAO (%P|%t) - SCIOP_Connection_Handler::open, SCIOP ")
00197                   ACE_TEXT ("connection to peer <%s> on %d\n"),
00198                   client, this->peer ().get_handle ()));
00199     }
00200 
00201   // Set that the transport is now connected, if fails we return -1
00202   // Use C-style cast b/c otherwise we get warnings on lots of
00203   // compilers
00204   if (!this->transport ()->post_open ((size_t) this->get_handle ()))
00205     return -1;
00206 
00207   this->state_changed (TAO_LF_Event::LFS_SUCCESS,
00208                        this->orb_core ()->leader_follower ());
00209 
00210   return 0;
00211 }

int TAO_SCIOP_Connection_Handler::open_handler void *   )  [virtual]
 

Connection_Handler overloads

Implements TAO_Connection_Handler.

Definition at line 79 of file SCIOP_Connection_Handler.cpp.

References open(), and v.

00080 {
00081   return this->open (v);
00082 }

int TAO_SCIOP_Connection_Handler::process_listen_point_list IIOP::ListenPointList listen_list  ) 
 

Process the .

Definition at line 303 of file SCIOP_Connection_Handler.cpp.

References ACE_DEBUG, ACE_TEXT, ACE_TEXT_CHAR_TO_TCHAR, IIOP::ListenPoint::host, TAO::unbounded_value_sequence< ListenPoint >::length(), LM_DEBUG, TAO_Transport::make_idle(), IIOP::ListenPoint::port, TAO_Transport::recache_transport(), TAO_Transport_Descriptor_Interface::set_bidir_flag(), TAO_debug_level, and TAO_Connection_Handler::transport().

Referenced by TAO_SCIOP_Transport::tear_listen_point_list().

00305 {
00306   // Get the size of the list
00307   CORBA::ULong const len = listen_list.length ();
00308 
00309   for (CORBA::ULong i = 0; i < len; ++ i)
00310     {
00311       IIOP::ListenPoint listen_point = listen_list[i];
00312       ACE_INET_Addr addr (listen_point.port,
00313                           listen_point.host.in ());
00314 
00315       if (TAO_debug_level > 0)
00316         {
00317           ACE_DEBUG ((LM_DEBUG,
00318                       ACE_TEXT("(%P|%t) Listening port [%d] on [%s]\n"),
00319                       listen_point.port,
00320                       ACE_TEXT_CHAR_TO_TCHAR(listen_point.host.in ())));
00321         }
00322 
00323       // Construct an  SCIOP_Endpoint object
00324       TAO_SCIOP_Endpoint endpoint (addr,
00325         this->orb_core()->orb_params()->use_dotted_decimal_addresses ());
00326 
00327       // Construct a property object
00328       TAO_Base_Transport_Property prop (&endpoint);
00329 
00330       // Mark the connection as bidirectional
00331       prop.set_bidir_flag (1);
00332 
00333       // The property for this handler has changed. Recache the
00334       // handler with this property
00335       int const retval = this->transport ()->recache_transport (&prop);
00336       if (retval == -1)
00337         return retval;
00338 
00339       // Make the handler idle and ready for use
00340       this->transport ()->make_idle ();
00341     }
00342 
00343   return 0;
00344 }

int TAO_SCIOP_Connection_Handler::release_os_resources void   )  [protected, virtual]
 

Reimplemented from TAO_Connection_Handler.

Definition at line 271 of file SCIOP_Connection_Handler.cpp.

00272 {
00273   return this->peer().close ();
00274 }

int TAO_SCIOP_Connection_Handler::resume_handler void   )  [virtual]
 

Definition at line 214 of file SCIOP_Connection_Handler.cpp.

int TAO_SCIOP_Connection_Handler::set_dscp_codepoint CORBA::Boolean  set_network_priority  )  [virtual]
 

Set Diff-Serv codepoint on outgoing packets.

Reimplemented from TAO_Connection_Handler.

Definition at line 347 of file SCIOP_Connection_Handler.cpp.

References ACE_DEBUG, TAO_Protocols_Hooks::get_dscp_codepoint(), TAO_ORB_Core::get_protocols_hooks(), IPDSFIELD_DSCP_DEFAULT, LM_DEBUG, TAO_Connection_Handler::orb_core(), and TAO_debug_level.

00348 {
00349   int tos = IPDSFIELD_DSCP_DEFAULT << 2;
00350 
00351   if (set_network_priority)
00352     {
00353       TAO_Protocols_Hooks *tph =
00354         this->orb_core ()->get_protocols_hooks ();
00355 
00356       CORBA::Long codepoint =
00357         tph->get_dscp_codepoint ();
00358 
00359       tos = (int)(codepoint) << 2;
00360     }
00361 
00362   if (tos != this->dscp_codepoint_)
00363     {
00364       int const result = this->peer ().set_option (IPPROTO_IP,
00365                                                    IP_TOS,
00366                                                    (int *) &tos ,
00367                                                    (int) sizeof (tos));
00368 
00369       if (TAO_debug_level)
00370         {
00371           ACE_DEBUG ((LM_DEBUG,
00372                       "TAO (%P|%t) - SCIOP_Connection_Handler::"
00373                       "set_dscp_codepoint -> dscp: %x; result: %d; %s\n",
00374                       tos,
00375                       result,
00376                       result == -1 ? "try running as superuser" : ""));
00377         }
00378 
00379       // On successful setting of TOS field.
00380       if (result == 0)
00381         this->dscp_codepoint_ = tos;
00382 
00383     }
00384 
00385   return 0;
00386 }


Member Data Documentation

int TAO_SCIOP_Connection_Handler::dscp_codepoint_ [private]
 

Stores the type of service value.

Definition at line 135 of file SCIOP_Connection_Handler.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 13:41:25 2006 for TAO_Strategies by doxygen 1.3.6