diff options
author | smcqueen <smcqueen@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-03-16 11:39:49 +0000 |
---|---|---|
committer | smcqueen <smcqueen@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2009-03-16 11:39:49 +0000 |
commit | c4b7f20d05711186a703cf327f8158e749371c63 (patch) | |
tree | d377b4f277d295629a8690083c43a1b1140ea448 | |
parent | 25fabcebcc8e2826912d008bd03f67e6d2bbb20d (diff) | |
download | ATCD-c4b7f20d05711186a703cf327f8158e749371c63.tar.gz |
ChangeLogTag: Mon Mar 16 11:36:58 UTC 2009 Simon McQueen <sm@prismtech.com>
28 files changed, 1334 insertions, 12 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 5f29dcfc572..5fd6704e285 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,44 @@ +Mon Mar 16 11:36:58 UTC 2009 Simon McQueen <sm@prismtech.com> + + * orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.cpp: + + Remove uninterceptable exception. + + * orbsvcs/tests/Bug_3598b_Regression/Bug_3598b_Regression.mpc: + * orbsvcs/tests/Bug_3598b_Regression/ClientORBInitializer.h: + * orbsvcs/tests/Bug_3598b_Regression/ClientORBInitializer.cpp: + * orbsvcs/tests/Bug_3598b_Regression/ClientRequest_Interceptor.h: + * orbsvcs/tests/Bug_3598b_Regression/ClientRequest_Interceptor.cpp: + * orbsvcs/tests/Bug_3598b_Regression/Hello.h: + * orbsvcs/tests/Bug_3598b_Regression/Hello.cpp: + * orbsvcs/tests/Bug_3598b_Regression/README: + * orbsvcs/tests/Bug_3598b_Regression/Test.idl: + * orbsvcs/tests/Bug_3598b_Regression/client.cpp: + * orbsvcs/tests/Bug_3598b_Regression/run_test.pl: + * orbsvcs/tests/Bug_3598b_Regression/server.cpp: + + Regression test for the above. + + * tao/Strategies/Optimized_Connection_Endpoint_Selector.cpp: + + Remove uninterceptable exception. + + * tests/Bug_3598a_Regression/Bug_3598a_Regression.mpc: + * tests/Bug_3598a_Regression/ClientORBInitializer.h: + * tests/Bug_3598a_Regression/ClientORBInitializer.cpp: + * tests/Bug_3598a_Regression/ClientRequest_Interceptor.h: + * tests/Bug_3598a_Regression/ClientRequest_Interceptor.cpp: + * tests/Bug_3598a_Regression/Hello.h: + * tests/Bug_3598a_Regression/Hello.cpp: + * tests/Bug_3598a_Regression/README: + * tests/Bug_3598a_Regression/Test.idl: + * tests/Bug_3598a_Regression/client.cpp: + * tests/Bug_3598a_Regression/run_test.pl: + * tests/Bug_3598a_Regression/server.cpp: + * tests/Bug_3598a_Regression/svc.conf: + + Regression test for the above. + Mon Mar 16 08:54:22 UTC 2009 Johnny Willemsen <jwillemsen@remedy.nl> * tao/RTCORBA/RT_Invocation_Endpoint_Selectors.cpp: diff --git a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.cpp b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.cpp index 2b9af0fe96e..142cc8f5a08 100644 --- a/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.cpp +++ b/TAO/orbsvcs/orbsvcs/FaultTolerance/FT_Invocation_Endpoint_Selectors.cpp @@ -38,12 +38,13 @@ TAO_FT_Invocation_Endpoint_Selector::select_endpoint ( retval = this->select_secondary (r, val); - if (!retval) - { - // If we get here, we completely failed to find an endpoint selector - // that we know how to use, so throw an exception. - throw CORBA::TRANSIENT (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO); - } + // If we get here and still haven't found a primary or + // secondary then we used to throw a TRANSIENT exception here. + // But that would prevent any request interception points + // being called. They may know how to fix the problem so + // we wait to throw the exception in + // Synch_Twoway_Invocation::remote_twoway and + // Synch_Oneway_Invocation::remote_oneway instead. return; } @@ -65,7 +66,7 @@ TAO_FT_Invocation_Endpoint_Selector::select_primary ( if (prof_list == 0) return false; - // Did not succeed. Try to look for primaries all over the place + // Try to look for primaries all over the place CORBA::ULong const sz = prof_list->size (); // Iterate through the list in a circular fashion. Stop one before @@ -79,7 +80,7 @@ TAO_FT_Invocation_Endpoint_Selector::select_primary ( bool retval = this->check_profile_for_primary (tmp); - // Choose a non-primary + // Found a primary if (retval == true && tmp != 0) { retval = @@ -125,7 +126,7 @@ TAO_FT_Invocation_Endpoint_Selector::select_secondary ( bool retval = this->check_profile_for_primary (tmp); - // Choose a non-primary + // Found a non-primary if (retval == false && tmp != 0) { retval = diff --git a/TAO/orbsvcs/tests/Bug_3598b_Regression/Bug_3598b_Regression.mpc b/TAO/orbsvcs/tests/Bug_3598b_Regression/Bug_3598b_Regression.mpc new file mode 100644 index 00000000000..63b37d20812 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_3598b_Regression/Bug_3598b_Regression.mpc @@ -0,0 +1,39 @@ +// -*- MPC -*- +// $Id$ + +project(*idl): taoidldefaults { + idlflags += -Sp + IDL_Files { + Test.idl + } + custom_only = 1 +} + +project(*Server): taoserver { + after += *idl + Source_Files { + Hello.cpp + server.cpp + } + Source_Files { + TestC.cpp + TestS.cpp + } + IDL_Files { + } +} + +project(*Client): taoclient, pi, ftclientorb { + after += *idl + Source_Files { + ClientORBInitializer.cpp + ClientRequest_Interceptor.cpp + client.cpp + } + Source_Files { + TestC.cpp + } + IDL_Files { + } +} + diff --git a/TAO/orbsvcs/tests/Bug_3598b_Regression/ClientORBInitializer.cpp b/TAO/orbsvcs/tests/Bug_3598b_Regression/ClientORBInitializer.cpp new file mode 100644 index 00000000000..2f4406185c9 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_3598b_Regression/ClientORBInitializer.cpp @@ -0,0 +1,28 @@ +// -*- C++ -*- +// +// $Id$ + +#include "ClientORBInitializer.h" + +void +ClientORBInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr) +{ + // No-op +} + +void +ClientORBInitializer::post_init (PortableInterceptor::ORBInitInfo_ptr info) +{ + PortableInterceptor::ClientRequestInterceptor_ptr cri = + PortableInterceptor::ClientRequestInterceptor::_nil (); + + ACE_NEW_THROW_EX (cri, + ClientRequest_Interceptor, + CORBA::NO_MEMORY ()); + + PortableInterceptor::ClientRequestInterceptor_var + client_interceptor = cri; + + info->add_client_request_interceptor (client_interceptor.in ()); + +} diff --git a/TAO/orbsvcs/tests/Bug_3598b_Regression/ClientORBInitializer.h b/TAO/orbsvcs/tests/Bug_3598b_Regression/ClientORBInitializer.h new file mode 100644 index 00000000000..1c0ca44b138 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_3598b_Regression/ClientORBInitializer.h @@ -0,0 +1,50 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ClientORBInitializer.h + * + * $Id$ + */ +//============================================================================= +#ifndef CLIENTORBINITIALIZER_H +#define CLIENTORBINITIALIZER_H + +#include /**/ "ace/pre.h" + +#include "tao/PortableInterceptorC.h" +#include "ClientRequest_Interceptor.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/// RTCORBA ORB initializer. +class ClientORBInitializer : + public virtual PortableInterceptor::ORBInitializer, + public virtual ::CORBA::LocalObject +{ +public: + + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info); +}; + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" + +#endif /* CLIENTORBINITIALIZER_H */ diff --git a/TAO/orbsvcs/tests/Bug_3598b_Regression/ClientRequest_Interceptor.cpp b/TAO/orbsvcs/tests/Bug_3598b_Regression/ClientRequest_Interceptor.cpp new file mode 100644 index 00000000000..8c25c69b51e --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_3598b_Regression/ClientRequest_Interceptor.cpp @@ -0,0 +1,89 @@ +// $Id$ + +#include "ClientRequest_Interceptor.h" + +#include "tao/CORBA_String.h" +#include "tao/debug.h" +#include "ace/Log_Msg.h" + + CORBA::Boolean + ClientRequest_Interceptor::success_flag_ = 0; + + ClientRequest_Interceptor::ClientRequest_Interceptor (void) + : name_ ("ClientRequest_Interceptor") + { + } + + ClientRequest_Interceptor::~ClientRequest_Interceptor (void) + { + } + + char * + ClientRequest_Interceptor::name () + { + return CORBA::string_dup (this->name_); + } + + void + ClientRequest_Interceptor::destroy () + { + // No-op + } + + void + ClientRequest_Interceptor::send_poll ( + PortableInterceptor::ClientRequestInfo_ptr ri + ) + { + // Print debug + CORBA::String_var op = + ri->operation (); + + + ACE_DEBUG ((LM_DEBUG, + "TAO_FT (%P|%t): ClientRequest_Interceptor::send_poll called for operation: %C\n", + op.in ())); + } + + void + ClientRequest_Interceptor::send_request ( + PortableInterceptor::ClientRequestInfo_ptr ri) + { + // Print debug + CORBA::String_var op = + ri->operation (); + + + ACE_DEBUG ((LM_DEBUG, + "ClientRequest_Interceptor::send_request called for operation: %C - things are going well...\n", + op.in ())); + } + + void + ClientRequest_Interceptor::receive_reply ( + PortableInterceptor::ClientRequestInfo_ptr) + { + // No-op + } + + void + ClientRequest_Interceptor::receive_other ( + PortableInterceptor::ClientRequestInfo_ptr) + { + // No-op + } + + void + ClientRequest_Interceptor::receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr ri) + { + // Print debug + CORBA::String_var op = + ri->operation (); + + + ACE_DEBUG ((LM_DEBUG, + "ClientRequest_Interceptor::receive_exception called for operation: %C - test has succeeded...\n", + op.in ())); + success_flag_ = 1; + } diff --git a/TAO/orbsvcs/tests/Bug_3598b_Regression/ClientRequest_Interceptor.h b/TAO/orbsvcs/tests/Bug_3598b_Regression/ClientRequest_Interceptor.h new file mode 100644 index 00000000000..36e4fc7032d --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_3598b_Regression/ClientRequest_Interceptor.h @@ -0,0 +1,68 @@ +// -*- C++ -*- +//============================================================================= +/** + * @file ClientRequest_Interceptor.h + * + * $Id$ + */ +//============================================================================= +#ifndef CLIENTREQUEST_INTERCEPTOR_H +#define CLIENTREQUEST_INTERCEPTOR_H +#include /**/ "ace/pre.h" + +#include "tao/PI/PI.h" +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** +* @class ClientRequest_Interceptor +* +*/ +class ClientRequest_Interceptor +: public virtual PortableInterceptor::ClientRequestInterceptor, + public virtual ::CORBA::LocalObject +{ +public: + +ClientRequest_Interceptor (void); + +~ClientRequest_Interceptor (void); + +/// Canonical name of the interceptor. +virtual char * name (); + + +virtual void destroy (); + +virtual void send_poll (PortableInterceptor::ClientRequestInfo_ptr); + +virtual void send_request (PortableInterceptor::ClientRequestInfo_ptr ri); + +virtual void receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri); + +virtual void receive_other (PortableInterceptor::ClientRequestInfo_ptr ri); + +virtual void receive_exception (PortableInterceptor::ClientRequestInfo_ptr ri); + +static CORBA::Boolean success_flag_; + +private: + +/// Name of the interceptor +const char *name_; + +}; +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /*CLIENTREQUEST_INTERCEPTOR_H*/ + diff --git a/TAO/orbsvcs/tests/Bug_3598b_Regression/Hello.cpp b/TAO/orbsvcs/tests/Bug_3598b_Regression/Hello.cpp new file mode 100644 index 00000000000..7b9497529ec --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_3598b_Regression/Hello.cpp @@ -0,0 +1,23 @@ +// +// $Id$ +// +#include "Hello.h" + +ACE_RCSID(Hello, Hello, "Hello.cpp,v 1.3 2002/01/29 20:21:07 okellogg Exp") + +Hello::Hello (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +char * +Hello::get_string () +{ + return CORBA::string_dup ("Hello there!"); +} + +void +Hello::shutdown () +{ + this->orb_->shutdown (0 ); +} diff --git a/TAO/orbsvcs/tests/Bug_3598b_Regression/Hello.h b/TAO/orbsvcs/tests/Bug_3598b_Regression/Hello.h new file mode 100644 index 00000000000..782b1b2f573 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_3598b_Regression/Hello.h @@ -0,0 +1,31 @@ +// +// $Id$ +// + +#ifndef HELLO_H +#define HELLO_H +#include /**/ "ace/pre.h" + +#include "TestS.h" + +/// Implement the Test::Hello interface +class Hello + : public virtual POA_Test::Hello +{ +public: + /// Constructor + Hello (CORBA::ORB_ptr orb); + + // = The skeleton methods + virtual char * get_string (); + + virtual void shutdown (); + +private: + /// Use an ORB reference to conver strings to objects and shutdown + /// the application. + CORBA::ORB_var orb_; +}; + +#include /**/ "ace/post.h" +#endif /* HELLO_H */ diff --git a/TAO/orbsvcs/tests/Bug_3598b_Regression/README b/TAO/orbsvcs/tests/Bug_3598b_Regression/README new file mode 100644 index 00000000000..b2d570b8158 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_3598b_Regression/README @@ -0,0 +1,12 @@ +$Id$ + +This test attempts to contact a server IOR with no connectable profile in it (on account of how there is no server running). + +The method invocation should fail but the installed client request interceptor should have its send_request and receive_exception methods invoked regardless. + +The expected result looks like: + +Client about to make method call that is doomed to failure... +ClientRequest_Interceptor::send_request called for operation: get_string - things are going well... +ClientRequest_Interceptor::receive_exception called for operation: get_string - test has succeeded... +Success - the server was unreachable and PI receive_exception was invoked. diff --git a/TAO/orbsvcs/tests/Bug_3598b_Regression/Test.idl b/TAO/orbsvcs/tests/Bug_3598b_Regression/Test.idl new file mode 100644 index 00000000000..3c0976e106d --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_3598b_Regression/Test.idl @@ -0,0 +1,20 @@ +// +// $Id$ +// + +/// Put the interfaces in a module, to avoid global namespace pollution +module Test +{ + /// A very simple interface + interface Hello + { + /// Return a simple string + string get_string (); + + /// A method to shutdown the ORB + /** + * This method is used to simplify the test shutdown process + */ + oneway void shutdown (); + }; +}; diff --git a/TAO/orbsvcs/tests/Bug_3598b_Regression/client.cpp b/TAO/orbsvcs/tests/Bug_3598b_Regression/client.cpp new file mode 100644 index 00000000000..651abc13e44 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_3598b_Regression/client.cpp @@ -0,0 +1,102 @@ +// $Id$ + +#include "TestC.h" +#include "ace/Get_Opt.h" +#include "tao/PortableInterceptorC.h" +#include "ClientORBInitializer.h" +#include "tao/ORBInitializer_Registry.h" +#include "orbsvcs/FaultTolerance/FT_ClientService_Activate.h" + +ACE_RCSID(Hello, client, "client.cpp,v 1.5 2002/01/29 20:21:07 okellogg Exp") + +const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior"); + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("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 +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + try + { + PortableInterceptor::ORBInitializer_ptr temp_orb_initializer = + PortableInterceptor::ORBInitializer::_nil (); + PortableInterceptor::ORBInitializer_var orb_initializer; + + // Register the ClientRequest_Interceptor ORBInitializer. + ACE_NEW_RETURN (temp_orb_initializer, + ClientORBInitializer, + -1); + + orb_initializer = temp_orb_initializer; + + PortableInterceptor::register_orb_initializer (orb_initializer.in ()); + + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var tmp = + orb->string_to_object (ACE_TEXT_ALWAYS_CHAR (ior)); + + Test::Hello_var hello = + Test::Hello::_narrow(tmp.in () ); + + if (CORBA::is_nil (hello.in ())) + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Nil Test::Hello reference <%s>\n", + ior), + 1); + } + + ACE_DEBUG ((LM_DEBUG, "Client about to make method call that is doomed to failure...\n")); + + CORBA::String_var the_string = + hello->get_string (); + + ACE_ERROR_RETURN ((LM_DEBUG, + "Error - the remote call succeeded which is bloody miraculous given that no server is running !!\n"), + 1); + } + catch (const CORBA::Exception&) + { + if (ClientRequest_Interceptor::success_flag_) + { + ACE_DEBUG ((LM_DEBUG, "Success - the server was unreachable and PI receive_exception was invoked.\n")); + return 0; + } + else + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Error: regression failed - interceptor receive_exception interception point was not invoked !!\n"), + 1); + } + } + + return 1; +} diff --git a/TAO/orbsvcs/tests/Bug_3598b_Regression/run_test.pl b/TAO/orbsvcs/tests/Bug_3598b_Regression/run_test.pl new file mode 100755 index 00000000000..0af02716e71 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_3598b_Regression/run_test.pl @@ -0,0 +1,76 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +$status = 0; +$debug_level = '0'; + +foreach $i (@ARGV) { + if ($i eq '-debug') { + $debug_level = '10'; + } +} + +my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; +my $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n"; + +my $iorbase = "server.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); + +$SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile"); +$CL = $client->CreateProcess ("client", "-k file://$client_iorfile"); +$server_status = $SV->Spawn (); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + exit 1; +} + +if ($server->WaitForFileTimed ($iorbase, + $server->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$server_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +if ($server->GetFile ($iorbase) == -1) { + print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} +if ($client->PutFile ($iorbase) == -1) { + print STDERR "ERROR: cannot set file <$client_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +$client_status = $CL->SpawnWaitKill (60); + +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; + $status = 1; +} + +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval()); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + $status = 1; +} + +$server->GetStderrLog(); +$client->GetStderrLog(); + +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); + +exit $status; diff --git a/TAO/orbsvcs/tests/Bug_3598b_Regression/server.cpp b/TAO/orbsvcs/tests/Bug_3598b_Regression/server.cpp new file mode 100644 index 00000000000..95d61429e99 --- /dev/null +++ b/TAO/orbsvcs/tests/Bug_3598b_Regression/server.cpp @@ -0,0 +1,99 @@ +// $Id$ + +#include "Hello.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" + +ACE_RCSID (Hello, + server, + "server.cpp,v 1.6 2003/11/01 11:15:11 dhinton Exp") + +const ACE_TCHAR *ior_output_file = ACE_TEXT("test.ior"); + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("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; +} + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + try + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv); + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA" ); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () ); + + 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 (); + + if (parse_args (argc, argv) != 0) + return 1; + + Hello *hello_impl = 0; + ACE_NEW_RETURN (hello_impl, + Hello (orb.in ()), + 1); + PortableServer::ServantBase_var owner_transfer(hello_impl); + + Test::Hello_var hello = + hello_impl->_this (); + + CORBA::String_var ior = + orb->object_to_string (hello.in () ); + + // 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", ior.in ()); + ACE_OS::fclose (output_file); + + root_poa->destroy (1, 1 ); + + orb->destroy (); + + ACE_DEBUG ((LM_DEBUG, "Event loop finished.\n")); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return 1; + } + + return 0; +} diff --git a/TAO/tao/Strategies/Optimized_Connection_Endpoint_Selector.cpp b/TAO/tao/Strategies/Optimized_Connection_Endpoint_Selector.cpp index a60ed33ad4b..de79c013571 100644 --- a/TAO/tao/Strategies/Optimized_Connection_Endpoint_Selector.cpp +++ b/TAO/tao/Strategies/Optimized_Connection_Endpoint_Selector.cpp @@ -165,9 +165,13 @@ TAO_Optimized_Connection_Endpoint_Selector::select_endpoint } while (r->stub ()->next_profile_retry () != 0); - // If we get here, we completely failed to find an endpoint selector - // that we know how to use, so throw an exception. - throw ::CORBA::TRANSIENT (CORBA::OMGVMCID | 2, CORBA::COMPLETED_NO); + // If we get here, we completely failed to find an endpoint + // that we know how to use. We used to throw an exception + // but that would prevent any request interception points + // being called. They may know how to fix the problem so + // we wait to throw the exception in + // Synch_Twoway_Invocation::remote_twoway and + // Synch_Oneway_Invocation::remote_oneway instead. } TAO_END_VERSIONED_NAMESPACE_DECL diff --git a/TAO/tests/Bug_3598a_Regression/Bug_3598a_Regression.mpc b/TAO/tests/Bug_3598a_Regression/Bug_3598a_Regression.mpc new file mode 100644 index 00000000000..0e883f6f7b0 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/Bug_3598a_Regression.mpc @@ -0,0 +1,39 @@ +// -*- MPC -*- +// $Id$ + +project(*idl): taoidldefaults { + idlflags += -Sp + IDL_Files { + Test.idl + } + custom_only = 1 +} + +project(*Server): taoserver, strategies { + after += *idl + Source_Files { + Hello.cpp + server.cpp + } + Source_Files { + TestC.cpp + TestS.cpp + } + IDL_Files { + } +} + +project(*Client): taoclient, pi, strategies { + after += *idl + Source_Files { + ClientORBInitializer.cpp + ClientRequest_Interceptor.cpp + client.cpp + } + Source_Files { + TestC.cpp + } + IDL_Files { + } +} + diff --git a/TAO/tests/Bug_3598a_Regression/ClientORBInitializer.cpp b/TAO/tests/Bug_3598a_Regression/ClientORBInitializer.cpp new file mode 100644 index 00000000000..2f4406185c9 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/ClientORBInitializer.cpp @@ -0,0 +1,28 @@ +// -*- C++ -*- +// +// $Id$ + +#include "ClientORBInitializer.h" + +void +ClientORBInitializer::pre_init (PortableInterceptor::ORBInitInfo_ptr) +{ + // No-op +} + +void +ClientORBInitializer::post_init (PortableInterceptor::ORBInitInfo_ptr info) +{ + PortableInterceptor::ClientRequestInterceptor_ptr cri = + PortableInterceptor::ClientRequestInterceptor::_nil (); + + ACE_NEW_THROW_EX (cri, + ClientRequest_Interceptor, + CORBA::NO_MEMORY ()); + + PortableInterceptor::ClientRequestInterceptor_var + client_interceptor = cri; + + info->add_client_request_interceptor (client_interceptor.in ()); + +} diff --git a/TAO/tests/Bug_3598a_Regression/ClientORBInitializer.h b/TAO/tests/Bug_3598a_Regression/ClientORBInitializer.h new file mode 100644 index 00000000000..1c0ca44b138 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/ClientORBInitializer.h @@ -0,0 +1,50 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file ClientORBInitializer.h + * + * $Id$ + */ +//============================================================================= +#ifndef CLIENTORBINITIALIZER_H +#define CLIENTORBINITIALIZER_H + +#include /**/ "ace/pre.h" + +#include "tao/PortableInterceptorC.h" +#include "ClientRequest_Interceptor.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/// RTCORBA ORB initializer. +class ClientORBInitializer : + public virtual PortableInterceptor::ORBInitializer, + public virtual ::CORBA::LocalObject +{ +public: + + virtual void pre_init (PortableInterceptor::ORBInitInfo_ptr info); + + virtual void post_init (PortableInterceptor::ORBInitInfo_ptr info); +}; + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" + +#endif /* CLIENTORBINITIALIZER_H */ diff --git a/TAO/tests/Bug_3598a_Regression/ClientRequest_Interceptor.cpp b/TAO/tests/Bug_3598a_Regression/ClientRequest_Interceptor.cpp new file mode 100644 index 00000000000..8c25c69b51e --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/ClientRequest_Interceptor.cpp @@ -0,0 +1,89 @@ +// $Id$ + +#include "ClientRequest_Interceptor.h" + +#include "tao/CORBA_String.h" +#include "tao/debug.h" +#include "ace/Log_Msg.h" + + CORBA::Boolean + ClientRequest_Interceptor::success_flag_ = 0; + + ClientRequest_Interceptor::ClientRequest_Interceptor (void) + : name_ ("ClientRequest_Interceptor") + { + } + + ClientRequest_Interceptor::~ClientRequest_Interceptor (void) + { + } + + char * + ClientRequest_Interceptor::name () + { + return CORBA::string_dup (this->name_); + } + + void + ClientRequest_Interceptor::destroy () + { + // No-op + } + + void + ClientRequest_Interceptor::send_poll ( + PortableInterceptor::ClientRequestInfo_ptr ri + ) + { + // Print debug + CORBA::String_var op = + ri->operation (); + + + ACE_DEBUG ((LM_DEBUG, + "TAO_FT (%P|%t): ClientRequest_Interceptor::send_poll called for operation: %C\n", + op.in ())); + } + + void + ClientRequest_Interceptor::send_request ( + PortableInterceptor::ClientRequestInfo_ptr ri) + { + // Print debug + CORBA::String_var op = + ri->operation (); + + + ACE_DEBUG ((LM_DEBUG, + "ClientRequest_Interceptor::send_request called for operation: %C - things are going well...\n", + op.in ())); + } + + void + ClientRequest_Interceptor::receive_reply ( + PortableInterceptor::ClientRequestInfo_ptr) + { + // No-op + } + + void + ClientRequest_Interceptor::receive_other ( + PortableInterceptor::ClientRequestInfo_ptr) + { + // No-op + } + + void + ClientRequest_Interceptor::receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr ri) + { + // Print debug + CORBA::String_var op = + ri->operation (); + + + ACE_DEBUG ((LM_DEBUG, + "ClientRequest_Interceptor::receive_exception called for operation: %C - test has succeeded...\n", + op.in ())); + success_flag_ = 1; + } diff --git a/TAO/tests/Bug_3598a_Regression/ClientRequest_Interceptor.h b/TAO/tests/Bug_3598a_Regression/ClientRequest_Interceptor.h new file mode 100644 index 00000000000..36e4fc7032d --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/ClientRequest_Interceptor.h @@ -0,0 +1,68 @@ +// -*- C++ -*- +//============================================================================= +/** + * @file ClientRequest_Interceptor.h + * + * $Id$ + */ +//============================================================================= +#ifndef CLIENTREQUEST_INTERCEPTOR_H +#define CLIENTREQUEST_INTERCEPTOR_H +#include /**/ "ace/pre.h" + +#include "tao/PI/PI.h" +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" + +// This is to remove "inherits via dominance" warnings from MSVC. +// MSVC is being a little too paranoid. +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable:4250) +#endif /* _MSC_VER */ + +/** +* @class ClientRequest_Interceptor +* +*/ +class ClientRequest_Interceptor +: public virtual PortableInterceptor::ClientRequestInterceptor, + public virtual ::CORBA::LocalObject +{ +public: + +ClientRequest_Interceptor (void); + +~ClientRequest_Interceptor (void); + +/// Canonical name of the interceptor. +virtual char * name (); + + +virtual void destroy (); + +virtual void send_poll (PortableInterceptor::ClientRequestInfo_ptr); + +virtual void send_request (PortableInterceptor::ClientRequestInfo_ptr ri); + +virtual void receive_reply (PortableInterceptor::ClientRequestInfo_ptr ri); + +virtual void receive_other (PortableInterceptor::ClientRequestInfo_ptr ri); + +virtual void receive_exception (PortableInterceptor::ClientRequestInfo_ptr ri); + +static CORBA::Boolean success_flag_; + +private: + +/// Name of the interceptor +const char *name_; + +}; +#if defined(_MSC_VER) +#pragma warning(pop) +#endif /* _MSC_VER */ + +#include /**/ "ace/post.h" +#endif /*CLIENTREQUEST_INTERCEPTOR_H*/ + diff --git a/TAO/tests/Bug_3598a_Regression/Hello.cpp b/TAO/tests/Bug_3598a_Regression/Hello.cpp new file mode 100644 index 00000000000..7b9497529ec --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/Hello.cpp @@ -0,0 +1,23 @@ +// +// $Id$ +// +#include "Hello.h" + +ACE_RCSID(Hello, Hello, "Hello.cpp,v 1.3 2002/01/29 20:21:07 okellogg Exp") + +Hello::Hello (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +char * +Hello::get_string () +{ + return CORBA::string_dup ("Hello there!"); +} + +void +Hello::shutdown () +{ + this->orb_->shutdown (0 ); +} diff --git a/TAO/tests/Bug_3598a_Regression/Hello.h b/TAO/tests/Bug_3598a_Regression/Hello.h new file mode 100644 index 00000000000..782b1b2f573 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/Hello.h @@ -0,0 +1,31 @@ +// +// $Id$ +// + +#ifndef HELLO_H +#define HELLO_H +#include /**/ "ace/pre.h" + +#include "TestS.h" + +/// Implement the Test::Hello interface +class Hello + : public virtual POA_Test::Hello +{ +public: + /// Constructor + Hello (CORBA::ORB_ptr orb); + + // = The skeleton methods + virtual char * get_string (); + + virtual void shutdown (); + +private: + /// Use an ORB reference to conver strings to objects and shutdown + /// the application. + CORBA::ORB_var orb_; +}; + +#include /**/ "ace/post.h" +#endif /* HELLO_H */ diff --git a/TAO/tests/Bug_3598a_Regression/README b/TAO/tests/Bug_3598a_Regression/README new file mode 100644 index 00000000000..b2d570b8158 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/README @@ -0,0 +1,12 @@ +$Id$ + +This test attempts to contact a server IOR with no connectable profile in it (on account of how there is no server running). + +The method invocation should fail but the installed client request interceptor should have its send_request and receive_exception methods invoked regardless. + +The expected result looks like: + +Client about to make method call that is doomed to failure... +ClientRequest_Interceptor::send_request called for operation: get_string - things are going well... +ClientRequest_Interceptor::receive_exception called for operation: get_string - test has succeeded... +Success - the server was unreachable and PI receive_exception was invoked. diff --git a/TAO/tests/Bug_3598a_Regression/Test.idl b/TAO/tests/Bug_3598a_Regression/Test.idl new file mode 100644 index 00000000000..3c0976e106d --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/Test.idl @@ -0,0 +1,20 @@ +// +// $Id$ +// + +/// Put the interfaces in a module, to avoid global namespace pollution +module Test +{ + /// A very simple interface + interface Hello + { + /// Return a simple string + string get_string (); + + /// A method to shutdown the ORB + /** + * This method is used to simplify the test shutdown process + */ + oneway void shutdown (); + }; +}; diff --git a/TAO/tests/Bug_3598a_Regression/client.cpp b/TAO/tests/Bug_3598a_Regression/client.cpp new file mode 100644 index 00000000000..06919103896 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/client.cpp @@ -0,0 +1,103 @@ +// $Id$ + +#include "TestC.h" +#include "ace/Get_Opt.h" +#include "tao/PortableInterceptorC.h" +#include "ClientORBInitializer.h" +#include "tao/ORBInitializer_Registry.h" +#include "tao/Strategies/advanced_resource.h" +#include "tao/Strategies/OC_Endpoint_Selector_Loader.h" + +ACE_RCSID(Hello, client, "client.cpp,v 1.5 2002/01/29 20:21:07 okellogg Exp") + +const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior"); + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("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 +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + try + { + PortableInterceptor::ORBInitializer_ptr temp_orb_initializer = + PortableInterceptor::ORBInitializer::_nil (); + PortableInterceptor::ORBInitializer_var orb_initializer; + + // Register the ClientRequest_Interceptor ORBInitializer. + ACE_NEW_RETURN (temp_orb_initializer, + ClientORBInitializer, + -1); + + orb_initializer = temp_orb_initializer; + + PortableInterceptor::register_orb_initializer (orb_initializer.in ()); + + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + if (parse_args (argc, argv) != 0) + return 1; + + CORBA::Object_var tmp = + orb->string_to_object (ACE_TEXT_ALWAYS_CHAR (ior)); + + Test::Hello_var hello = + Test::Hello::_narrow(tmp.in () ); + + if (CORBA::is_nil (hello.in ())) + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Nil Test::Hello reference <%s>\n", + ior), + 1); + } + + ACE_DEBUG ((LM_DEBUG, "Client about to make method call that is doomed to failure...\n")); + + CORBA::String_var the_string = + hello->get_string (); + + ACE_ERROR_RETURN ((LM_DEBUG, + "Error - the remote call succeeded which is bloody miraculous given that no server is running !!\n"), + 1); + } + catch (const CORBA::Exception&) + { + if (ClientRequest_Interceptor::success_flag_) + { + ACE_DEBUG ((LM_DEBUG, "Success - the server was unreachable and PI receive_exception was invoked.\n")); + return 0; + } + else + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Error: regression failed - interceptor receive_exception interception point was not invoked !!\n"), + 1); + } + } + + return 1; +} diff --git a/TAO/tests/Bug_3598a_Regression/run_test.pl b/TAO/tests/Bug_3598a_Regression/run_test.pl new file mode 100755 index 00000000000..0af02716e71 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/run_test.pl @@ -0,0 +1,76 @@ +eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}' + & eval 'exec perl -S $0 $argv:q' + if 0; + +# $Id$ +# -*- perl -*- + +use lib "$ENV{ACE_ROOT}/bin"; +use PerlACE::TestTarget; + +$status = 0; +$debug_level = '0'; + +foreach $i (@ARGV) { + if ($i eq '-debug') { + $debug_level = '10'; + } +} + +my $server = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; +my $client = PerlACE::TestTarget::create_target (2) || die "Create target 2 failed\n"; + +my $iorbase = "server.ior"; +my $server_iorfile = $server->LocalFile ($iorbase); +my $client_iorfile = $client->LocalFile ($iorbase); +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); + +$SV = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile"); +$CL = $client->CreateProcess ("client", "-k file://$client_iorfile"); +$server_status = $SV->Spawn (); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + exit 1; +} + +if ($server->WaitForFileTimed ($iorbase, + $server->ProcessStartWaitInterval()) == -1) { + print STDERR "ERROR: cannot find file <$server_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +if ($server->GetFile ($iorbase) == -1) { + print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} +if ($client->PutFile ($iorbase) == -1) { + print STDERR "ERROR: cannot set file <$client_iorfile>\n"; + $SV->Kill (); $SV->TimedWait (1); + exit 1; +} + +$client_status = $CL->SpawnWaitKill (60); + +if ($client_status != 0) { + print STDERR "ERROR: client returned $client_status\n"; + $status = 1; +} + +$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval()); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + $status = 1; +} + +$server->GetStderrLog(); +$client->GetStderrLog(); + +$server->DeleteFile($iorbase); +$client->DeleteFile($iorbase); + +exit $status; diff --git a/TAO/tests/Bug_3598a_Regression/server.cpp b/TAO/tests/Bug_3598a_Regression/server.cpp new file mode 100644 index 00000000000..95d61429e99 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/server.cpp @@ -0,0 +1,99 @@ +// $Id$ + +#include "Hello.h" +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" + +ACE_RCSID (Hello, + server, + "server.cpp,v 1.6 2003/11/01 11:15:11 dhinton Exp") + +const ACE_TCHAR *ior_output_file = ACE_TEXT("test.ior"); + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("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; +} + +int +ACE_TMAIN(int argc, ACE_TCHAR *argv[]) +{ + try + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, argv); + + CORBA::Object_var poa_object = + orb->resolve_initial_references("RootPOA" ); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in () ); + + 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 (); + + if (parse_args (argc, argv) != 0) + return 1; + + Hello *hello_impl = 0; + ACE_NEW_RETURN (hello_impl, + Hello (orb.in ()), + 1); + PortableServer::ServantBase_var owner_transfer(hello_impl); + + Test::Hello_var hello = + hello_impl->_this (); + + CORBA::String_var ior = + orb->object_to_string (hello.in () ); + + // 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", ior.in ()); + ACE_OS::fclose (output_file); + + root_poa->destroy (1, 1 ); + + orb->destroy (); + + ACE_DEBUG ((LM_DEBUG, "Event loop finished.\n")); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return 1; + } + + return 0; +} diff --git a/TAO/tests/Bug_3598a_Regression/svc.conf b/TAO/tests/Bug_3598a_Regression/svc.conf new file mode 100644 index 00000000000..75b92f3c589 --- /dev/null +++ b/TAO/tests/Bug_3598a_Regression/svc.conf @@ -0,0 +1 @@ +static OC_Endpoint_Selector_Factory "-connect_timeout 1300" |