TAO_UIOP_Connection_Handler Class Reference

Handles requests on a single connection. More...

#include <UIOP_Connection_Handler.h>

Inheritance diagram for TAO_UIOP_Connection_Handler:

Inheritance graph
[legend]
Collaboration diagram for TAO_UIOP_Connection_Handler:

Collaboration graph
[legend]
List of all members.

Public Member Functions

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

 ~TAO_UIOP_Connection_Handler (void)
 Destructor.

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 open (void *)
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_Connection Handler overloads
virtual int release_os_resources (void)

Detailed Description

Handles requests on a single connection.

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

Definition at line 48 of file UIOP_Connection_Handler.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_UIOP_Connection_Handler::TAO_UIOP_Connection_Handler ACE_Thread_Manager t = 0  ) 
 

Definition at line 28 of file UIOP_Connection_Handler.cpp.

References ACE_ASSERT, and TAO_UIOP_SVC_HANDLER.

00029   : TAO_UIOP_SVC_HANDLER (t, 0 , 0),
00030     TAO_Connection_Handler (0)
00031 {
00032   // This constructor should *never* get called, it is just here to
00033   // make the compiler happy: the default implementation of the
00034   // Creation_Strategy requires a constructor with that signature, we
00035   // don't use that implementation, but some (most?) compilers
00036   // instantiate it anyway.
00037   ACE_ASSERT (0);
00038 }

TAO_UIOP_Connection_Handler::TAO_UIOP_Connection_Handler TAO_ORB_Core orb_core,
CORBA::Boolean  flag
 

Constructor.

Definition at line 41 of file UIOP_Connection_Handler.cpp.

References ACE_NEW, TAO_UIOP_SVC_HANDLER, and TAO_Connection_Handler::transport().

00044   : TAO_UIOP_SVC_HANDLER (orb_core->thr_mgr (), 0, 0),
00045     TAO_Connection_Handler (orb_core)
00046 {
00047   TAO_UIOP_Transport* specific_transport = 0;
00048   ACE_NEW (specific_transport,
00049            TAO_UIOP_Transport (this, orb_core, flag));
00050 
00051   // store this pointer (indirectly increment ref count)
00052   this->transport (specific_transport);
00053 }

TAO_UIOP_Connection_Handler::~TAO_UIOP_Connection_Handler void   ) 
 

Destructor.

Definition at line 56 of file UIOP_Connection_Handler.cpp.

References TAO_Connection_Handler::transport().

00057 {
00058   delete this->transport ();
00059 }


Member Function Documentation

int TAO_UIOP_Connection_Handler::add_transport_to_cache void   ) 
 

Add ourselves to Cache.

Definition at line 210 of file UIOP_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().

00211 {
00212   ACE_UNIX_Addr addr;
00213 
00214   // Get the peername.
00215   if (this->peer ().get_remote_addr (addr) == -1)
00216     return -1;
00217 
00218   // Construct an  UIOP_Endpoint object
00219   TAO_UIOP_Endpoint endpoint (addr);
00220 
00221   // Construct a property object
00222   TAO_Base_Transport_Property prop (&endpoint);
00223 
00224   TAO::Transport_Cache_Manager &cache =
00225     this->orb_core ()->lane_resources ().transport_cache ();
00226 
00227   // Add the handler to Cache
00228   return cache.cache_idle_transport (&prop,
00229                                      this->transport ());
00230 }

int TAO_UIOP_Connection_Handler::close u_long  = 0  )  [virtual]
 

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

Reimplemented from ACE_Svc_Handler<, >.

Definition at line 198 of file UIOP_Connection_Handler.cpp.

References TAO_Connection_Handler::close_handler().

Referenced by handle_timeout(), and TAO_UIOP_Connector::make_connection().

00199 {
00200   return this->close_handler ();
00201 }

int TAO_UIOP_Connection_Handler::close_connection void   )  [virtual]
 

Implements TAO_Connection_Handler.

Definition at line 153 of file UIOP_Connection_Handler.cpp.

References TAO_Connection_Handler::close_connection_eh().

Referenced by handle_output().

00154 {
00155   return this->close_connection_eh (this);
00156 }

int TAO_UIOP_Connection_Handler::handle_close ACE_HANDLE  ,
ACE_Reactor_Mask 
[virtual]
 

Reimplemented from ACE_Svc_Handler<, >.

Definition at line 190 of file UIOP_Connection_Handler.cpp.

References ACE_ASSERT.

00192 {
00193   ACE_ASSERT (0);
00194   return 0;
00195 }

int TAO_UIOP_Connection_Handler::handle_input ACE_HANDLE   )  [virtual]
 

Implements TAO_Connection_Handler.

Definition at line 159 of file UIOP_Connection_Handler.cpp.

References TAO_Connection_Handler::handle_input_eh().

00160 {
00161   return this->handle_input_eh (h, this);
00162 }

