00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef TAO_ACCEPTOR_IMPL_CPP
00020 #define TAO_ACCEPTOR_IMPL_CPP
00021
00022 #include "tao/Acceptor_Impl.h"
00023
00024 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 # pragma once
00026 #endif
00027
00028 #include "tao/Thread_Per_Connection_Handler.h"
00029 #include "tao/Server_Strategy_Factory.h"
00030 #include "tao/ORB_Core.h"
00031 #include "tao/Transport_Cache_Manager.h"
00032 #include "tao/Thread_Lane_Resources.h"
00033 #include "tao/Transport.h"
00034 #include "tao/debug.h"
00035
00036 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
00037
00038
00039
00040 template <class SVC_HANDLER>
00041 TAO_Creation_Strategy<SVC_HANDLER>::TAO_Creation_Strategy (TAO_ORB_Core *orb_core,
00042 CORBA::Boolean flag)
00043 : ACE_Creation_Strategy<SVC_HANDLER> (0, orb_core->reactor()),
00044 orb_core_ (orb_core),
00045 lite_flag_ (flag)
00046 {
00047 }
00048
00049 template <class SVC_HANDLER> int
00050 TAO_Creation_Strategy<SVC_HANDLER>::make_svc_handler (SVC_HANDLER *&sh)
00051 {
00052 if (sh == 0)
00053 {
00054
00055 this->orb_core_->lane_resources ().transport_cache ().purge ();
00056
00057 ACE_NEW_RETURN (sh,
00058 SVC_HANDLER (this->orb_core_,
00059 this->lite_flag_),
00060 -1);
00061 }
00062
00063 return 0;
00064 }
00065
00066
00067
00068 template <class SVC_HANDLER>
00069 TAO_Concurrency_Strategy<SVC_HANDLER>::TAO_Concurrency_Strategy (TAO_ORB_Core *orb_core)
00070 : orb_core_ (orb_core)
00071 {
00072 }
00073
00074 template <class SVC_HANDLER> int
00075 TAO_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (SVC_HANDLER *sh,
00076 void *arg)
00077 {
00078 sh->transport ()->opened_as (TAO::TAO_SERVER_ROLE);
00079
00080
00081 if (TAO_debug_level > 6)
00082 ACE_DEBUG ((LM_DEBUG,
00083 "TAO (%P|%t) - Concurrency_Strategy::activate_svc_handler, "
00084 "opened as TAO_SERVER_ROLE\n"));
00085
00086
00087
00088
00089 if (this->ACE_Concurrency_Strategy<SVC_HANDLER>::activate_svc_handler (sh,
00090 arg) == -1)
00091 return -1;
00092
00093
00094 if (sh->add_transport_to_cache () == -1)
00095 {
00096
00097 sh->close ();
00098
00099
00100
00101 if (TAO_debug_level > 0)
00102 {
00103 ACE_ERROR ((LM_ERROR,
00104 ACE_TEXT ("TAO (%P|%t) - Concurrency_Strategy::activate_svc_handler, ")
00105 ACE_TEXT ("could not add the handler to cache \n")));
00106 }
00107
00108 return -1;
00109 }
00110
00111
00112
00113
00114 TAO_Server_Strategy_Factory *f =
00115 this->orb_core_->server_factory ();
00116
00117 int result = 0;
00118
00119
00120 if (f->activate_server_connections ())
00121 {
00122
00123 TAO_Thread_Per_Connection_Handler *tpch = 0;
00124
00125 ACE_NEW_RETURN (tpch,
00126 TAO_Thread_Per_Connection_Handler (sh,
00127 this->orb_core_),
00128 -1);
00129
00130 result =
00131 tpch->activate (f->server_connection_thread_flags (),
00132 f->server_connection_thread_count ());
00133 }
00134 else
00135 {
00136
00137
00138
00139 result =
00140 sh->transport ()->register_handler ();
00141 }
00142
00143 if (result != -1)
00144 {
00145
00146
00147
00148
00149
00150
00151 sh->transport ()->remove_reference ();
00152 }
00153 else
00154 {
00155
00156
00157
00158
00159 sh->transport ()->purge_entry ();
00160
00161
00162
00163
00164 sh->close ();
00165
00166
00167
00168 if (TAO_debug_level > 0)
00169 {
00170 const ACE_TCHAR *error = 0;
00171 if (f->activate_server_connections ())
00172 error = ACE_TEXT("could not activate new connection");
00173 else
00174 error = ACE_TEXT("could not register new connection in the reactor");
00175
00176 ACE_ERROR ((LM_ERROR,
00177 "TAO (%P|%t) - Concurrency_Strategy::activate_svc_handler, "
00178 "%s\n", error));
00179 }
00180
00181 return -1;
00182 }
00183
00184
00185 return result;
00186 }
00187
00188
00189
00190 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
00191 TAO_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::TAO_Accept_Strategy (TAO_ORB_Core *orb_core)
00192 : orb_core_ (orb_core)
00193 {
00194 }
00195
00196 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
00197 TAO_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open (const ACE_PEER_ACCEPTOR_ADDR &local_addr,
00198 int restart)
00199 {
00200
00201 return ACCEPT_STRATEGY_BASE::open (local_addr,
00202 restart);
00203 }
00204
00205 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
00206 TAO_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler (SVC_HANDLER *svc_handler)
00207 {
00208 return ACCEPT_STRATEGY_BASE::accept_svc_handler (svc_handler);
00209 }
00210
00211
00212
00213
00214 TAO_END_VERSIONED_NAMESPACE_DECL
00215
00216 #endif