Go to the documentation of this file.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 {
00084
00085 sh->transport ()->remove_reference ();
00086
00087
00088
00089 return -1;
00090 }
00091
00092
00093 if (sh->add_transport_to_cache () == -1)
00094 {
00095
00096 sh->close ();
00097
00098
00099 sh->transport ()->remove_reference ();
00100
00101
00102
00103 if (TAO_debug_level > 0)
00104 {
00105 ACE_ERROR ((LM_ERROR,
00106 ACE_TEXT ("TAO (%P|%t) - Concurrency_Strategy::activate_svc_handler, ")
00107 ACE_TEXT ("could not add the handler to cache\n")));
00108 }
00109
00110 return -1;
00111 }
00112
00113
00114
00115
00116 TAO_Server_Strategy_Factory *f =
00117 this->orb_core_->server_factory ();
00118
00119 int result = 0;
00120
00121
00122 if (f->activate_server_connections ())
00123 {
00124
00125 TAO_Thread_Per_Connection_Handler *tpch = 0;
00126
00127 ACE_NEW_RETURN (tpch,
00128 TAO_Thread_Per_Connection_Handler (sh,
00129 this->orb_core_),
00130 -1);
00131
00132 result =
00133 tpch->activate (f->server_connection_thread_flags (),
00134 f->server_connection_thread_count ());
00135 }
00136 else
00137 {
00138
00139
00140
00141 result = sh->transport ()->register_handler ();
00142 }
00143
00144 if (result != -1)
00145 {
00146
00147
00148
00149
00150
00151
00152 sh->transport ()->remove_reference ();
00153 }
00154 else
00155 {
00156
00157
00158
00159
00160 sh->transport ()->purge_entry ();
00161
00162
00163
00164
00165 sh->close ();
00166
00167
00168 sh->transport ()->remove_reference ();
00169
00170
00171
00172 if (TAO_debug_level > 0)
00173 {
00174 const ACE_TCHAR *error = 0;
00175 if (f->activate_server_connections ())
00176 error = ACE_TEXT("could not activate new connection");
00177 else
00178 error = ACE_TEXT("could not register new connection in the reactor");
00179
00180 ACE_ERROR ((LM_ERROR,
00181 ACE_TEXT("TAO (%P|%t) - Concurrency_Strategy::activate_svc_handler, ")
00182 ACE_TEXT("%s\n"), error));
00183 }
00184
00185 return -1;
00186 }
00187
00188
00189 return result;
00190 }
00191
00192
00193
00194 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1>
00195 TAO_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::TAO_Accept_Strategy (TAO_ORB_Core *orb_core)
00196 : orb_core_ (orb_core)
00197 {
00198 }
00199
00200 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
00201 TAO_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open (const ACE_PEER_ACCEPTOR_ADDR &local_addr,
00202 bool restart)
00203 {
00204 return ACCEPT_STRATEGY_BASE::open (local_addr, restart);
00205 }
00206
00207 template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> int
00208 TAO_Accept_Strategy<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::accept_svc_handler (SVC_HANDLER *svc_handler)
00209 {
00210 int const result = ACCEPT_STRATEGY_BASE::accept_svc_handler (svc_handler);
00211 if (result == -1)
00212 {
00213 svc_handler->transport ()->remove_reference ();
00214
00215
00216 }
00217
00218 return result;
00219 }
00220
00221
00222
00223
00224 TAO_END_VERSIONED_NAMESPACE_DECL
00225
00226 #endif