COIOP_Connection_Handler.cpp

Go to the documentation of this file.
00001 // $Id: COIOP_Connection_Handler.cpp 78931 2007-07-18 09:59:36Z johnnyw $
00002 
00003 #include "tao/Strategies/COIOP_Connection_Handler.h"
00004 
00005 #if defined (TAO_HAS_COIOP) && (TAO_HAS_COIOP != 0)
00006 
00007 #include "tao/Timeprobe.h"
00008 #include "tao/debug.h"
00009 #include "tao/ORB_Core.h"
00010 #include "tao/ORB.h"
00011 #include "tao/CDR.h"
00012 #include "tao/Server_Strategy_Factory.h"
00013 #include "tao/Transport_Cache_Manager.h"
00014 #include "tao/Thread_Lane_Resources.h"
00015 #include "tao/Base_Transport_Property.h"
00016 #include "tao/Protocols_Hooks.h"
00017 #include "tao/Resume_Handle.h"
00018 
00019 #include "tao/Strategies/COIOP_Transport.h"
00020 #include "tao/Strategies/COIOP_Endpoint.h"
00021 
00022 ACE_RCSID(tao, COIOP_Connect, "$Id: COIOP_Connection_Handler.cpp 78931 2007-07-18 09:59:36Z johnnyw $")
00023 
00024 
00025 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00026 
00027 TAO_COIOP_Connection_Handler::TAO_COIOP_Connection_Handler (ACE_Thread_Manager *t)
00028   : TAO_COIOP_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 }
00038 
00039 
00040 TAO_COIOP_Connection_Handler::TAO_COIOP_Connection_Handler (TAO_ORB_Core *orb_core)
00041   : TAO_COIOP_SVC_HANDLER (orb_core->thr_mgr (), 0, 0),
00042     TAO_Connection_Handler (orb_core)
00043 {
00044   TAO_COIOP_Transport* specific_transport = 0;
00045   ACE_NEW (specific_transport,
00046            TAO_COIOP_Transport(this, orb_core));
00047 
00048   // store this pointer (indirectly increment ref count)
00049   this->transport (specific_transport);
00050 }
00051 
00052 
00053 TAO_COIOP_Connection_Handler::~TAO_COIOP_Connection_Handler (void)
00054 {
00055   delete this->transport ();
00056 
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) - COIOP_Connection_Handler::")
00064                   ACE_TEXT("~COIOP_Connection_Handler, ")
00065                   ACE_TEXT("release_os_resources() failed %m\n")));
00066     }
00067   delete this->transport ();
00068 }
00069 
00070 int
00071 TAO_COIOP_Connection_Handler::open_handler (void *v)
00072 {
00073   return this->open (v);
00074 }
00075 
00076 int
00077 TAO_COIOP_Connection_Handler::open (void*)
00078 {
00079   return 0;
00080 }
00081 
00082 int
00083 TAO_COIOP_Connection_Handler::resume_handler (void)
00084 {
00085   return ACE_Event_Handler::ACE_APPLICATION_RESUMES_HANDLER;
00086 }
00087 
00088 int
00089 TAO_COIOP_Connection_Handler::close_connection (void)
00090 {
00091   return this->close_connection_eh (this);
00092 }
00093 
00094 int
00095 TAO_COIOP_Connection_Handler::handle_input (ACE_HANDLE h)
00096 {
00097   return this->handle_input_eh (h, this);
00098 }
00099 
00100 int
00101 TAO_COIOP_Connection_Handler::handle_output (ACE_HANDLE handle)
00102 {
00103   int const result =
00104     this->handle_output_eh (handle, this);
00105 
00106   if (result == -1)
00107     {
00108       this->close_connection ();
00109       return 0;
00110     }
00111 
00112   return result;
00113 }
00114 
00115 int
00116 TAO_COIOP_Connection_Handler::handle_timeout (const ACE_Time_Value &,
00117                                               const void *)
00118 {
00119   // We don't use this upcall from the Reactor.  However, we should
00120   // override this since the base class returns -1 which will result
00121   // in handle_close() getting called.
00122   return 0;
00123 }
00124 
00125 int
00126 TAO_COIOP_Connection_Handler::handle_close (ACE_HANDLE,
00127                                             ACE_Reactor_Mask)
00128 {
00129   // No asserts here since the handler is registered with the Reactor
00130   // and the handler ownership is given to the Reactor.  When the
00131   // Reactor closes, it will call handle_close() on the handler.  It
00132   // is however important to overwrite handle_close() to do nothing
00133   // since the base class does too much.
00134   return 0;
00135 }
00136 
00137 int
00138 TAO_COIOP_Connection_Handler::close (u_long)
00139 {
00140   return this->close_handler ();
00141 }
00142 
00143 TAO_END_VERSIONED_NAMESPACE_DECL
00144 
00145 #endif /* TAO_HAS_COIOP && TAO_HAS_COIOP != 0 */

Generated on Sun Jan 27 15:59:45 2008 for TAO_Strategies by doxygen 1.3.6