diff options
author | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
---|---|---|
committer | William R. Otte <wotte@dre.vanderbilt.edu> | 2006-07-24 15:50:21 +0000 |
commit | 3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c (patch) | |
tree | 197c810e5f5bce17b1233a7cb8d7b50c0bcd25e2 /TAO/orbsvcs/tests/Bug_2287_Regression | |
parent | 6b846cf03c0bcbd8c276cb0af61a181e5f98eaae (diff) | |
download | ATCD-3aff90f4a822fcf5d902bbfbcc9fa931d6191a8c.tar.gz |
Repo restructuring
Diffstat (limited to 'TAO/orbsvcs/tests/Bug_2287_Regression')
13 files changed, 1104 insertions, 0 deletions
diff --git a/TAO/orbsvcs/tests/Bug_2287_Regression/Bug_2287_Regression.mpc b/TAO/orbsvcs/tests/Bug_2287_Regression/Bug_2287_Regression.mpc new file mode 100644 index 00000000000..4138843a913 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2287_Regression/Bug_2287_Regression.mpc @@ -0,0 +1,39 @@ +// -*- MPC -*- +// $Id$ + +project(*IDL): taoidldefaults { + IDL_Files { + Test.idl + } + custom_only = 1 +} + +project(*Client): taoserver, ftclientorb { + after += *IDL + + exename = client + Source_Files { + client.cpp + Hello.cpp + TestS.cpp + TestC.cpp + } + IDL_Files { + } +} + +project (*Server) : taoserver, ftclientorb, pi_server { + after += *IDL + + exename = server + Source_Files { + server.cpp + Hello.cpp + ServerORBInitializer2.cpp + ServerRequest_Interceptor2.cpp + TestS.cpp + TestC.cpp + } + IDL_Files { + } +} diff --git a/TAO/orbsvcs/tests/Bug_2287_Regression/Hello.cpp b/TAO/orbsvcs/tests/Bug_2287_Regression/Hello.cpp new file mode 100644 index 00000000000..995e0eeed0d --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2287_Regression/Hello.cpp @@ -0,0 +1,32 @@ +// +// $Id$ +// +#include "Hello.h" + +ACE_RCSID(Hello, Hello, "$Id$") + +Hello::Hello (CORBA::ORB_ptr orb, Test::Hello_ptr, CORBA::ULong) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +void +Hello::shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->orb_->shutdown (0 ACE_ENV_ARG_PARAMETER); +} + +void +Hello::ping (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return; +} + +void +Hello::throw_location_forward (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return; +} diff --git a/TAO/orbsvcs/tests/Bug_2287_Regression/Hello.h b/TAO/orbsvcs/tests/Bug_2287_Regression/Hello.h new file mode 100644 index 00000000000..c1d688daa82 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2287_Regression/Hello.h @@ -0,0 +1,45 @@ +// +// $Id$ +// + +#ifndef HELLO_H +#define HELLO_H +#include /**/ "ace/pre.h" + +#include "TestS.h" + +#if defined (_MSC_VER) +# pragma warning(push) +# pragma warning (disable:4250) +#endif /* _MSC_VER */ + +/// Implement the Test::Hello interface +class Hello + : public virtual POA_Test::Hello +{ +public: + /// Constructor + Hello (CORBA::ORB_ptr orb, Test::Hello_ptr server, CORBA::ULong server_id = 0); + + // = The skeleton methods + virtual void shutdown (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void ping (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void throw_location_forward (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + /// Use an ORB reference to conver strings to objects and shutdown + /// the application. + CORBA::ORB_var orb_; +}; + +#if defined(_MSC_VER) +# pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /* HELLO_H */ diff --git a/TAO/orbsvcs/tests/Bug_2287_Regression/Makefile.am b/TAO/orbsvcs/tests/Bug_2287_Regression/Makefile.am new file mode 100644 index 00000000000..4e41c8eec08 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2287_Regression/Makefile.am @@ -0,0 +1,153 @@ +## Process this file with automake to create Makefile.in +## +## $Id$ +## +## This file was generated by MPC. Any changes made directly to +## this file will be lost the next time it is generated. +## +## MPC Command: +## ../bin/mwc.pl -type automake -noreldefs TAO.mwc + +ACE_BUILDDIR = $(top_builddir)/.. +ACE_ROOT = $(top_srcdir)/.. +TAO_BUILDDIR = $(top_builddir) +TAO_IDL = ACE_ROOT=$(ACE_ROOT) TAO_ROOT=$(TAO_ROOT) $(TAO_BUILDDIR)/TAO_IDL/tao_idl +TAO_IDL_DEP = $(TAO_BUILDDIR)/TAO_IDL/tao_idl +TAO_IDLFLAGS = -Ge 1 -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -I$(srcdir) -g $(ACE_BUILDDIR)/apps/gperf/src/gperf +TAO_ROOT = $(top_srcdir) + +noinst_PROGRAMS = + +## Makefile.Bug_2287_Regression_IDL.am + +BUILT_SOURCES = \ + TestC.cpp \ + TestC.h \ + TestC.inl \ + TestS.cpp \ + TestS.h \ + TestS.inl + +CLEANFILES = \ + Test-stamp \ + TestC.cpp \ + TestC.h \ + TestC.inl \ + TestS.cpp \ + TestS.h \ + TestS.inl + +TestC.cpp TestC.h TestC.inl TestS.cpp TestS.h TestS.inl: Test-stamp + +Test-stamp: $(srcdir)/Test.idl $(TAO_IDL_DEP) + $(TAO_IDL) $(TAO_IDLFLAGS) -Sa -St $(srcdir)/Test.idl + @touch $@ + + +noinst_HEADERS = \ + Test.idl + +## Makefile.Bug_2287_Regression_Client.am + +if BUILD_ACE_UUID +if BUILD_CORBA_MESSAGING +if BUILD_INTERCEPTORS +if !BUILD_ACE_FOR_TAO +if !BUILD_MINIMUM_CORBA + +noinst_PROGRAMS += client + +client_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) \ + -I$(TAO_ROOT)/orbsvcs \ + -I$(TAO_BUILDDIR)/orbsvcs + +client_SOURCES = \ + Hello.cpp \ + TestC.cpp \ + TestS.cpp \ + client.cpp \ + Hello.h + +client_LDADD = \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_FT_ClientORB.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_FTORB_Utils.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_PortableGroup.la \ + $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \ + $(TAO_BUILDDIR)/tao/libTAO_PI.la \ + $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ + $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ + $(TAO_BUILDDIR)/tao/libTAO_IORManip.la \ + $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif !BUILD_MINIMUM_CORBA +endif !BUILD_ACE_FOR_TAO +endif BUILD_INTERCEPTORS +endif BUILD_CORBA_MESSAGING +endif BUILD_ACE_UUID + +## Makefile.Bug_2287_Regression_Server.am + +if BUILD_ACE_UUID +if BUILD_CORBA_MESSAGING +if BUILD_INTERCEPTORS +if !BUILD_ACE_FOR_TAO +if !BUILD_MINIMUM_CORBA + +noinst_PROGRAMS += server + +server_CPPFLAGS = \ + -I$(ACE_ROOT) \ + -I$(ACE_BUILDDIR) \ + -I$(TAO_ROOT) \ + -I$(TAO_BUILDDIR) \ + -I$(TAO_ROOT)/orbsvcs \ + -I$(TAO_BUILDDIR)/orbsvcs + +server_SOURCES = \ + Hello.cpp \ + ServerORBInitializer2.cpp \ + ServerRequest_Interceptor2.cpp \ + TestC.cpp \ + TestS.cpp \ + server.cpp \ + Hello.h \ + ServerORBInitializer2.h \ + ServerRequest_Interceptor2.h + +server_LDADD = \ + $(TAO_BUILDDIR)/tao/libTAO_PI_Server.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_FT_ClientORB.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_FTORB_Utils.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_PortableGroup.la \ + $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \ + $(TAO_BUILDDIR)/tao/libTAO_PI.la \ + $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \ + $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \ + $(TAO_BUILDDIR)/orbsvcs/orbsvcs/libTAO_CosNaming.la \ + $(TAO_BUILDDIR)/tao/libTAO_IORManip.la \ + $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \ + $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \ + $(TAO_BUILDDIR)/tao/libTAO.la \ + $(ACE_BUILDDIR)/ace/libACE.la + +endif !BUILD_MINIMUM_CORBA +endif !BUILD_ACE_FOR_TAO +endif BUILD_INTERCEPTORS +endif BUILD_CORBA_MESSAGING +endif BUILD_ACE_UUID + +## Clean up template repositories, etc. +clean-local: + -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.* + -rm -f gcctemp.c gcctemp so_locations *.ics + -rm -rf cxx_repository ptrepository ti_files + -rm -rf templateregistry ir.out + -rm -rf ptrepository SunWS_cache Templates.DB diff --git a/TAO/orbsvcs/tests/Bug_2287_Regression/README b/TAO/orbsvcs/tests/Bug_2287_Regression/README new file mode 100644 index 00000000000..3c77b3edb08 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2287_Regression/README @@ -0,0 +1,32 @@ +// $Id$ + +This test provides regression coverage for bugzilla #2287. + +See http://deuce.doc.wustl.edu/bugzilla/show_bug.cgi?id=2287 for more. + +The server installs a server request interceptor and persistent servant and writes out an IOGR for itself. +The client installs client side FT support and invokes the method "throw_location_forward" on the IOGR. +The server request interceptor detects invocations of this method and in response either: +a/ Throws a location forward back to the original IOGR if cannot determine (from the expiration_time member of the FT request service context) thatthe client must have despatched the request after the expiration time. +b/ Allows the request to be completed if it can determine absolutely that the request was despatched after the expiration time. This indicates a regression to the client. + +A successful outcome is if the client stops following the location forwards once it detects that the expiration time has passed, and a TRANSIENT system exception is recived in the application code. + +__Regression Output__ + +The expiration time has now passed !! +Expiration time : 133496335605156250 +Time now : 133496335605312500 +Test Failed - REGRESSION !!! Client ORB is still retrying LOCATION_FORWARDs after the expiration time!! +Expiration time : 133496335605156250 +Time now : 133496335605312500 +REGRESSION - Test has failed !!! +(3128|3992) server - event loop finished +Error: REGRESSION identified!!! +ERROR: client returned 1 + +__Successful Output__ + +Client catches a TRANSIENT, as expected. No problem ! +(3528|3532) server - event loop finished +Test passed !!! diff --git a/TAO/orbsvcs/tests/Bug_2287_Regression/ServerORBInitializer2.cpp b/TAO/orbsvcs/tests/Bug_2287_Regression/ServerORBInitializer2.cpp new file mode 100644 index 00000000000..f7a7b408be7 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2287_Regression/ServerORBInitializer2.cpp @@ -0,0 +1,52 @@ +// -*- C++ -*- +// +// $Id$ + +#include "ServerORBInitializer2.h" +#include "ServerRequest_Interceptor2.h" +#include "tao/ORB_Constants.h" +#include "tao/Exception.h" + + +void +Server_ORBInitializer2::pre_init ( + PortableInterceptor::ORBInitInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + +} + +void +Server_ORBInitializer2::post_init ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + this->register_server_request_interceptors (info + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +Server_ORBInitializer2::register_server_request_interceptors ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)) +{ + PortableInterceptor::ServerRequestInterceptor_ptr sri = + PortableInterceptor::ServerRequestInterceptor::_nil (); + + ACE_NEW_THROW_EX (sri, + TAO249_ServerRequest_Interceptor2, + CORBA::NO_MEMORY ()); + + PortableInterceptor::ServerRequestInterceptor_var + server_interceptor = sri; + + info->add_server_request_interceptor (server_interceptor.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + + diff --git a/TAO/orbsvcs/tests/Bug_2287_Regression/ServerORBInitializer2.h b/TAO/orbsvcs/tests/Bug_2287_Regression/ServerORBInitializer2.h new file mode 100644 index 00000000000..a98a94523be --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2287_Regression/ServerORBInitializer2.h @@ -0,0 +1,51 @@ +// -*- C++ -*- + +//============================================================================= +/** + * $Id$ + */ +//============================================================================= +#ifndef TAO249_SERVER_ORBINITIALIZER2_H +#define TAO249_SERVER_ORBINITIALIZER2_H + +#include /**/ "ace/pre.h" + +#include "tao/PortableInterceptorC.h" +#include "tao/PI_Server/PI_Server_includeC.h" +#include "tao/PI/PI.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/LocalObject.h" + +/// RTCORBA ORB initializer. +class Server_ORBInitializer2 : + public virtual PortableInterceptor::ORBInitializer, + public virtual TAO_Local_RefCounted_Object +{ +public: + + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL_WITH_DEFAULTS) + ACE_THROW_SPEC ((CORBA::SystemException)); + +private: + + /// Register the necessary interceptors. + void register_server_request_interceptors ( + PortableInterceptor::ORBInitInfo_ptr info + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + +}; + +#include /**/ "ace/post.h" + +#endif /* TAO249_SERVER_ORBINITIALIZER2_H */ + diff --git a/TAO/orbsvcs/tests/Bug_2287_Regression/ServerRequest_Interceptor2.cpp b/TAO/orbsvcs/tests/Bug_2287_Regression/ServerRequest_Interceptor2.cpp new file mode 100644 index 00000000000..226898bcf40 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2287_Regression/ServerRequest_Interceptor2.cpp @@ -0,0 +1,176 @@ +// -*- C++ -*- + +#include "ServerRequest_Interceptor2.h" +#include "orbsvcs/FT_CORBA_ORBC.h" +#include "tao/IOP_IORC.h" +#include "tao/ORB_Constants.h" +#include "tao/AnyTypeCode/DynamicC.h" +#include "tao/AnyTypeCode/TypeCode.h" +#include "tao/CDR.h" +#include "ace/Log_Msg.h" +#include "ace/OS_NS_string.h" +#include "ace/OS_NS_stdio.h" +#include "ace/OS_NS_unistd.h" +#include "Hello.h" +#include "ace/OS_NS_sys_time.h" +#include "tao/PI/PIForwardRequestC.h" + +ACE_RCSID (FaultTolerance, + TAO249_ServerRequest_Interceptor2, + "$Id$") + +CORBA::Object_var +TAO249_ServerRequest_Interceptor2::server_iogr_ = CORBA::Object::_nil (); + +TAO249_ServerRequest_Interceptor2::TAO249_ServerRequest_Interceptor2 (void) +: orb_ (0), + expired_ (0) +{ +} + +TAO249_ServerRequest_Interceptor2::~TAO249_ServerRequest_Interceptor2 (void) +{ +} + +char * +TAO249_ServerRequest_Interceptor2::name (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +ACE_THROW_SPEC ((CORBA::SystemException)) +{ + return CORBA::string_dup ("TAO_TAO249_ServerRequest_Interceptor2"); +} + +void +TAO249_ServerRequest_Interceptor2::destroy (ACE_ENV_SINGLE_ARG_DECL_NOT_USED) +ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +TAO249_ServerRequest_Interceptor2::receive_request_service_contexts ( + PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL) +ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ +} + +void +TAO249_ServerRequest_Interceptor2::receive_request ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL_NOT_USED) +ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ + CORBA::String_var op = ri->operation (ACE_ENV_SINGLE_ARG_PARAMETER); + + if (ACE_OS::strcmp (op.in (), "throw_location_forward")) + { + // bail if not the op we are interested in - + // avoid excess spurious error clutter when client calls ::shutdown + return; + } + + + IOP::ServiceContext_var sc = + ri->get_request_service_context (IOP::FT_REQUEST + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + TAO_InputCDR cdr (reinterpret_cast <const char*> + (sc->context_data.get_buffer () + ), + sc->context_data.length ()); + + CORBA::Boolean byte_order; + + if ((cdr >> ACE_InputCDR::to_boolean (byte_order)) == 0) + { + ACE_THROW (CORBA::BAD_PARAM (CORBA::OMGVMCID | 28, + CORBA::COMPLETED_NO)); + } + ACE_CHECK; + + cdr.reset_byte_order (static_cast <int>(byte_order)); + + FT::FTRequestServiceContext ftrsc; + + if ((cdr >> ftrsc) == 0) + ACE_THROW (CORBA::BAD_PARAM (CORBA::OMGVMCID | 28, + CORBA::COMPLETED_NO)); + ACE_CHECK; + + TimeBase::TimeT now = get_now (); + + if (now > ftrsc.expiration_time) + { + // We have passed the exp time... there should be no more retries received after this point... + if (expired_) + { + // The client has retried after the expiration time. This is a regression + ACE_DEBUG ((LM_ERROR, "Test Failed - REGRESSION !!! Client ORB is still retrying LOCATION_FORWARDs after the expiration time!!\n")); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("Expiration time : %Q\n"), ftrsc.expiration_time)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("Time now : %Q\n"), now)); + + // Let the request 'succeed' rather than throwing a forward exception. + return; + } + else + { + // A request has been recioved after the expiration time. + // This could legitimately happen - it is only definitely a problem if + // the client keeps on retrying after now. We set a flag so we can check for this. + expired_ = 1; + ACE_DEBUG ((LM_DEBUG, "The expiration time has now passed !!\n")); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("Expiration time : %Q\n"), ftrsc.expiration_time)); + ACE_DEBUG ((LM_DEBUG, ACE_TEXT("Time now : %Q\n"), now)); + } + } + + // Let's forward the client back to us again. I would like to be able to make this a PERM + // but there's no such animal in the PortableInterceptor module. Plus as we (currently) transform + // and marshal *all* forward requests as vanilla LOCATION_FORWARD it doesn't really matter. + ACE_THROW (PortableInterceptor::ForwardRequest (server_iogr_.in ())); +} + +TimeBase::TimeT +TAO249_ServerRequest_Interceptor2::get_now (void) +{ + // 1582... + const TimeBase::TimeT timeOffset = ACE_UINT64_LITERAL (0x1B21DD213814000); + + // Now in posix + ACE_Time_Value time_value = ACE_OS::gettimeofday (); + + TimeBase::TimeT sec_part = time_value.sec (); + sec_part = sec_part * 10000000; + TimeBase::TimeT usec_part = time_value.usec (); + usec_part = usec_part * 10; + return (sec_part + usec_part + timeOffset); +} + +void +TAO249_ServerRequest_Interceptor2::send_reply ( + PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) +ACE_THROW_SPEC ((CORBA::SystemException)) +{ +} + +void +TAO249_ServerRequest_Interceptor2::send_exception ( + PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) +ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ +} + +void +TAO249_ServerRequest_Interceptor2::send_other ( + PortableInterceptor::ServerRequestInfo_ptr + ACE_ENV_ARG_DECL_NOT_USED) +ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)) +{ +} + diff --git a/TAO/orbsvcs/tests/Bug_2287_Regression/ServerRequest_Interceptor2.h b/TAO/orbsvcs/tests/Bug_2287_Regression/ServerRequest_Interceptor2.h new file mode 100644 index 00000000000..b7767f6d798 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2287_Regression/ServerRequest_Interceptor2.h @@ -0,0 +1,98 @@ +// -*- C++ -*- + +//============================================================================= +/** + * $Id$ + */ +//============================================================================= + +#ifndef TAO249_SERVER_REQUEST_INTERCEPTOR2_H +#define TAO249_SERVER_REQUEST_INTERCEPTOR2_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ +#include "tao/LocalObject.h" +#include "tao/PortableInterceptorC.h" +#include "tao/ORB.h" +#include "tao/PI/PI.h" +#include "tao/PI_Server/PI_Server.h" +#include "tao/TimeBaseC.h" + +/** +* $Id$ +*/ +class TAO249_ServerRequest_Interceptor2 +: public virtual PortableInterceptor::ServerRequestInterceptor, + public virtual TAO_Local_RefCounted_Object +{ +public: + +/// Constructor. +TAO249_ServerRequest_Interceptor2 (void); + +/// Destructor. +~TAO249_ServerRequest_Interceptor2 (void); + +/** + * @name Methods Required by the Server Request Interceptor + * Interface + * + * These are methods that must be implemented since they are pure + * virtual in the abstract base class. They are the canonical + * methods required for all server request interceptors. + */ +//@{ +/// Return the name of this ServerRequestinterceptor. +virtual char * name (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + +virtual void destroy (ACE_ENV_SINGLE_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + +virtual void receive_request_service_contexts ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) +ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + +virtual void receive_request ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + +virtual void send_reply ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException)); + +virtual void send_exception ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); + +virtual void send_other ( + PortableInterceptor::ServerRequestInfo_ptr ri + ACE_ENV_ARG_DECL) + ACE_THROW_SPEC ((CORBA::SystemException, + PortableInterceptor::ForwardRequest)); +//@} + +static CORBA::Object_var server_iogr_; + +protected: + TimeBase::TimeT get_now (void); + +private: + +CORBA::ORB_var orb_; + +CORBA::Boolean expired_; +}; + +#endif /* TAO249_SERVER_REQUEST_INTERCEPTOR2_H */ + diff --git a/TAO/orbsvcs/tests/Bug_2287_Regression/Test.idl b/TAO/orbsvcs/tests/Bug_2287_Regression/Test.idl new file mode 100644 index 00000000000..9e1fa22e0be --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2287_Regression/Test.idl @@ -0,0 +1,24 @@ +// +// $Id$ +// + +/// Put the interfaces in a module, to avoid global namespace pollution +module Test +{ + interface Hello + { + /// A method to shutdown the ORB + /** + * This method is used to simplify the test shutdown process + */ + oneway void shutdown (); + + // Lets make sure things are working + void ping (); + + // The client calls this method which will generate + // a locate forward to the same IOGR on every invocation + // until well after the request expiration time when it will then succeed + void throw_location_forward (); + }; +}; diff --git a/TAO/orbsvcs/tests/Bug_2287_Regression/client.cpp b/TAO/orbsvcs/tests/Bug_2287_Regression/client.cpp new file mode 100644 index 00000000000..efc5c8c1da7 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2287_Regression/client.cpp @@ -0,0 +1,110 @@ +// $Id$ + +#include "TestS.h" +#include "ace/Get_Opt.h" +#include "orbsvcs/FaultTolerance/FT_ClientService_Activate.h" +#include "Hello.h" + +ACE_RCSID(Hello, client, "$Id$") + +const char *ior = "file://test.ior"; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "k:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'k': + ior = get_opts.opt_arg (); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k <ior> " + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +main (int argc, char *argv[]) +{ + CORBA::Boolean result = 0; + ACE_TRY_NEW_ENV + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv, "" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var tmp = + orb->string_to_object(ior ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Test::Hello_var hello = + Test::Hello::_narrow(tmp.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (hello.in ())) + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Test failed - Not regression - Unexpected Nil Test::Hello reference <%s>\n", + ior), + 1); + } + + // Check this isn't generating transients for any other reason + hello->ping (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + + ACE_TRY + { + hello->throw_location_forward (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_ERROR, "REGRESSION - Test has failed !!!\n")); + result = 1; + } + ACE_CATCH (CORBA::TRANSIENT, my_ex) + { + ACE_UNUSED_ARG (my_ex); + ACE_DEBUG ((LM_DEBUG, "Client catches a TRANSIENT, as expected. No problem !\n")); + } + ACE_ENDTRY; + + hello->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, + "Test failed (Not regression) because unexpected exception caught:"); + return 1; + } + ACE_ENDTRY; + + if (result) + { + ACE_DEBUG ((LM_ERROR, "Error: REGRESSION identified!!!\n")); + } + else + { + ACE_DEBUG ((LM_DEBUG, "Test passed !!!\n")); + } + return result; +} diff --git a/TAO/orbsvcs/tests/Bug_2287_Regression/run_test.pl b/TAO/orbsvcs/tests/Bug_2287_Regression/run_test.pl new file mode 100755 index 00000000000..de69f709455 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2287_Regression/run_test.pl @@ -0,0 +1,49 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib '../../../../bin'; +use PerlACE::Run_Test; + +$status = 0; + +$iorfile = PerlACE::LocalFile ("server.ior"); +unlink $iorfile; + +if (PerlACE::is_vxworks_test()) { + $SV = new PerlACE::ProcessVX ("server", "-o server.ior"); +} +else { + $SV = new PerlACE::Process ("server", "-o $iorfile"); +} +$CL = new PerlACE::Process ("client", " -k file://$iorfile"); + +$SV->Spawn (); + +if (PerlACE::waitforfile_timed ($iorfile, + $PerlACE::wait_interval_for_process_creation) == -1) { + print STDERR "ERROR: cannot find file <$iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +$client = $CL->SpawnWaitKill (300); + +if ($client != 0) { + print STDERR "ERROR: client returned $client\n"; + $status = 1; +} + +$server = $SV->WaitKill (10); + +if ($server != 0) { + print STDERR "ERROR: server returned $server\n"; + $status = 1; +} + +unlink $iorfile; + +exit $status; diff --git a/TAO/orbsvcs/tests/Bug_2287_Regression/server.cpp b/TAO/orbsvcs/tests/Bug_2287_Regression/server.cpp new file mode 100644 index 00000000000..eca1cfc94de --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_2287_Regression/server.cpp @@ -0,0 +1,243 @@ +// $Id$ + +#include "Hello.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" +#include "tao/IORManipulation/IORManip_Loader.h" +#include "tao/PortableServer/PortableServer.h" +#include "orbsvcs/FaultTolerance/FT_IOGR_Property.h" +#include "ServerORBInitializer2.h" +#include "ServerRequest_Interceptor2.h" +#include "tao/PI/PI.h" +#include "tao/ORBInitializer_Registry.h" + +ACE_RCSID (Hello, + server, + "$Id$") + +const char *ior_output_file = "test.ior"; +TAO_IOP::TAO_IOR_Manipulation_var iorm = 0; + +int +parse_args (int argc, char *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, "o:"); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'o': + ior_output_file = get_opts.opt_arg (); + break; + + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-o <iorfile>" + "\n", + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +CORBA::Object_ptr +make_iogr (const char* domain_id, CORBA::ULongLong group_id, CORBA::ULong group_version, CORBA::Object_ptr ref ACE_ENV_ARG_DECL) +{ + FT::TagFTGroupTaggedComponent ft_tag_component; + // Create the list + TAO_IOP::TAO_IOR_Manipulation::IORList iors (1); + iors.length(1); + iors [0] = CORBA::Object::_duplicate (ref); + + CORBA::Object_var new_ref = + iorm->merge_iors (iors ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + // Property values + + // Major and Minor revision numbers + ft_tag_component.component_version.major = (CORBA::Octet) 1; + ft_tag_component.component_version.minor = (CORBA::Octet) 0; + + // Domain id + //const char *id = "iogr_testing"; + ft_tag_component.group_domain_id = domain_id; + + // Object group id + ft_tag_component.object_group_id = group_id; + + // Version + ft_tag_component.object_group_ref_version = group_version; + + // Construct the IOGR Property class + TAO_FT_IOGR_Property iogr_prop (ft_tag_component); + + // Set the property + CORBA::Boolean retval = iorm->set_property (&iogr_prop, + new_ref.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + + // Set the primary + // See we are setting the second ior as the primary + if (retval != 0) + { + retval = iorm->set_primary (&iogr_prop, + new_ref.in (), + new_ref.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK_RETURN (0); + } + + return new_ref._retn (); +} + +int +main (int argc, char *argv[]) +{ + ACE_TRY_NEW_ENV + { + Server_ORBInitializer2 *temp_initializer = 0; + ACE_NEW_RETURN (temp_initializer, + Server_ORBInitializer2, + -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_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA" ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (root_poa.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + " (%P|%t) Panic: nil RootPOA\n"), + 1); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::PolicyList policies (2); + policies.length (2); + + policies[0] = + root_poa->create_id_assignment_policy (PortableServer::USER_ID + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK + + policies[1] = + root_poa->create_lifespan_policy (PortableServer::PERSISTENT + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POA_var my_poa = + root_poa->create_POA ("my_poa", + poa_manager.in (), + policies + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Creation of the new POA is over, so destroy the Policy_ptr's. + for (CORBA::ULong i = 0; i < policies.length (); ++i) + { + CORBA::Policy_ptr policy = policies[i]; + policy->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + + + if (parse_args (argc, argv) != 0) + return 1; + + Hello *hello_impl; + ACE_NEW_RETURN (hello_impl, + Hello (orb.in (), Test::Hello::_nil ()), + 1); + + PortableServer::ObjectId_var server_id = + PortableServer::string_to_ObjectId ("server_id"); + + my_poa->activate_object_with_id (server_id.in (), + hello_impl + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var hello = + my_poa->id_to_reference (server_id.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (hello.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Get a ref to the IORManipulation object + CORBA::Object_var IORM = + orb->resolve_initial_references (TAO_OBJID_IORMANIPULATION, + 0 + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Narrow + iorm = + TAO_IOP::TAO_IOR_Manipulation::_narrow (IORM.in() ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::Object_var iogr = make_iogr ("Domain_1", 1, 1, orb->string_to_object (ior.in ()) ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var iorgr_string = + orb->object_to_string (iogr.in () ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // Output the IOR to the <ior_output_file> + FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot open output file for writing IOR: %s", + ior_output_file), + 1); + ACE_OS::fprintf (output_file, "%s", iorgr_string.in ()); + ACE_OS::fclose (output_file); + + TAO249_ServerRequest_Interceptor2::server_iogr_ = CORBA::Object::_duplicate (iogr.in ()); + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + orb->run (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); + + root_poa->destroy (1, 1 ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Exception caught:"); + return 1; + } + ACE_ENDTRY; + + return 0; +} |