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