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)
 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 45 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 27 of file UIOP_Connection_Handler.cpp.

References ACE_ASSERT.

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

TAO_UIOP_Connection_Handler::TAO_UIOP_Connection_Handler ( TAO_ORB_Core orb_core  ) 

Constructor.

Definition at line 40 of file UIOP_Connection_Handler.cpp.

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

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

TAO_UIOP_Connection_Handler::~TAO_UIOP_Connection_Handler ( void   ) 

Destructor.

Definition at line 53 of file UIOP_Connection_Handler.cpp.

References ACE_ERROR, ACE_TEXT, LM_ERROR, release_os_resources(), TAO_debug_level, and TAO_Connection_Handler::transport().

00054 {
00055   delete this->transport ();
00056   int const result =
00057     this->release_os_resources ();
00058 
00059   if (result == -1 && TAO_debug_level)
00060     {
00061       ACE_ERROR ((LM_ERROR,
00062                   ACE_TEXT("TAO (%P|%t) - UIOP_Connection_Handler::")
00063                   ACE_TEXT("~UIOP_Connection_Handler, ")
00064                   ACE_TEXT("release_os_resources() failed %m\n")));
00065     }
00066 }


Member Function Documentation

int TAO_UIOP_Connection_Handler::add_transport_to_cache ( void   ) 

Add ourselves to Cache.

Definition at line 221 of file UIOP_Connection_Handler.cpp.

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

00222 {
00223   ACE_UNIX_Addr addr;
00224 
00225   // Get the peername.
00226   if (this->peer ().get_remote_addr (addr) == -1)
00227     return -1;
00228 
00229   // Construct an  UIOP_Endpoint object
00230   TAO_UIOP_Endpoint endpoint (addr);
00231 
00232   // Construct a property object
00233   TAO_Base_Transport_Property prop (&endpoint);
00234 
00235   TAO::Transport_Cache_Manager &cache =
00236     this->orb_core ()->lane_resources ().transport_cache ();
00237 
00238   // Add the handler to Cache
00239   return cache.cache_idle_transport (&prop, this->transport ());
00240 }

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< ACE_LSOCK_STREAM, ACE_NULL_SYNCH >.

Definition at line 209 of file UIOP_Connection_Handler.cpp.

References TAO_Connection_Handler::close_handler().

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

00210 {
00211   return this->close_handler ();
00212 }

int TAO_UIOP_Connection_Handler::close_connection ( void   )  [virtual]

Implements TAO_Connection_Handler.

Definition at line 152 of file UIOP_Connection_Handler.cpp.

References TAO_Connection_Handler::close_connection_eh().

Referenced by handle_output().

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

int TAO_UIOP_Connection_Handler::handle_close ( ACE_HANDLE  ,
ACE_Reactor_Mask   
) [virtual]

Reimplemented from ACE_Svc_Handler< ACE_LSOCK_STREAM, ACE_NULL_SYNCH >.

Definition at line 202 of file UIOP_Connection_Handler.cpp.

References ACE_ASSERT.

00203 {
00204   ACE_ASSERT (0);
00205   return 0;
00206 }

int TAO_UIOP_Connection_Handler::handle_input ( ACE_HANDLE   )  [virtual]

Implements TAO_Connection_Handler.

Definition at line 158 of file UIOP_Connection_Handler.cpp.

References TAO_Connection_Handler::handle_input_eh().

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

int TAO_UIOP_Connection_Handler::handle_output ( ACE_HANDLE   )  [virtual]

Reimplemented from ACE_Event_Handler.

Definition at line 164 of file UIOP_Connection_Handler.cpp.

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

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

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

Reimplemented from ACE_Svc_Handler< ACE_LSOCK_STREAM, ACE_NULL_SYNCH >.

Definition at line 179 of file UIOP_Connection_Handler.cpp.

References close(), TAO_LF_Event::LFS_TIMEOUT, and TAO_LF_Event::reset_state().

00181 {
00182   // Using this to ensure this instance will be deleted (if necessary)
00183   // only after reset_state(). Without this, when this refcount==1 -
00184   // the call to close() will cause a call to remove_reference() which
00185   // will delete this. At that point this->reset_state() is in no
00186   // man's territory and that causes SEGV on some platforms (Windows!)
00187 
00188   TAO_Auto_Reference<TAO_UIOP_Connection_Handler> safeguard (*this);
00189 
00190   // NOTE: Perhaps not the best solution, as it feels like the upper
00191   // layers should be responsible for this?
00192 
00193   // We don't use this upcall for I/O.  This is only used by the
00194   // Connector to indicate that the connection timedout.  Therefore,
00195   // we should call close().
00196   int const ret = this->close ();
00197   this->reset_state (TAO_LF_Event::LFS_TIMEOUT);
00198   return ret;
00199 }

int TAO_UIOP_Connection_Handler::open ( void *   )  [virtual]

Reimplemented from ACE_Svc_Handler< ACE_LSOCK_STREAM, ACE_NULL_SYNCH >.

Definition at line 75 of file UIOP_Connection_Handler.cpp.

References ACE_DEBUG, ACE_NONBLOCK, ACE_TEXT, TAO_Protocols_Hooks::client_protocol_properties_at_orb_level(), ACE_UNIX_Addr::get_path_name(), TAO_ORB_Core::get_protocols_hooks(), TAO_LF_Event::LFS_SUCCESS, LM_DEBUG, TAO_Connection_Handler::orb_core(), TAO_ORB_Core::orb_params(), ACE_Svc_Handler< ACE_LSOCK_STREAM, ACE_NULL_SYNCH >::peer(), TAO_UIOP_Protocol_Properties::recv_buffer_size_, TAO_UIOP_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, and TAO_debug_level.

Referenced by open_handler().

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

int TAO_UIOP_Connection_Handler::open_handler ( void *   )  [virtual]

Connection_Handler overloads

Implements TAO_Connection_Handler.

Definition at line 69 of file UIOP_Connection_Handler.cpp.

References open().

00070 {
00071   return this->open (v);
00072 }

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

Reimplemented from TAO_Connection_Handler.

Definition at line 215 of file UIOP_Connection_Handler.cpp.

References ACE_Svc_Handler< ACE_LSOCK_STREAM, ACE_NULL_SYNCH >::peer().

Referenced by ~TAO_UIOP_Connection_Handler().

00216 {
00217   return this->peer().close ();
00218 }

int TAO_UIOP_Connection_Handler::resume_handler ( void   )  [virtual]

Reimplemented from ACE_Event_Handler.

Definition at line 146 of file UIOP_Connection_Handler.cpp.

References ACE_Event_Handler::ACE_APPLICATION_RESUMES_HANDLER.


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:47:35 2010 for TAO_Strategies by  doxygen 1.4.7