From b5738783687df2ecc211f1fefeb8e63ce5fd78bc Mon Sep 17 00:00:00 2001 From: iliyan Date: Fri, 27 Oct 2006 18:30:31 +0000 Subject: Eliminated the problems caused by my fat-fingered patch ... --- TAO/orbsvcs/Transport_Current/Current_Loader.cpp | 156 ---------- .../Current_ORBInitializer_Base.cpp | 76 ----- .../Transport_Current/IIOP_Current_Impl.cpp | 124 -------- .../Transport_Current/IIOP_Current_Loader.cpp | 95 ------ .../Framework/Client_Request_Interceptor.cpp | 182 ------------ .../Transport_Current/Framework/Current_Test.idl | 34 --- .../Framework/Current_Test_Impl.cpp | 169 ----------- .../Transport_Current/Framework/Server_Main.cpp | 23 -- .../Framework/Server_Request_Interceptor.cpp | 164 ----------- .../tests/Transport_Current/Framework/Tester.cpp | 70 ----- .../tests/Transport_Current/Framework/client.cpp | 287 ------------------ .../tests/Transport_Current/Framework/server.cpp | 240 --------------- .../Transport_Current/IIOP/IIOP_Server_Main.cpp | 23 -- .../IIOP/IIOP_Server_Request_Interceptor.cpp | 323 --------------------- .../tests/Transport_Current/IIOP/IIOP_Tester.cpp | 81 ------ 15 files changed, 2047 deletions(-) diff --git a/TAO/orbsvcs/Transport_Current/Current_Loader.cpp b/TAO/orbsvcs/Transport_Current/Current_Loader.cpp index ea0cb0fb3f7..c0fb7e73ac1 100644 --- a/TAO/orbsvcs/Transport_Current/Current_Loader.cpp +++ b/TAO/orbsvcs/Transport_Current/Current_Loader.cpp @@ -118,162 +118,6 @@ TAO_END_VERSIONED_NAMESPACE_DECL -#if defined (TAO_AS_STATIC_LIBS) - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -ACE_STATIC_SVC_REQUIRE (TAO_Transport_Current_Loader); - -namespace TAO -{ - namespace Transport - { - int current_static_initializer (void) - { - ACE_STATIC_SVC_REGISTER (TAO_Transport_Current_Loader); - return 0; - } - - } -} - -TAO_END_VERSIONED_NAMESPACE_DECL - -#endif /* defined (TAO_AS_STATIC_LIBS) */ - - - - -ACE_STATIC_SVC_DEFINE (TAO_Transport_Current_Loader, - ACE_TEXT ("TAO_Transport_Current_Loader"), - ACE_SVC_OBJ_T, - &ACE_SVC_NAME (TAO_Transport_Current_Loader), - ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, - 0) - -ACE_FACTORY_NAMESPACE_DEFINE (TAO_Transport_Current, - TAO_Transport_Current_Loader, - TAO::Transport::Current_Loader) -/* -*- C++ -*- */ - -// ================================================================= -/** - * @file Current_Loader.cpp - * - * $Id$ - * - * @author Iliyan Jeliazkov - * - */ -// ================================================================= - - -#include "ace/Service_Config.h" - -#include "tao/ORB_Constants.h" -#include "tao/ORBInitializer_Registry.h" - -#include "tao/PI/PI.h" - -#include "orbsvcs/Transport_Current/Current_ORBInitializer.h" -#include "orbsvcs/Transport_Current/Current_Loader.h" -#include "orbsvcs/Transport_Current/Current_Impl.h" -//#include "orbsvcs/Transport_Current/TCC.h" - -ACE_RCSID (Transport_Current, - Current_Loader, - "$Id$") - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace TAO -{ - namespace Transport - { - - /// A helper method for obtaining access to the the Transport - /// Factory Manager instance. - - Current_Loader* - Current_Loader::instance (void) - { - Current_Loader *cl = - ACE_Dynamic_Service ::instance (ACE_TEXT ("TAO_Transport_Current_Loader")); - - if (cl == 0) -#if defined (TAO_AS_STATIC_LIBS) - { - if (TAO_debug_level > 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%P|%t) Unable to obtain Current::Loader instance: %m\n")), - 0); - return 0; - } -#else - { - // In case we build shared, try to load the appropriate library. - ACE_Service_Config::process_directive - (ACE_DYNAMIC_SERVICE_DIRECTIVE("TAO_Transport_Current_Loader", - "TAO_TC", - "_make_TAO_Transport_Current_Loader", - "")); - cl = ACE_Dynamic_Service::instance (ACE_TEXT ("TAO_Transport_Current_Loader")); - } -#endif /* TAO_AS_STATIC_LIBS */ - - if (cl != 0) - return cl; - - if (TAO_debug_level > 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("(%P|%t) Unable to obtain Current::Loader instance: %m\n")), - 0); - return 0; - } - - - /// dtor - - Current_Loader::~Current_Loader (void) - { - } - - - - /// Initializes object when dynamic linking occurs. - - int - Current_Loader::init (int, ACE_TCHAR *[]) - { - PortableInterceptor::ORBInitializer_ptr tmp = 0; - ACE_NEW_THROW_EX (tmp, - Current_ORBInitializer - (ACE_TEXT ("TAO::Transport::Current")), - CORBA::NO_MEMORY - (CORBA::SystemException::_tao_minor_code (TAO::VMCID, - ENOMEM), - CORBA::COMPLETED_NO)); - ACE_TRY_CHECK; - - PortableInterceptor::ORBInitializer_var initializer (tmp); - - PortableInterceptor::register_orb_initializer (initializer.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - return 0; - } - - } /* namespace Transport */ - -} /* namespace TAO */ - -TAO_END_VERSIONED_NAMESPACE_DECL - - - - - #if defined (TAO_AS_STATIC_LIBS) TAO_BEGIN_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/Transport_Current/Current_ORBInitializer_Base.cpp b/TAO/orbsvcs/Transport_Current/Current_ORBInitializer_Base.cpp index 874f77f7230..81451724e5f 100644 --- a/TAO/orbsvcs/Transport_Current/Current_ORBInitializer_Base.cpp +++ b/TAO/orbsvcs/Transport_Current/Current_ORBInitializer_Base.cpp @@ -22,82 +22,6 @@ namespace TAO - void - Current_ORBInitializer_Base::pre_init (PortableInterceptor::ORBInitInfo_ptr info - ACE_ENV_ARG_DECL_NOT_USED ) - ACE_THROW_SPEC( (CORBA::SystemException) ) - { - // Narrow to a TAO_ORBInitInfo object to get access to the - // allocate_tss_slot_id() TAO extension. - TAO_ORBInitInfo_var tao_info = - TAO_ORBInitInfo::_narrow (info - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - if (CORBA::is_nil (tao_info.in ())) - { - if (TAO_debug_level > 0) - ACE_ERROR ((LM_ERROR, - "TAO (%P|%t) TAO::Transport::ORBInitializer::pre_init - " - "Panic: unable to narrow the ORBInitInfo_ptr\n")); - - ACE_THROW (CORBA::INTERNAL ()); - } - - // Reserve a TSS slot in the ORB core internal TSS resources for the - // thread-specific portion of the Current object. - size_t tss_slot = tao_info->allocate_tss_slot_id (0 - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - // Create the Current - Current_var current (this->make_current_instance (tao_info->orb_core (), - tss_slot - ACE_ENV_ARG_PARAMETER)); - - info->register_initial_reference (ACE_TEXT_ALWAYS_CHAR (this->id_.fast_rep ()), - current.in ()); - - } - - void - Current_ORBInitializer_Base::post_init (PortableInterceptor::ORBInitInfo_ptr - ACE_ENV_ARG_DECL_NOT_USED ) - ACE_THROW_SPEC( (CORBA::SystemException) ) - { - } - - } - -} - -TAO_END_VERSIONED_NAMESPACE_DECL - -#include /**/ "ace/post.h" -// $Id$ - -#include "tao/PI/ORBInitInfo.h" - -#include "orbsvcs/Transport_Current/Current_ORBInitializer_Base.h" - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace TAO -{ - namespace Transport - { - - Current_ORBInitializer_Base::Current_ORBInitializer_Base(const ACE_TCHAR* id) - : id_ (id) - { - } - - Current_ORBInitializer_Base::~Current_ORBInitializer_Base(void) - { - } - - - void Current_ORBInitializer_Base::pre_init (PortableInterceptor::ORBInitInfo_ptr info ACE_ENV_ARG_DECL_NOT_USED ) diff --git a/TAO/orbsvcs/Transport_Current/IIOP_Current_Impl.cpp b/TAO/orbsvcs/Transport_Current/IIOP_Current_Impl.cpp index c3f765a7a58..649cb6258ed 100644 --- a/TAO/orbsvcs/Transport_Current/IIOP_Current_Impl.cpp +++ b/TAO/orbsvcs/Transport_Current/IIOP_Current_Impl.cpp @@ -121,128 +121,4 @@ namespace TAO } -TAO_END_VERSIONED_NAMESPACE_DECL -// $Id$ - -#include "ace/INET_Addr.h" -#include "tao/IIOP_Connection_Handler.h" -#include "tao/IIOP_Transport.h" -#include "tao/Transport_Selection_Guard.h" - -#include "IIOP_Current_Impl.h" - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace TAO -{ - namespace Transport - { - - - /// Obtains the IIOP_Connection_Handler associated with the - /// Transport. Will throw NO_IMPLEMENT if the (selected) transport - /// () == 0, or if transport->connection_handler () == 0. Will - /// throw NoContext, if no transport has been selected yet. - - TAO_IIOP_Connection_Handler* - IIOP_Current_Impl::handler (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) - { - const TAO_Transport* t = this->transport (); - if (t == 0) - ACE_THROW_RETURN (::CORBA::NO_IMPLEMENT (), 0); - - TAO_Connection_Handler *ch = const_cast(t)->connection_handler (); - if (ch == 0) - ACE_THROW_RETURN (::CORBA::NO_IMPLEMENT (), 0); - - return static_cast (ch); - } - - - /// Ctor - - IIOP_Current_Impl::IIOP_Current_Impl (TAO_ORB_Core* core, size_t tss_slot_id) - : Current_Impl (core, tss_slot_id) - { - } - - - /// Dtor - - IIOP_Current_Impl::~IIOP_Current_Impl (void) - { - } - - CORBA::Long - IIOP_Current_Impl::id (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) - { - return this->handler ()->get_handle (); - } - - ::SSLIOP::Current_ptr - IIOP_Current_Impl::ssliop_current (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) - { - ACE_THROW_RETURN (::CORBA::NO_IMPLEMENT (), 0); - } - - - CORBA::Long - IIOP_Current_Impl::remote_port (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) - { - TAO_IIOP_Connection_Handler *iiopch = - this->handler (); - - ACE_INET_Addr a; - iiopch->peer ().get_remote_addr (a); - - return a.get_port_number (); - } - - char* - IIOP_Current_Impl::remote_host (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) - { - TAO_IIOP_Connection_Handler *iiopch = - this->handler (); - - ACE_INET_Addr a; - iiopch->peer ().get_remote_addr (a); - - return CORBA::string_dup (a.get_host_addr ()); - } - - CORBA::Long - IIOP_Current_Impl::local_port (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) - { - TAO_IIOP_Connection_Handler *iiopch = - this->handler (); - - ACE_INET_Addr a; - iiopch->peer ().get_local_addr (a); - - return a.get_port_number (); - } - - char* - IIOP_Current_Impl::local_host (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((::CORBA::SystemException, NoContext)) - { - TAO_IIOP_Connection_Handler *iiopch = - this->handler (); - - ACE_INET_Addr a; - iiopch->peer ().get_local_addr (a); - - return CORBA::string_dup (a.get_host_addr ()); - } - - } -} - - TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/orbsvcs/Transport_Current/IIOP_Current_Loader.cpp b/TAO/orbsvcs/Transport_Current/IIOP_Current_Loader.cpp index 559014bd081..707702de20d 100644 --- a/TAO/orbsvcs/Transport_Current/IIOP_Current_Loader.cpp +++ b/TAO/orbsvcs/Transport_Current/IIOP_Current_Loader.cpp @@ -81,101 +81,6 @@ namespace TAO #endif /* defined (TAO_AS_STATIC_LIBS) */ -TAO_END_VERSIONED_NAMESPACE_DECL - -ACE_STATIC_SVC_DEFINE (TAO_Transport_IIOP_Current_Loader, - ACE_TEXT ("TAO_Transport_IIOP_Current_Loader"), - ACE_SVC_OBJ_T, - &ACE_SVC_NAME (TAO_Transport_IIOP_Current_Loader), - ACE_Service_Type::DELETE_THIS | ACE_Service_Type::DELETE_OBJ, - 0) - -ACE_FACTORY_NAMESPACE_DEFINE (TAO_Transport_Current, - TAO_Transport_IIOP_Current_Loader, - TAO::Transport::IIOP::Current_Loader) -/* -*- C++ -*- */ - -// ================================================================= -/** - * @file IIOP_Current_Loader.cpp - * - * $Id$ - * - * @author Iliyan Jeliazkov - * - */ -// ================================================================= - - -#include "ace/Service_Config.h" - -#include "tao/ORBInitializer_Registry.h" -#include "tao/ORB_Constants.h" - -#include "tao/PI/PI.h" - -#include "orbsvcs/Transport_Current/Current_ORBInitializer.h" -#include "orbsvcs/Transport_Current/IIOP_Current_Loader.h" -#include "orbsvcs/Transport_Current/IIOP_Current_Impl.h" - -ACE_RCSID (Transport_Current, - IIOP_Current_Loader, - "$Id$") - -TAO_BEGIN_VERSIONED_NAMESPACE_DECL - -namespace TAO -{ - namespace Transport - { - namespace IIOP - { - /// Initializes object when dynamic linking occurs. - int - Current_Loader::init (int, ACE_TCHAR *[]) - { - PortableInterceptor::ORBInitializer_ptr tmp = 0; - ACE_NEW_THROW_EX (tmp, - Current_ORBInitializer (ACE_TEXT ("TAO::Transport::IIOP::Current")), - CORBA::NO_MEMORY (CORBA::SystemException::_tao_minor_code (TAO::VMCID, - ENOMEM), - CORBA::COMPLETED_NO)); - ACE_TRY_CHECK; - - PortableInterceptor::ORBInitializer_var initializer (tmp); - - PortableInterceptor::register_orb_initializer (initializer.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - return 0; - } - } - - } -} - - -#if defined (TAO_AS_STATIC_LIBS) -ACE_STATIC_SVC_REQUIRE (TAO_Transport_IIOP_Current_Loader); - -namespace TAO -{ - namespace Transport - { - namespace IIOP - { - int current_static_initializer (void) - { - ACE_STATIC_SVC_REGISTER (TAO_Transport_IIOP_Current_Loader); - return 0; - } - } - } -} -#endif /* defined (TAO_AS_STATIC_LIBS) */ - - TAO_END_VERSIONED_NAMESPACE_DECL ACE_STATIC_SVC_DEFINE (TAO_Transport_IIOP_Current_Loader, diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/Client_Request_Interceptor.cpp b/TAO/orbsvcs/tests/Transport_Current/Framework/Client_Request_Interceptor.cpp index 05190ee9efa..51e7fa04b31 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/Client_Request_Interceptor.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/Client_Request_Interceptor.cpp @@ -17,188 +17,6 @@ ACE_RCSID (ForwardRequest, // ACE_THROW_SPEC ((CORBA::SystemException)); -namespace Test -{ - - using namespace TAO; - - // A specialization to handle client-side interceptors - template <> - void - ORBInitializer::post_init (PortableInterceptor::ORBInitInfo* oii - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - oii->add_client_request_interceptor (this->interceptor_.in ()); - }; - - Client_Request_Interceptor::Client_Request_Interceptor (const char *orb_id, - TEST test) - : orb_id_ (CORBA::string_dup (orb_id)) - , request_count_ (0) - , requestID_ (1) - , test_ (test) - { - } - - CORBA::Long - Client_Request_Interceptor::interceptions (void) - { - return this->request_count_; - } - - char * - Client_Request_Interceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - return CORBA::string_dup ("Client_Request_Interceptor"); - } - - void - Client_Request_Interceptor::test_transport_current (const ACE_TCHAR* amethod - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - CORBA::UserException)) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("CRI (%P|%t) Test accessing Transport Current from %s\n"), - amethod)); - - ++this->request_count_; - - int tmp = 0; - CORBA::ORB_var orb = CORBA::ORB_init (tmp, - 0, - orb_id_.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - - (*this->test_) (orb.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("CRI (%P|%t) Successfully tested Transport Current from %s\n"), - amethod)); - } - - void - Client_Request_Interceptor::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - } - - void - Client_Request_Interceptor::send_request (PortableInterceptor::ClientRequestInfo_ptr ri - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - PortableInterceptor::ForwardRequest)) - { - //Test TC - - test_transport_current ("send_request" - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - CORBA::Boolean response_expected = - ri->response_expected (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; - - // Oneway? - if (response_expected) - ACE_DEBUG ((LM_DEBUG, ACE_TEXT("CRI (%P|%t) Sending a two-way\n"))); - else - ACE_DEBUG ((LM_DEBUG, ACE_TEXT("CRI (%P|%t) Sending a one-way\n"))); - - // Make the context to send the context to the target - - IOP::ServiceContext sc; - sc.context_id = TAO::Transport::CurrentTest::ContextTag; - - char temp[100]; - { - ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_); - - ACE_OS::sprintf (temp, "%d", this->requestID_); - this->requestID_++; - } - - CORBA::ULong string_len = ACE_OS::strlen (temp) + 1; - CORBA::Octet *buf = CORBA::OctetSeq::allocbuf (string_len); - ACE_OS::strcpy (ACE_reinterpret_cast (char *, buf), temp); - - sc.context_data.replace (string_len, string_len, buf, 1); - - // Add this context to the service context list. - ri->add_request_service_context (sc, 0 ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - } - - void - Client_Request_Interceptor::send_poll (PortableInterceptor::ClientRequestInfo_ptr - ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - test_transport_current ("send_poll" - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } - - void - Client_Request_Interceptor::receive_reply (PortableInterceptor::ClientRequestInfo_ptr - ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - test_transport_current ("receive_reply" - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } - - void - Client_Request_Interceptor::receive_exception (PortableInterceptor::ClientRequestInfo_ptr - ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException, - PortableInterceptor::ForwardRequest)) - { - test_transport_current ("receive_exception" - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } - - void - Client_Request_Interceptor::receive_other (PortableInterceptor::ClientRequestInfo_ptr - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - PortableInterceptor::ForwardRequest)) - { - - test_transport_current ("receive_other" - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - } - -} -// -*- C++ -*- - -#include "ace/Log_Msg.h" - -ACE_RCSID (ForwardRequest, - Client_Request_Interceptor, - "$Id$") - -#include "Current_TestC.h" -#include "Client_Request_Interceptor.h" -#include "ORBInitializer_T.h" - -// // A specialization to handle client-side interceptors -// template <> -// void ORBInitializer::post_init -// (PortableInterceptor::ORBInitInfo* oii ACE_ENV_ARG_DECL_WITH_DEFAULTS) -// ACE_THROW_SPEC ((CORBA::SystemException)); - - namespace Test { diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/Current_Test.idl b/TAO/orbsvcs/tests/Transport_Current/Framework/Current_Test.idl index b53806bcda4..419be426991 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/Current_Test.idl +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/Current_Test.idl @@ -32,37 +32,3 @@ module TAO }; }; }; -// -*- IDL -*- - -//============================================================================= -/** - * @file test.idl - * - * $Id$ - * - * Simple IDL file to test TAO::TranspotCurrent - * support. - * - * @author Iliyan Jeliazkov - */ -//============================================================================= - -module TAO -{ - module Transport - { - interface CurrentTest - { - - const unsigned long ContextTag = 0xabcdef; - - void invoked_by_client (); - - void invoked_during_upcall (); - - long self_test (); - - oneway void shutdown (); - }; - }; -}; diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/Current_Test_Impl.cpp b/TAO/orbsvcs/tests/Transport_Current/Framework/Current_Test_Impl.cpp index ab9d7039073..8b44743f3df 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/Current_Test_Impl.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/Current_Test_Impl.cpp @@ -167,172 +167,3 @@ Current_Test_Impl::shutdown (ACE_ENV_SINGLE_ARG_DECL) this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); } -// -*- C++ -*- - -#include "orbsvcs/Transport_Current/TCC.h" - -#include "Current_Test_Impl.h" - -ACE_RCSID (Transport_Current, - Current_Test_Impl, - "$Id$") - - Current_Test_Impl::Current_Test_Impl (CORBA::ORB_ptr orb, - PortableServer::POA_ptr poa, - int do_collocated_calls) - : orb_ (CORBA::ORB::_duplicate (orb)) - , poa_ (PortableServer::POA::_duplicate (poa)) - , do_collocated_calls_ (do_collocated_calls) -{ -} - -Current_Test_Impl::~Current_Test_Impl (void) -{ -} - -::CORBA::Long -Current_Test_Impl::self_test (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((::CORBA::SystemException)) -{ - return 0; -} - -void -Current_Test_Impl::test_transport_current (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - if (TAO_debug_level > 2) { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) server - Testing access to Transport Current ...\n"))); - } - - CORBA::Object_var tcobject = - orb_->resolve_initial_references ("TAO::Transport::Current" - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - TAO::Transport::Current_var tc = - TAO::Transport::Current::_narrow (tcobject.in () - ACE_ENV_SINGLE_ARG_DECL); - ACE_TRY_CHECK; - - if (TAO_debug_level >= 1) - { - ::CORBA::Long id = tc->id (ACE_ENV_SINGLE_ARG_DECL); - ACE_TRY_CHECK; - - ::TAO::CounterT bs = tc->bytes_sent (ACE_ENV_SINGLE_ARG_DECL); - ACE_TRY_CHECK; - - ::TAO::CounterT br = tc->bytes_received (ACE_ENV_SINGLE_ARG_DECL); - ACE_TRY_CHECK; - - ::TAO::CounterT rs = tc->messages_sent (ACE_ENV_SINGLE_ARG_DECL); - ACE_TRY_CHECK; - - ::TAO::CounterT rr = tc->messages_received (ACE_ENV_SINGLE_ARG_DECL); - ACE_TRY_CHECK; - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Current_Test_Impl (%P|%t) Transport [%q] - Sent/Received [bytes=%q/%q, messages=%q/%q]\n"), - (ACE_UINT64)id, - (ACE_UINT64)bs, - (ACE_UINT64)br, - (ACE_UINT64)rs, - (ACE_UINT64)rr)); - } - - if (TAO_debug_level > 2) { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) server - Successfully accessed Transport Current\n"))); - } -} - -void -Current_Test_Impl::invoked_by_client (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - ACE_TRY - { - this->invoked_by_client_i (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCH (TAO::Transport::NoContext, ex) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) server - Caught a Transport::NoContext exception\n"))); - } - ACE_CATCH (CORBA::SystemException, ex1) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) server - Caught a CORBA::SystemException exception\n"))); - } - ACE_ENDTRY; -} - -void -Current_Test_Impl::invoked_by_client_i (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, TAO::Transport::NoContext)) -{ - if (TAO_debug_level > 2) { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) server - Testing inside an upcall\n"))); - } - - this->test_transport_current (ACE_ENV_SINGLE_ARG_DECL); - ACE_TRY_CHECK; - - if (this->do_collocated_calls_) - { - CORBA::Object_var selfobject = - poa_->servant_to_reference (this - ACE_ENV_SINGLE_ARG_DECL); - ACE_TRY_CHECK; - - TAO::Transport::CurrentTest_var self = - TAO::Transport::CurrentTest::_narrow (selfobject.in () - ACE_ENV_SINGLE_ARG_DECL); - ACE_TRY_CHECK; - - if (TAO_debug_level >= 1) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) server - Testing a collocated call\n"))); - } - self->invoked_during_upcall (ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - else - { - if (TAO_debug_level >= 1) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) server - Skipping the collocated call test\n"))); - } - } -} - -void -Current_Test_Impl::invoked_during_upcall (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - if (TAO_debug_level > 2) { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) server - Test method invoked ") - ACE_TEXT ("by the server during upcall.\n"))); - } - -} - -void -Current_Test_Impl::shutdown (ACE_ENV_SINGLE_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) -{ - if (TAO_debug_level > 2) { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("(%P|%t) server - shutting down.\n"))); - } - - this->orb_->shutdown (0 - ACE_ENV_ARG_PARAMETER); -} diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/Server_Main.cpp b/TAO/orbsvcs/tests/Transport_Current/Framework/Server_Main.cpp index 55a17b65719..21c1227fbf3 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/Server_Main.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/Server_Main.cpp @@ -21,26 +21,3 @@ ACE_TMAIN (int argc, Test::Server_Request_Interceptor cri ("test_orb", test_transport_current); return server_main (argc, argv, &cri); } -// -*- C++ -*- - -// $Id$ - -#include "Server_Request_Interceptor.h" - -/// Prototype -int server_main (int argc, - ACE_TCHAR *argv[], - Test::Server_Request_Interceptor *cri); - -int -test_transport_current (CORBA::ORB_ptr orb - ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, - CORBA::UserException)); - -int -ACE_TMAIN (int argc, - ACE_TCHAR *argv[]) -{ - Test::Server_Request_Interceptor cri ("test_orb", test_transport_current); - return server_main (argc, argv, &cri); -} diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/Server_Request_Interceptor.cpp b/TAO/orbsvcs/tests/Transport_Current/Framework/Server_Request_Interceptor.cpp index b10de1d4804..26062f02c97 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/Server_Request_Interceptor.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/Server_Request_Interceptor.cpp @@ -27,170 +27,6 @@ namespace Test { - Server_Request_Interceptor::Server_Request_Interceptor (const char* orbid, TEST test) - : request_count_ (0) - , orb_id_ (::CORBA::string_dup (orbid)) - , test_ (test) - { - } - - Server_Request_Interceptor::~Server_Request_Interceptor (void) - { - } - - void - Server_Request_Interceptor::test_transport_current (const ACE_TCHAR* amethod - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - CORBA::String_var name (this->name ()); - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%s (%P|%t) Test accessing Transport Current from %s\n"), - name.in (), - amethod)); - - ++this->request_count_; - - if (TAO_debug_level >=1) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%s (%P|%t) Getting the ORB\n"), - name.in ())); - - int tmpargc = 0; - CORBA::ORB_var orb = CORBA::ORB_init (tmpargc, - 0, - this->orb_id_.in () - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - if (TAO_debug_level >=1) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%s (%P|%t) Resolving the TC\n"), - name.in ())); - - CORBA::Object_var tcobject = - orb->resolve_initial_references ("TAO::Transport::Current" - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - (*this->test_) (orb.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%s (%P|%t) Success - Transport Current from %s\n"), - name.in (), - amethod)); - } - - /// queries the status of the test - bool - Server_Request_Interceptor::self_test () const - { - return true; - } - - - char * - Server_Request_Interceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - return CORBA::string_dup ("SRI "); - } - - void - Server_Request_Interceptor::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - } - - void - Server_Request_Interceptor::receive_request_service_contexts (PortableInterceptor::ServerRequestInfo_ptr - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - PortableInterceptor::ForwardRequest)) - { - test_transport_current ("receive_request_service_contexts" - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - } - - void - Server_Request_Interceptor::receive_request (PortableInterceptor::ServerRequestInfo_ptr - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - PortableInterceptor::ForwardRequest)) - { - test_transport_current ("receive_request" - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - } - - void - Server_Request_Interceptor::send_reply (PortableInterceptor::ServerRequestInfo_ptr - ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - test_transport_current ("send_reply" - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } - - void - Server_Request_Interceptor::send_exception (PortableInterceptor::ServerRequestInfo_ptr - ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException, - PortableInterceptor::ForwardRequest)) - { - test_transport_current ("send_exception" - ACE_ENV_ARG_PARAMETER); - - ACE_CHECK; - } - - void - Server_Request_Interceptor::send_other (PortableInterceptor::ServerRequestInfo_ptr - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - PortableInterceptor::ForwardRequest)) - { - test_transport_current ("send_other" - ACE_ENV_ARG_PARAMETER); - - ACE_CHECK; - } - -} /* namespace Test */ -// -*- C++ -*- - -#include "ace/Log_Msg.h" -//#include "ace/Global_Macros.h" -#include "tao/ORB_Constants.h" - - -ACE_RCSID (ForwardRequest, - Server_Request_Interceptor, - "$Id$") - -#include "Server_Request_Interceptor.h" - -namespace Test { - - using namespace TAO; - - // A specialization to handle server-side interceptors - template <> - void - ORBInitializer::post_init (PortableInterceptor::ORBInitInfo* oii - ACE_ENV_ARG_DECL_WITH_DEFAULTS) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - oii->add_server_request_interceptor (this->interceptor_.in ()); - } - - - Server_Request_Interceptor::Server_Request_Interceptor (const char* orbid, TEST test) : request_count_ (0) , orb_id_ (::CORBA::string_dup (orbid)) diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/Tester.cpp b/TAO/orbsvcs/tests/Transport_Current/Framework/Tester.cpp index 78cc2b73702..4b3b1ed632d 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/Tester.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/Tester.cpp @@ -5,76 +5,6 @@ using namespace TAO; -/// Test referencing the TC data outside of the context of an upcall, -/// or a client-side interceptor - -int -test_transport_current (Transport::Current_ptr tc - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - CORBA::UserException)) -{ - CORBA::Long id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - TAO::CounterT bs = tc->bytes_sent (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - TAO::CounterT br = tc->bytes_received (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - TAO::CounterT rs = tc->messages_sent (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - TAO::CounterT rr = tc->messages_received (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Tester (%P|%t) Transport [%q] - Sent/Received [bytes=%q/%q, messages=%q/%q]\n"), - (ACE_UINT64)id, - (ACE_UINT64)bs, - (ACE_UINT64)br, - (ACE_UINT64)rs, - (ACE_UINT64)rr)); - - return 0; -} - -int -test_transport_current (CORBA::ORB_ptr orb - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - CORBA::UserException)) -{ - // Get the Current object. - CORBA::Object_var tcobject = - orb->resolve_initial_references ("TAO::Transport::Current" - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - Transport::Current_var tc = - Transport::Current::_narrow (tcobject.in () - ACE_ENV_SINGLE_ARG_DECL); - ACE_TRY_CHECK; - - if (CORBA::is_nil (tc.in ())) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("(%P|%t) client - ERROR: Could not resolve ") - ACE_TEXT ("TAOTransportCurrent object.\n"))); - - ACE_TRY_THROW (CORBA::INTERNAL ()); - } - - return test_transport_current (tc.in ()); -} -// $Id$ - -#include "orbsvcs/Transport_Current/Transport_Current.h" - -using namespace TAO; - - /// Test referencing the TC data outside of the context of an upcall, /// or a client-side interceptor diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/client.cpp b/TAO/orbsvcs/tests/Transport_Current/Framework/client.cpp index da8eeeede14..3631e5f2562 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/client.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/client.cpp @@ -151,293 +151,6 @@ Worker::svc (void) } -/// The main driver -int -ACE_TMAIN (int argc, ACE_TCHAR *argv[]) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - Test::Client_Request_Interceptor cri (CLIENT_ORB_ID, test_transport_current); - - PortableInterceptor::ORBInitializer_ptr temp_initializer = - PortableInterceptor::ORBInitializer::_nil (); - - ACE_NEW_RETURN (temp_initializer, - Test::ORBInitializer (&cri), - -1); - - PortableInterceptor::ORBInitializer_var orb_initializer = - temp_initializer; - - PortableInterceptor::register_orb_initializer (orb_initializer.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - CORBA::ORB_var orb = - CORBA::ORB_init (argc, - argv, - CLIENT_ORB_ID - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (parse_args (argc, argv) != 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Client (%P|%t) Failure to parse the command line.\n"), - ior), - -1); - - - ACE_TRY - { - test_transport_current (orb.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Client (%P|%t) ERROR: ") - ACE_TEXT ("TC invocation, outside of ") - ACE_TEXT ("interceptor context is undefined.") - ACE_TEXT (" Expected exception was not thrown\n")), - -1); - } - ACE_CATCH (Transport::NoContext, ex) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Client (%P|%t) Expected exception occured when trying ") - ACE_TEXT ("to access traits outside the ") - ACE_TEXT ("interceptor or upcall context.\n"))); - } - ACE_ENDTRY; - - // Resolve the target object - CORBA::Object_var obj = orb->string_to_object (ior ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - Transport::CurrentTest_var server = - Transport::CurrentTest::_narrow (obj.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (server.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Client (%P|%t) The server object reference <%s> is nil.\n"), - ior), - -1); - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Client (%P|%t) Spawning %d threads\n"), nthreads)); - - // Spawn a number of clients doing the same thing for a - // predetermined number of times - Worker client (server.in (), niterations, use_dii); - if (client.activate (THR_NEW_LWP | THR_JOINABLE, - nthreads) != 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Client (%P|%t) Cannot activate the threads\n")), - -1); - client.thr_mgr ()->wait (); - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Client (%P|%t) Collected all threads\n"))); - - CORBA::Long result = 0; - - // Verify enough interception points have been triggered - if (cri.interceptions () != 2 * // request & response - niterations * // iterations - nthreads * // threads - (2*use_dii)) // sii and dii, if needed - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("Client (%P|%t) Expected %d client-side interceptions, but detected %d\n"), - 2 * niterations * nthreads * (2*use_dii), - cri.interceptions ())); - } - else - { - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Client (%P|%t) Invoking server->self_test()\n"))); - - // Self-test the server side - result = server->self_test (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (result != 0) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("Client (%P|%t) Server self-test reported failure\n"))); - } - - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Client (%P|%t) Invoking oneway server->shutdown()\n"))); - - server->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_DEBUG ((LM_INFO, - ACE_TEXT ("Client (%P|%t) Completed %s\n"), - ((result == 0) ? ACE_TEXT ("successfuly") : ACE_TEXT ("with failure")))); - return result; - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT ("Client: Transport Current test (client-side) failed:")); - return -1; - } - ACE_ENDTRY; -} -// -*- C++ -*- - -#include "ace/Get_Opt.h" -#include "ace/Task.h" - -#include "tao/DynamicInterface/Request.h" -#include "tao/ORBInitializer_Registry.h" - -#include "orbsvcs/Transport_Current/Transport_Current.h" - -#include "Client_Request_Interceptor.h" -#include "Current_TestC.h" - -#include "ORBInitializer_T.h" - -ACE_RCSID (PICurrent, - client, - "$Id$") - -// Prototype - -int -test_transport_current (CORBA::ORB_ptr - ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, - CORBA::UserException)); - -using namespace TAO; - -const ACE_TCHAR* CLIENT_ORB_ID = ACE_TEXT ("client orb"); -const ACE_TCHAR* ior = "file://server.ior"; - -int nthreads = 1; -int niterations = 1; -int use_dii = 1; - - -int -parse_args (int argc, ACE_TCHAR *argv[]) -{ - ACE_Get_Opt get_opts (argc, argv, "yt:n:k:"); - int c; - - while ((c = get_opts ()) != -1) - switch (c) - { - case 'y': - use_dii = 0; // Do not use DII - break; - case 'k': - ior = get_opts.opt_arg (); - break; - case 't': - nthreads = ACE_OS::atoi (get_opts.opt_arg ()); - break; - case 'n': - niterations = ACE_OS::atoi (get_opts.opt_arg ()); - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "Usage: %s " - "-k IOR " - "-t threads " - "-n iterations " - "-y " - "\n", - argv[0]), - -1); - } - return 0; -} - - -/// A helper class to encapsulate a task - -class Worker : public ACE_Task_Base -{ -public: - Worker (TAO::Transport::CurrentTest_ptr server, int niterations, int use_dii_too); - virtual int svc (void); - -private: - // The server. - TAO::Transport::CurrentTest_var server_; - - // The number of iterations on each client thread. - int niterations_; - - // Whether to use DII in addition to SII - int use_dii_too_; -}; - - -/// Ctor - -Worker::Worker (TAO::Transport::CurrentTest_ptr server, - int niterations, - int use_dii_too) - : server_ (TAO::Transport::CurrentTest::_duplicate (server)) - , niterations_ (niterations) - , use_dii_too_ (use_dii_too) -{ -} - - -/// Test referencing the TC data *inside* the context of a client-side -/// interceptor - -int -Worker::svc (void) -{ - ACE_TRY_NEW_ENV - { - - for (int i = 0; i < this->niterations_; ++i) - { - - if (this->use_dii_too_) - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Client (%P|%t) Invoking server->invoked_by_client() via DII\n"))); - - CORBA::Request_var request = - this->server_->_request ("invoked_by_client" - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - request->set_return_type (CORBA::_tc_void); - - request->invoke (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_CHECK; - } - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Client (%P|%t) Invoking server->invoked_by_client() via SII\n"))); - - this->server_->invoked_by_client (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (TAO_debug_level > 0 && i % 100 == 0) - ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Client (%P|%t) Iteration = %d\n"), - i)); - } - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Client: exception raised"); - } - ACE_ENDTRY; - return 0; -} - - /// The main driver int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) diff --git a/TAO/orbsvcs/tests/Transport_Current/Framework/server.cpp b/TAO/orbsvcs/tests/Transport_Current/Framework/server.cpp index 7421465160a..93bfcae4ac0 100644 --- a/TAO/orbsvcs/tests/Transport_Current/Framework/server.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/Framework/server.cpp @@ -108,246 +108,6 @@ Worker::svc (void) -/// Main driver - -int -server_main (int argc, - ACE_TCHAR *argv[], - Test::Server_Request_Interceptor *cri) -{ - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - PortableInterceptor::ORBInitializer_ptr temp_initializer = - PortableInterceptor::ORBInitializer::_nil (); - - ACE_NEW_RETURN (temp_initializer, - Test::ORBInitializer (cri), - -1); // No exceptions yet! - - PortableInterceptor::ORBInitializer_var orb_initializer = - temp_initializer; - - PortableInterceptor::register_orb_initializer (orb_initializer.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - - CORBA::ORB_var orb = CORBA::ORB_init (argc, - argv, - ACE_TEXT ("test_orb") - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - CORBA::Object_var obj = - orb->resolve_initial_references ("RootPOA" - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - PortableServer::POA_var root_poa = - PortableServer::POA::_narrow (obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (root_poa.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Server (%P|%t) Unable to obtain") - ACE_TEXT (" RootPOA reference.\n")), - -1); - - PortableServer::POAManager_var poa_manager = - root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (parse_args (argc, argv) != 0) - return -1; - - Current_Test_Impl server_impl (orb.in (), - root_poa.in (), - use_collocated_call); - - obj = server_impl._this (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - TAO::Transport::CurrentTest_var server = - TAO::Transport::CurrentTest::_narrow (obj.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - if (CORBA::is_nil (server.in ())) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Server (%P|%t) Unable to obtain ") - ACE_TEXT ("reference to CurrentTest object.\n")), - -1); - - CORBA::String_var ior = - orb->object_to_string (server.in () ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // If the ior_output_file exists, output the IOR to it. - if (ior_output_file != 0) - { - FILE *output_file = ACE_OS::fopen (ior_output_file, "w"); - if (output_file == 0) - ACE_ERROR_RETURN ((LM_ERROR, - "Server (%P|%t) Cannot write " - "IOR: %s - %m", - ior_output_file), - -1); - ACE_OS::fprintf (output_file, "%s", ior.in ()); - ACE_OS::fclose (output_file); - } - - // Spawn a number of clients doing the same thing for a - // predetermined number of times - Worker worker (orb.in ()); - if (worker.activate (THR_NEW_LWP | THR_JOINABLE, - nthreads) != 0) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("Server (%P|%t) Cannot activate %d server threads\n"), - nthreads), - -1); - worker.thr_mgr ()->wait (); - - if (TAO_debug_level >= 1) - ACE_DEBUG ((LM_INFO, ACE_TEXT ("Server (%P|%t) Event loop finished.\n"))); - - if (!cri->self_test ()) - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("Server (%P|%t) Interceptor self_test failed\n"))); - - server->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - ACE_TEXT ("Server (%P|%t) ERROR: ")); - - return -1; - } - ACE_ENDTRY; - - ACE_DEBUG ((LM_INFO, ACE_TEXT ("Server (%P|%t) Completed successfuly.\n"))); - return 0; -} -// -*- C++ -*- - -#include "ace/Get_Opt.h" -#include "ace/OS_NS_stdio.h" -#include "ace/Task.h" - -#include "tao/ORBInitializer_Registry.h" - -#include "Current_Test_Impl.h" -#include "Server_Request_Interceptor.h" - -ACE_RCSID (Transport_Current, - server, - "$Id$") - -#if defined (TAO_AS_STATIC_LIBS) - -// Create an object that will insert the into the -// list of statically linked services that the -// will initialize at run-time. -#include "orbsvcs/Transport_Current/Current_Loader.h" -ACE_STATIC_SVC_REQUIRE (TAO_Transport_Current_Loader); -#endif - -const char *ior_output_file = "server.ior"; -int nthreads = 1; -int use_collocated_call = 1; - -int -parse_args (int argc, char *argv[]) -{ - ACE_Get_Opt get_opts (argc, argv, "t:o:n:c:"); - int c; - - while ((c = get_opts ()) != -1) - switch (c) - { - case 'c': - use_collocated_call = ACE_OS::atoi (get_opts.opt_arg ()); - break; - case 'o': - ior_output_file = get_opts.opt_arg (); - break; - case 't': - nthreads = ACE_OS::atoi (get_opts.opt_arg ()); - break; - case 'n': // Does nothing. Added just for symetry with the client. - break; - default: - ACE_ERROR_RETURN ((LM_ERROR, - "Usage: %s " - "-o " - "-t threads " - "-n n (ignored, if provided) " - "-c make_collocated_calls " - "\n", - argv[0]), - -1); - } - - // Indicates sucessful parsing of the command line - return 0; -} - - - -/// A helper class to encapsulate a task - -class Worker : public ACE_Task_Base -{ -public: - Worker (CORBA::ORB_ptr); - virtual int svc (void); - -private: - // The ORB - CORBA::ORB_var orb_; -}; - - -/// Ctor - -Worker::Worker (CORBA::ORB_ptr orb) - : orb_ (CORBA::ORB::_duplicate (orb)) -{ -} - - -/// Test referencing the TC data *inside* the context of a client-side -/// interceptor - -int -Worker::svc (void) -{ - ACE_TRY_NEW_ENV - { - this->orb_->run (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "Server: exception raised"); - } - ACE_ENDTRY; - return 0; -} - - - /// Main driver int diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Main.cpp b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Main.cpp index 3bd1b2bb12e..cce444d8662 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Main.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Main.cpp @@ -21,26 +21,3 @@ ACE_TMAIN (int argc, Test::IIOP_Server_Request_Interceptor cri ("test_orb", test_transport_current); return server_main (argc, argv, &cri); } -// -*- C++ -*- - -// $Id$ - -#include "IIOP_Server_Request_Interceptor.h" - -/// Prototype -int server_main (int argc, - ACE_TCHAR *argv[], - Test::Server_Request_Interceptor *cri); - -int -test_transport_current (CORBA::ORB_ptr orb - ACE_ENV_ARG_DECL) ACE_THROW_SPEC ((CORBA::SystemException, - CORBA::UserException)); - -int -ACE_TMAIN (int argc, - ACE_TCHAR *argv[]) -{ - Test::IIOP_Server_Request_Interceptor cri ("test_orb", test_transport_current); - return server_main (argc, argv, &cri); -} diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.cpp b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.cpp index bbc77e6b8f0..92950ce0b7f 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Server_Request_Interceptor.cpp @@ -214,329 +214,6 @@ namespace Test { - void - IIOP_Server_Request_Interceptor::receive_request_service_contexts (PortableInterceptor::ServerRequestInfo_ptr ri - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - PortableInterceptor::ForwardRequest)) - { - ACE_TRY - { - inbound_process_context (ri ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - CORBA::String_var name (this->name ()); - ACE_ERROR ((LM_ERROR, - ACE_TEXT("%s (%P|%t) Inbound_process_context failed in ") - ACE_TEXT(" receive_request_service_contexts.\n"), - name.in ())); - } - ACE_ENDTRY; - - Server_Request_Interceptor::receive_request_service_contexts (ri ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - } - - - void - IIOP_Server_Request_Interceptor::send_reply (PortableInterceptor::ServerRequestInfo_ptr ri - ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - ACE_TRY - { - outbound_process_context (ri ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - } - ACE_CATCHANY - { - CORBA::String_var name (this->name ()); - ACE_ERROR ((LM_ERROR, - ACE_TEXT("%s (%P|%t) Outbound_process_context failed in ") - ACE_TEXT("send_reply.\n"), - name.in ())); - } - ACE_ENDTRY; - - Server_Request_Interceptor::send_reply (ri ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - } - - void - IIOP_Server_Request_Interceptor::send_exception (PortableInterceptor::ServerRequestInfo_ptr ri - ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException, - PortableInterceptor::ForwardRequest)) - { - ACE_TRY - { - outbound_process_context (ri ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - - } - ACE_CATCHANY - { - CORBA::String_var name (this->name ()); - ACE_ERROR ((LM_ERROR, - ACE_TEXT("%s (%P|%t) Outbound_process_context failed in ") - ACE_TEXT("send_exception.\n"), - name.in ())); - - } - ACE_ENDTRY; - - Server_Request_Interceptor::send_exception (ri ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } - - void - IIOP_Server_Request_Interceptor::send_other (PortableInterceptor::ServerRequestInfo_ptr ri - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - PortableInterceptor::ForwardRequest)) - { - ACE_TRY - { - outbound_process_context (ri ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCHANY - { - CORBA::String_var name (this->name ()); - ACE_ERROR ((LM_ERROR, - ACE_TEXT("%s (%P|%t) Outbound_process_context failed in ") - ACE_TEXT("send_other.\n"), - name.in ())); - } - ACE_ENDTRY; - - Server_Request_Interceptor::send_other (ri ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - } - -} -// -*- C++ -*- - -#include "ace/Log_Msg.h" -#include "tao/ORB_Constants.h" -#include "orbsvcs/Transport_Current/TC_IIOPC.h" - -ACE_RCSID (ForwardRequest, - Server_Request_Interceptor, - "$Id$") - -#include "IIOP_Server_Request_Interceptor.h" - -namespace Test { - - using namespace TAO; - - IIOP_Server_Request_Interceptor::IIOP_Server_Request_Interceptor (const char* orbid, TEST test) - : Server_Request_Interceptor (orbid, test) - , iiop_test_successful_ (true) - , mult_thr_test_successful_ (true) - { - } - - IIOP_Server_Request_Interceptor::~IIOP_Server_Request_Interceptor (void) - { - } - - char * - IIOP_Server_Request_Interceptor::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - return CORBA::string_dup ("II SRI"); - } - - /// - TAO::Transport::IIOP::Current_ptr - IIOP_Server_Request_Interceptor::resolve_iiop_transport_current (const char* orbid - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - CORBA::String_var name (this->name ()); - - int tmpargc = 0; - CORBA::ORB_var orb = CORBA::ORB_init (tmpargc, - 0, - orbid - ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - CORBA::Object_var tcobject = - orb->resolve_initial_references (ACE_TEXT_ALWAYS_CHAR ("TAO::Transport::IIOP::Current") - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - return TAO::Transport::IIOP::Current::_narrow (tcobject.in () - ACE_ENV_ARG_PARAMETER); - } - - /// On every request, a client-supplied (via the context) id is used - /// as index in an array, where we store the endpoint - void - IIOP_Server_Request_Interceptor::push_request_info (size_t requestID - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - CORBA::String_var name (this->name ()); - - TAO::Transport::IIOP::Current_var tc = - resolve_iiop_transport_current (this->orb_id_.in () - ACE_ENV_ARG_PARAMETER); - - CORBA::String_var host (tc->remote_host()); - EndPoint ep (tc->remote_port(), host.in ()); - - if (requestID < sizeof (endPoints_)) - endPoints_[requestID] = ep; - else - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%s (%P|%t) ") - ACE_TEXT ("push_request_info: Can't track that many requests %d\n"), - name.in (), - requestID)); - - } - - void - IIOP_Server_Request_Interceptor::pop_request_info (size_t requestID) - { - static EndPoint dummy; - CORBA::String_var name (this->name ()); - - if (requestID >= sizeof (endPoints_)) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%s (%P|%t) ") - ACE_TEXT ("pop_request_info: Can't track that many requests %d\n"), - name.in (), - requestID)); - return; - } - - TAO::Transport::IIOP::Current_var tc = - resolve_iiop_transport_current (this->orb_id_.in () - ACE_ENV_ARG_PARAMETER); - - CORBA::String_var host (tc->remote_host()); - EndPoint ep (tc->remote_port(), host.in ()); - - if (ep != endPoints_[requestID]) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%s (%P|%t) ") - ACE_TEXT ("pop_request_info: The expected host and port don't match for request %d\n"), - name.in (), - requestID)); - return; - } - - endPoints_[requestID] = dummy; - } - - - /// Checks if all the endpoints, encountered on the way in have been - /// cleaned on the way out of the interception point - bool - IIOP_Server_Request_Interceptor::self_test (void) - { - CORBA::String_var name (this->name ()); - bool has_remaining_endpoints = false; - for (size_t count = 0; - count < sizeof (endPoints_); - count ++) - { - if (endPoints_[count].port_ != 0) - { - has_remaining_endpoints = true; - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("%s (%S|%t) Endpoint at ") - ACE_TEXT ("index=%d is not been removed yet\n"), - name.in ())); - } - } - - return Server_Request_Interceptor::self_test () - && iiop_test_successful_ - && !has_remaining_endpoints; - } - - - - void - IIOP_Server_Request_Interceptor::inbound_process_context (PortableInterceptor::ServerRequestInfo_ptr ri - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - CORBA::String_var name (this->name ()); - CORBA::String_var op (ri->operation(ACE_ENV_ARG_PARAMETER)); - ACE_CHECK; - - if (TAO_debug_level >=1) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT("%s (%P|%t) Intercepted operation %s ()\n"), - name.in (), - op.in ())); - - ACE_TRY - { - IOP::ServiceId id = Transport::CurrentTest::ContextTag; - IOP::ServiceContext_var sc = - ri->get_request_service_context (id - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - const char *buf = - ACE_reinterpret_cast (const char *, sc->context_data.get_buffer ()); - - long requestID = ACE_OS::atoi (buf); - - this->push_request_info (requestID); - } - ACE_CATCHANY - { - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("%s (%P|%t) Service context") - ACE_TEXT (" is unavailable when invoking %s (). ") - ACE_TEXT ("A colocated invocation would have ") - ACE_TEXT ("no service context.\n"), - name.in (), - op.in ())); - } - ACE_ENDTRY; - - } - - void - IIOP_Server_Request_Interceptor::outbound_process_context (PortableInterceptor::ServerRequestInfo_ptr ri - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - IOP::ServiceId id = Transport::CurrentTest::ContextTag; - - IOP::ServiceContext_var sc = - ri->get_request_service_context (id ACE_ENV_ARG_PARAMETER); - ACE_CHECK; - - const char *buf = - ACE_reinterpret_cast (const char *, sc->context_data.get_buffer ()); - - this->pop_request_info (ACE_OS::atoi (buf)); - } - - - - - - void IIOP_Server_Request_Interceptor::receive_request_service_contexts (PortableInterceptor::ServerRequestInfo_ptr ri ACE_ENV_ARG_DECL) diff --git a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Tester.cpp b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Tester.cpp index ec76e46eee5..2b87ba0e285 100644 --- a/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Tester.cpp +++ b/TAO/orbsvcs/tests/Transport_Current/IIOP/IIOP_Tester.cpp @@ -79,84 +79,3 @@ test_transport_current (CORBA::ORB_ptr orb return 0; } -// -*- C++ -*- - -// $Id$ - -#include "orbsvcs/Transport_Current/IIOP_Transport_Current.h" - -using namespace TAO; - - -/// Test referencing the TC data outside of the context of an upcall, -/// or a client-side interceptor - -int -test_transport_current (CORBA::ORB_ptr orb - ACE_ENV_ARG_DECL) - ACE_THROW_SPEC ((CORBA::SystemException, - CORBA::UserException)) -{ - // Get the Current object. - CORBA::Object_var tcobject = - orb->resolve_initial_references (ACE_TEXT_ALWAYS_CHAR ("TAO::Transport::IIOP::Current") - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - - if (TAO_debug_level >= 1) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Tester (%P|%t) Resolved initial reference for IIOP::Current\n"))); - - Transport::IIOP::Current_var tc = - Transport::IIOP::Current::_narrow (tcobject.in () - ACE_ENV_SINGLE_ARG_DECL); - ACE_TRY_CHECK; - - if (TAO_debug_level >= 1) - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Tester (%P|%t) Narowed the IIOP Transport Current\n"))); - - if (CORBA::is_nil (tc.in ())) - { - ACE_ERROR ((LM_ERROR, - ACE_TEXT ("Tester (%P|%t) ERROR: Could not resolve ") - ACE_TEXT ("TAO::Transport::IIOP::Current object.\n"))); - - ACE_TRY_THROW (CORBA::INTERNAL ()); - } - - ::CORBA::String_var rhost (tc->remote_host (ACE_ENV_SINGLE_ARG_PARAMETER)); - ACE_TRY_CHECK; - - ::CORBA::String_var lhost (tc->local_host (ACE_ENV_SINGLE_ARG_PARAMETER)); - ACE_TRY_CHECK; - - ::CORBA::Long id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - ::TAO::CounterT bs = tc->bytes_sent (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - ::TAO::CounterT br = tc->bytes_received (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - ::TAO::CounterT rs = tc->messages_sent (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - ::TAO::CounterT rr = tc->messages_received (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_DEBUG ((LM_DEBUG, - ACE_TEXT ("Tester (%P|%t) Transport [%q] [%s:%d -> %s:%d] ") - ACE_TEXT ("Sent/Received [bytes=%q/%q, messages=%q/%q]\n"), - (ACE_UINT64)id, - rhost.in (), tc->remote_port (ACE_ENV_SINGLE_ARG_PARAMETER), - lhost.in (), tc->local_port (ACE_ENV_SINGLE_ARG_PARAMETER), - (ACE_UINT64)bs, - (ACE_UINT64)br, - (ACE_UINT64)rs, - (ACE_UINT64)rr)); - return 0; -} - -- cgit v1.2.1