int TAO_UIOP_Connection_Handler::handle_output ACE_HANDLE   )  [virtual]
 

Reimplemented from ACE_Event_Handler.

Definition at line 165 of file UIOP_Connection_Handler.cpp.

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

00166 {
00167   const int result =
00168     this->handle_output_eh (handle, this);
00169 
00170   if (result == -1)
00171     {
00172       this->close_connection ();
00173       return 0;
00174     }
00175 
00176   return result;
00177 }

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

Reimplemented from ACE_Svc_Handler<, >.

Definition at line 180 of file UIOP_Connection_Handler.cpp.

References close().

00182 {
00183   // We don't use this upcall for I/O.  This is only used by the
00184   // Connector to indicate that the connection timedout.  Therefore,
00185   // we should call close().
00186   return this->close ();
00187 }

int TAO_UIOP_Connection_Handler::open void *   )  [virtual]
 

Reimplemented from ACE_Svc_Handler<, >.

Definition at line 68 of file UIOP_Connection_Handler.cpp.

References ACE_CATCHANY, ACE_CHECK_RETURN, ACE_DEBUG, ACE_DECLARE_NEW_CORBA_ENV, ACE_ENDTRY, ACE_ENV_ARG_PARAMETER, ACE_NONBLOCK, ACE_TEXT, ACE_TRY, ACE_TRY_CHECK, TAO_Protocols_Hooks::client_protocol_properties_at_orb_level(), ACE_UNIX_Addr::get_path_name(), TAO_ORB_Core::get_protocols_hooks(), LM_DEBUG, 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_UIOP_Protocol_Properties::recv_buffer_size_, TAO_UIOP_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_UIOP_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 
00078   TAO_Protocols_Hooks *tph =
00079     this->orb_core ()->get_protocols_hooks ();
00080 
00081   bool client =
00082     this->transport ()->opened_as () == TAO::TAO_CLIENT_ROLE;;
00083 
00084   ACE_DECLARE_NEW_CORBA_ENV;
00085 
00086   ACE_TRY
00087     {
00088       if (client)
00089         {
00090           tph->client_protocol_properties_at_orb_level (
00091             protocol_properties
00092             ACE_ENV_ARG_PARAMETER);
00093           ACE_TRY_CHECK;
00094         }
00095       else
00096         {
00097           tph->server_protocol_properties_at_orb_level (
00098             protocol_properties
00099             ACE_ENV_ARG_PARAMETER);
00100           ACE_TRY_CHECK;
00101         }
00102     }
00103   ACE_CATCHANY
00104     {
00105       return -1;
00106     }
00107   ACE_ENDTRY;
00108   ACE_CHECK_RETURN (-1);
00109 
00110   if (this->set_socket_option (this->peer (),
00111                                protocol_properties.send_buffer_size_,
00112                                protocol_properties.recv_buffer_size_) == -1)
00113     return -1;
00114 
00115   if (this->transport ()->wait_strategy ()->non_blocking ())
00116     {
00117       if (this->peer ().enable (ACE_NONBLOCK) == -1)
00118         return -1;
00119     }
00120 
00121   // Called by the <Strategy_Acceptor> when the handler is completely
00122   // connected.
00123   ACE_UNIX_Addr addr;
00124 
00125   if (this->peer ().get_remote_addr (addr) == -1)
00126     return -1;
00127 
00128   if (TAO_debug_level > 0)
00129     ACE_DEBUG ((LM_DEBUG,
00130                 ACE_TEXT ("TAO (%P|%t) UIOP connection to server ")
00131                 ACE_TEXT ("<%s> on %d\n"),
00132                 addr.get_path_name (), this->peer ().get_handle ()));
00133 
00134   // Set that the transport is now connected, if fails we return -1
00135   // Use C-style cast b/c otherwise we get warnings on lots of
00136   // compilers
00137   if (!this->transport ()->post_open ((size_t) this->get_handle ()))
00138     return -1;
00139 
00140   this->state_changed (TAO_LF_Event::LFS_SUCCESS,
00141                        this->orb_core ()->leader_follower ());
00142 
00143   return 0;
00144 }

int TAO_UIOP_Connection_Handler::open_handler void *   )  [virtual]
 

Connection_Handler overloads

Implements TAO_Connection_Handler.

Definition at line 62 of file UIOP_Connection_Handler.cpp.

References open(), and v.

00063 {
00064   return this->open (v);
00065 }

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

Reimplemented from TAO_Connection_Handler.

Definition at line 204 of file UIOP_Connection_Handler.cpp.

References ACE_Svc_Handler<, >::peer().

00205 {
00206   return this->peer().close ();
00207 }

int TAO_UIOP_Connection_Handler::resume_handler void   )  [virtual]
 

Reimplemented from ACE_Event_Handler.

Definition at line 147 of file UIOP_Connection_Handler.cpp.


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