Go to the documentation of this file.00001
00002
00003
00004
00005
00006 #include "orbsvcs/PortableGroup/UIPMC_Mcast_Connection_Handler.h"
00007 #include "orbsvcs/PortableGroup/UIPMC_Endpoint.h"
00008
00009 #include "tao/Timeprobe.h"
00010 #include "tao/debug.h"
00011 #include "tao/ORB_Core.h"
00012 #include "tao/ORB.h"
00013 #include "tao/CDR.h"
00014 #include "tao/Server_Strategy_Factory.h"
00015 #include "tao/Transport_Cache_Manager.h"
00016 #include "tao/Thread_Lane_Resources.h"
00017 #include "tao/Base_Transport_Property.h"
00018 #include "tao/Resume_Handle.h"
00019 #include "tao/Protocols_Hooks.h"
00020
00021
00022 ACE_RCSID(PortableGroup,
00023 UIPMC_Mcast_Connection_Handler,
00024 "$Id: UIPMC_Mcast_Connection_Handler.cpp 85817 2009-06-26 20:44:58Z mitza $")
00025
00026 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00027
00028 TAO_UIPMC_Mcast_Connection_Handler::TAO_UIPMC_Mcast_Connection_Handler (
00029 ACE_Thread_Manager *t)
00030 : TAO_UIPMC_MCAST_SVC_HANDLER (t, 0 , 0),
00031 TAO_Connection_Handler (0)
00032 {
00033
00034
00035
00036
00037
00038 ACE_ASSERT (0);
00039 }
00040
00041 TAO_UIPMC_Mcast_Connection_Handler::TAO_UIPMC_Mcast_Connection_Handler (
00042 TAO_ORB_Core *orb_core)
00043 : TAO_UIPMC_MCAST_SVC_HANDLER (orb_core->thr_mgr (), 0, 0),
00044 TAO_Connection_Handler (orb_core)
00045 {
00046 UIPMC_MULTICAST_TRANSPORT* specific_transport = 0;
00047 ACE_NEW(specific_transport,
00048 UIPMC_MULTICAST_TRANSPORT (this, orb_core));
00049
00050
00051 this->transport (specific_transport);
00052 }
00053
00054 TAO_UIPMC_Mcast_Connection_Handler::~TAO_UIPMC_Mcast_Connection_Handler (void)
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_Mcast_Connection_Handler::")
00064 ACE_TEXT("~UIPMC_Mcast_Connection_Handler, ")
00065 ACE_TEXT("release_os_resources() failed %m\n")));
00066 }
00067 }
00068
00069 const ACE_INET_Addr &
00070 TAO_UIPMC_Mcast_Connection_Handler::addr (void)
00071 {
00072 return this->addr_;
00073 }
00074
00075 void
00076 TAO_UIPMC_Mcast_Connection_Handler::addr (const ACE_INET_Addr &addr)
00077 {
00078 this->addr_ = addr;
00079 }
00080
00081 const ACE_INET_Addr &
00082 TAO_UIPMC_Mcast_Connection_Handler::local_addr (void)
00083 {
00084 return local_addr_;
00085 }
00086
00087 void
00088 TAO_UIPMC_Mcast_Connection_Handler::local_addr (const ACE_INET_Addr &addr)
00089 {
00090 local_addr_ = addr;
00091 }
00092
00093 ssize_t
00094 TAO_UIPMC_Mcast_Connection_Handler::send (const iovec [],
00095 int,
00096 const ACE_Addr &,
00097 int) const
00098 {
00099 ACE_ASSERT (0);
00100 return -1;
00101 }
00102
00103 int
00104 TAO_UIPMC_Mcast_Connection_Handler::open_handler (void *v)
00105 {
00106 return this->open (v);
00107 }
00108
00109 int
00110 TAO_UIPMC_Mcast_Connection_Handler::open (void*)
00111 {
00112 this->peer ().join (this->local_addr_);
00113
00114 if (TAO_debug_level > 5)
00115 {
00116 ACE_DEBUG ((LM_DEBUG,
00117 ACE_TEXT("TAO (%P|%t) - UIPMC_Mcast_Connection_Handler::open_server, ")
00118 ACE_TEXT("subcribed to multicast group at %s:%d\n"),
00119 this->local_addr_.get_host_addr (),
00120 this->local_addr_.get_port_number ()
00121 ));
00122 }
00123
00124 this->transport ()->id ((size_t) this->peer ().get_handle ());
00125
00126 return 0;
00127 }
00128
00129 int
00130 TAO_UIPMC_Mcast_Connection_Handler::resume_handler (void)
00131 {
00132 return ACE_Event_Handler::ACE_APPLICATION_RESUMES_HANDLER;
00133 }
00134
00135 int
00136 TAO_UIPMC_Mcast_Connection_Handler::close_connection (void)
00137 {
00138 return this->close_connection_eh (this);
00139 }
00140
00141 int
00142 TAO_UIPMC_Mcast_Connection_Handler::handle_input (ACE_HANDLE h)
00143 {
00144 return this->handle_input_eh (h, this);
00145 }
00146
00147 int
00148 TAO_UIPMC_Mcast_Connection_Handler::handle_output (ACE_HANDLE handle)
00149 {
00150 int result =
00151 this->handle_output_eh (handle, this);
00152
00153 if (result == -1)
00154 {
00155 this->close_connection ();
00156 return 0;
00157 }
00158
00159 return result;
00160 }
00161
00162 int
00163 TAO_UIPMC_Mcast_Connection_Handler::handle_timeout (const ACE_Time_Value &,
00164 const void *)
00165 {
00166
00167
00168
00169
00170
00171
00172 TAO_Auto_Reference<TAO_UIPMC_Mcast_Connection_Handler> safeguard (*this);
00173
00174
00175
00176
00177
00178
00179
00180 int ret = this->close ();
00181 this->reset_state (TAO_LF_Event::LFS_TIMEOUT);
00182 return ret;
00183 }
00184
00185 int
00186 TAO_UIPMC_Mcast_Connection_Handler::handle_close (ACE_HANDLE,
00187 ACE_Reactor_Mask)
00188 {
00189
00190
00191
00192
00193
00194 return 0;
00195 }
00196
00197 int
00198 TAO_UIPMC_Mcast_Connection_Handler::close (u_long flags)
00199 {
00200 return this->close_handler (flags);
00201 }
00202
00203 int
00204 TAO_UIPMC_Mcast_Connection_Handler::release_os_resources (void)
00205 {
00206 return this->peer ().close ();
00207 }
00208
00209 int
00210 TAO_UIPMC_Mcast_Connection_Handler::add_transport_to_cache (void)
00211 {
00212 ACE_INET_Addr addr;
00213
00214
00215
00216
00217
00218
00219
00220 TAO_UIPMC_Endpoint endpoint (addr);
00221
00222
00223 TAO_Base_Transport_Property prop (&endpoint);
00224
00225
00226 return this->orb_core ()->lane_resources ()
00227 .transport_cache ().cache_transport (&prop,
00228 this->transport ());
00229 }
00230
00231 int
00232 TAO_UIPMC_Mcast_Connection_Handler::handle_write_ready
00233 (const ACE_Time_Value *t)
00234 {
00235 return ACE::handle_write_ready (this->peer ().get_handle (), t);
00236 }
00237
00238 TAO_END_VERSIONED_NAMESPACE_DECL