diff options
Diffstat (limited to 'TAO')
-rw-r--r-- | TAO/ChangeLog | 17 | ||||
-rw-r--r-- | TAO/bin/tao_orb_tests.lst | 1 | ||||
-rw-r--r-- | TAO/tests/Bug_3926_Regression/Bug_3926_Regression.mpc | 39 | ||||
-rw-r--r-- | TAO/tests/Bug_3926_Regression/Client_ORBInitializer.cpp | 54 | ||||
-rw-r--r-- | TAO/tests/Bug_3926_Regression/Client_ORBInitializer.h | 30 | ||||
-rw-r--r-- | TAO/tests/Bug_3926_Regression/Client_Request_Interceptor.cpp | 129 | ||||
-rw-r--r-- | TAO/tests/Bug_3926_Regression/Client_Request_Interceptor.h | 76 | ||||
-rw-r--r-- | TAO/tests/Bug_3926_Regression/README | 85 | ||||
-rw-r--r-- | TAO/tests/Bug_3926_Regression/client.cpp | 104 | ||||
-rwxr-xr-x | TAO/tests/Bug_3926_Regression/run_test.pl | 74 | ||||
-rw-r--r-- | TAO/tests/Bug_3926_Regression/server.cpp | 109 | ||||
-rw-r--r-- | TAO/tests/Bug_3926_Regression/test.idl | 8 | ||||
-rw-r--r-- | TAO/tests/Bug_3926_Regression/test_i.cpp | 46 | ||||
-rw-r--r-- | TAO/tests/Bug_3926_Regression/test_i.h | 55 |
14 files changed, 827 insertions, 0 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 4fd35d5cb6a..5da9f220a71 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,20 @@ +Fri Nov 19 13:29:57 UTC 2010 Vladimir Zykov <vladimir.zykov@prismtech.com> + + * tests/Bug_3926_Regression/client.cpp: + * tests/Bug_3926_Regression/Client_ORBInitializer.cpp: + * tests/Bug_3926_Regression/Client_Request_Interceptor.cpp: + * tests/Bug_3926_Regression/test.idl: + * tests/Bug_3926_Regression/server.cpp: + * tests/Bug_3926_Regression/test_i.cpp: + * tests/Bug_3926_Regression/Client_ORBInitializer.h: + * tests/Bug_3926_Regression/Client_Request_Interceptor.h: + * tests/Bug_3926_Regression/README: + * tests/Bug_3926_Regression/run_test.pl: + * tests/Bug_3926_Regression/test_i.h: + * tests/Bug_3926_Regression/Bug_3926_Regression.mpc: + * bin/tao_orb_tests.lst: + Added a test and marked it as non-fixed. + Thu Nov 18 14:11:00 UTC 2010 Jeff Parsons <j.parsons@vanderbilt.edu> * TAO_IDL/be/be_visitor_dds_ts_idl.cpp: diff --git a/TAO/bin/tao_orb_tests.lst b/TAO/bin/tao_orb_tests.lst index 94be70a344a..d5e4ad493b8 100644 --- a/TAO/bin/tao_orb_tests.lst +++ b/TAO/bin/tao_orb_tests.lst @@ -188,6 +188,7 @@ TAO/tests/Bug_3837_Regression/run_test.pl: !STATIC TAO/tests/Bug_3845_Regression/run_test.pl: TAO/tests/Bug_3896_Regression/run_test.pl: !ST !NO_MESSAGING TAO/tests/Bug_3919_Regression/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO +TAO/tests/Bug_3926_Regression/run_test.pl: !FIXED_BUGS_ONLY !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !DISABLE_INTERCEPTORS TAO/tests/DIOP/run_test.pl: !ST !NO_DIOP !ACE_FOR_TAO !CORBA_E_MICRO TAO/tests/DIOP/run_test_ipv6.pl: IPV6 !ST !NO_DIOP !ACE_FOR_TAO !CORBA_E_MICRO TAO/tests/RTCORBA/Activate_Object_Multiple_ORBs/run_test.pl: !MINIMUM !CORBA_E_COMPACT !CORBA_E_MICRO !ST diff --git a/TAO/tests/Bug_3926_Regression/Bug_3926_Regression.mpc b/TAO/tests/Bug_3926_Regression/Bug_3926_Regression.mpc new file mode 100644 index 00000000000..342e78b964b --- /dev/null +++ b/TAO/tests/Bug_3926_Regression/Bug_3926_Regression.mpc @@ -0,0 +1,39 @@ +// -*- MPC -*- +// $Id$ + +project(*idl): taoidldefaults { + IDL_Files { + test.idl + } + custom_only = 1 +} + +project(*Server): taoserver { + after += *idl + + Source_Files { + test_i.cpp + server.cpp + } + Source_Files { + testC.cpp + testS.cpp + } + IDL_Files { + } +} + +project(*Client): taoclient, pi, interceptors { + after += *idl + + Source_Files { + Client_ORBInitializer.cpp + Client_Request_Interceptor.cpp + client.cpp + } + Source_Files { + testC.cpp + } + IDL_Files { + } +} diff --git a/TAO/tests/Bug_3926_Regression/Client_ORBInitializer.cpp b/TAO/tests/Bug_3926_Regression/Client_ORBInitializer.cpp new file mode 100644 index 00000000000..bc817f79d96 --- /dev/null +++ b/TAO/tests/Bug_3926_Regression/Client_ORBInitializer.cpp @@ -0,0 +1,54 @@ +// -*- C++ -*- +// $Id$ + +#include "Client_ORBInitializer.h" + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "Client_Request_Interceptor.h" + +#include "ace/OS_NS_string.h" + +void +Client_ORBInitializer::pre_init ( + PortableInterceptor::ORBInitInfo_ptr) +{ +} + +void +Client_ORBInitializer::post_init ( + PortableInterceptor::ORBInitInfo_ptr info) +{ + CORBA::String_var orb_id = info->orb_id (); + + CORBA::StringSeq_var args = info->arguments (); + + CORBA::String_var forward_str; + + // Extract the last forward reference from the argument list. + CORBA::ULong args_len = args->length (); + for (CORBA::ULong i = 0; i < args_len; ++i) + if (ACE_OS::strcmp ("-k", args[i]) == 0 + && i < (args_len - 1)) + forward_str = args[i + 1]; + + PortableInterceptor::ClientRequestInterceptor_ptr interceptor = + PortableInterceptor::ClientRequestInterceptor::_nil (); + + // Install the client request interceptor. + ACE_NEW_THROW_EX (interceptor, + Client_Request_Interceptor (orb_id.in (), + forward_str.in ()), + CORBA::NO_MEMORY ( + CORBA::SystemException::_tao_minor_code ( + TAO::VMCID, + ENOMEM), + CORBA::COMPLETED_NO)); + + PortableInterceptor::ClientRequestInterceptor_var + client_interceptor = interceptor; + + info->add_client_request_interceptor (client_interceptor.in ()); +} + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ diff --git a/TAO/tests/Bug_3926_Regression/Client_ORBInitializer.h b/TAO/tests/Bug_3926_Regression/Client_ORBInitializer.h new file mode 100644 index 00000000000..ff2b4beafa2 --- /dev/null +++ b/TAO/tests/Bug_3926_Regression/Client_ORBInitializer.h @@ -0,0 +1,30 @@ +// -*- C++ -*- + +#ifndef TAO_CLIENT_ORB_INITIALIZER_H +#define TAO_CLIENT_ORB_INITIALIZER_H + +#include /**/ "ace/pre.h" + +#include "tao/PI/PI.h" + +#if TAO_HAS_INTERCEPTORS == 1 + +#include "tao/LocalObject.h" + +/// Client side ORB initializer. +class Client_ORBInitializer : + 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); +}; + +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + +#include /**/ "ace/post.h" + +#endif /* TAO_CLIENT_ORB_INITIALIZER_H */ diff --git a/TAO/tests/Bug_3926_Regression/Client_Request_Interceptor.cpp b/TAO/tests/Bug_3926_Regression/Client_Request_Interceptor.cpp new file mode 100644 index 00000000000..ad3ac8a59e1 --- /dev/null +++ b/TAO/tests/Bug_3926_Regression/Client_Request_Interceptor.cpp @@ -0,0 +1,129 @@ +// -*- C++ -*- +// $Id$ + +#include "Client_Request_Interceptor.h" +#include "testC.h" + +#include "ace/Log_Msg.h" + +Client_Request_Interceptor::Client_Request_Interceptor ( + const char *orb_id, + const char *forward_str) + : orb_id_ (CORBA::string_dup (orb_id)), + orb_ (), + request_count_ (0), + forward_str_ (CORBA::string_dup (forward_str)) +{ +} + +char * +Client_Request_Interceptor::name () +{ + return CORBA::string_dup ("Client_Request_Interceptor"); +} + +void +Client_Request_Interceptor::destroy (void) +{ +} + +void +Client_Request_Interceptor::send_request ( + PortableInterceptor::ClientRequestInfo_ptr ri) +{ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CRI: in send_request\n"))); + + ++this->request_count_; + + CORBA::Boolean response_expected = + ri->response_expected (); + + if (!response_expected) // A one-way request. + return; + + // Request 1 -- non-forwarded + // Request 2 -- forwarded by this interception point. + // Request 3 -- non-forwarded + + if (this->request_count_ == 2) + { + if (CORBA::is_nil (this->orb_.in ())) + { + int argc = 0; + char **const argv= 0; + this->orb_ = CORBA::ORB_init (argc, + argv, + this->orb_id_.in ()); + } + + CORBA::Object_var forward = + this->orb_->string_to_object (this->forward_str_.in ()); + + CORBA::String_var forward_str = + this->orb_->object_to_string (forward.in ()); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CRI: request %d will be forwarded via send_request()\n"), + this->request_count_)); + + // Notice that this is not a permanent forward. + throw PortableInterceptor::ForwardRequest (forward.in ()); + } +} + +void +Client_Request_Interceptor::send_poll ( + PortableInterceptor::ClientRequestInfo_ptr) +{ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CRI: in send_poll\n"))); +} + +void +Client_Request_Interceptor::receive_reply ( + PortableInterceptor::ClientRequestInfo_ptr) +{ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CRI: in receive_reply\n"))); +} + +void +Client_Request_Interceptor::receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr) +{ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CRI: in receive_exception\n"))); +} + +void +Client_Request_Interceptor::receive_other ( + PortableInterceptor::ClientRequestInfo_ptr ri) +{ + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CRI: in receive_other\n"))); + + CORBA::Boolean response_expected = + ri->response_expected (); + + // Oneway + if (!response_expected) + return; + + PortableInterceptor::ReplyStatus reply_status; + + try + { + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CRI: in receive_other, before reply_status\n"))); + + reply_status = ri->reply_status (); + } + catch(CORBA::BAD_INV_ORDER const &e) + { + e._tao_print_exception ("CRI: exception"); + } + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("CRI: in receive_other, after reply_status\n"))); +} diff --git a/TAO/tests/Bug_3926_Regression/Client_Request_Interceptor.h b/TAO/tests/Bug_3926_Regression/Client_Request_Interceptor.h new file mode 100644 index 00000000000..66e204db3b6 --- /dev/null +++ b/TAO/tests/Bug_3926_Regression/Client_Request_Interceptor.h @@ -0,0 +1,76 @@ +// -*- C++ -*- + +#ifndef CLIENT_REQUEST_INTERCEPTOR_H +#define CLIENT_REQUEST_INTERCEPTOR_H + +#include "ace/config-all.h" + +#if !defined (ACE_LACKS_PRAGMA_ONCE) +# pragma once +#endif /* ACE_LACKS_PRAGMA_ONCE */ + +#include "tao/PI/PI.h" +#include "tao/PortableInterceptorC.h" +#include "tao/LocalObject.h" +#include "tao/ORB.h" +#include "tao/CORBA_String.h" + +class Client_Request_Interceptor + : public virtual PortableInterceptor::ClientRequestInterceptor, + public virtual CORBA::LocalObject +{ +public: + + /// Constructor. + Client_Request_Interceptor (const char *orb_id, + const char *forward_str); + + /** + * @name Methods Required by the Client 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 client request interceptors. + */ + //@{ + /// Return the name of this ClientRequestinterceptor. + virtual char * name (void); + + virtual void destroy (void); + + virtual void send_request ( + PortableInterceptor::ClientRequestInfo_ptr ri); + + virtual void send_poll ( + PortableInterceptor::ClientRequestInfo_ptr ri); + + virtual void receive_reply ( + PortableInterceptor::ClientRequestInfo_ptr ri); + + virtual void receive_exception ( + PortableInterceptor::ClientRequestInfo_ptr ri); + + virtual void receive_other ( + PortableInterceptor::ClientRequestInfo_ptr ri); + //@} + +private: + + ///The ID of the ORB this interceptor is registered with. + CORBA::String_var orb_id_; + + /// Pseudo-reference to the ORB this interceptor is registered + /// with. + CORBA::ORB_var orb_; + + /// The number of requests intercepted by this interceptor. + CORBA::ULong request_count_; + + /// Stringified reference to the object the initial request will be + /// forwarded to by this interceptor. + CORBA::String_var forward_str_; + +}; + +#endif /* CLIENT_REQUEST_INTERCEPTOR_H */ diff --git a/TAO/tests/Bug_3926_Regression/README b/TAO/tests/Bug_3926_Regression/README new file mode 100644 index 00000000000..00be79aab75 --- /dev/null +++ b/TAO/tests/Bug_3926_Regression/README @@ -0,0 +1,85 @@ +// $Id$ + +The scenario for this test is the following. + +The client: + +- makes a first request to the server, the send_request interception point does nothing +- receives a reply, receive_reply interception point called -> *OK* +- makes another request, the send_request interception point forwards it to the server IOR +- receives a reply, receive_reply interception point called -> *OK* +- makes a third request, the send_request interception does nothing + +At this point server is instructed to throw an exception. + +If the server throws one exception in the following set +*COMM_FAILURE* +*TRANSIENT* +*NO_RESPONSE* +*OBJ_ADAPTER* +with completion status *COMPLETED_NO* the client's *receive_other* interception point is +called *with an invalid ClientRequestInfo object*. Reading this object will result in a +BAD_INV_ORDER exception to be raised with minor code of 1330446350. + +If the server throws any other exception, the receive_exception interception point is +called as expected. + + +__Successful Output__ + +$> ./run_test.pl +SERVER: test_i servant: <IOR:....> +CLIENT: Issuing request 1. +CRI: in send_request +CRI: in receive_reply +CLIENT: Request 1 returns 1. +CLIENT: Issuing request 2. +CRI: in send_request +CRI: request 2 will be forwarded via send_request() +CRI: in send_request +CRI: in receive_reply +CLIENT: Request 2 returns 2. +CLIENT: Issuing request 3. +CRI: in send_request +CRI: in receive_other +CRI: in receive_other, before reply_status +CRI: in receive_other, after reply_status +CRI: in send_request +CRI: in receive_reply +CLIENT: Request 3 returns 4. +CRI: in send_request +SERVER: Server is shutting down at 4. +SERVER: Event loop finished. +CRI: in receive_other + + +__Regression Output__ + +$> ./run_test.pl +SERVER: test_i servant: <IOR:....> +CLIENT: Issuing request 1. +CRI: in send_request +CRI: in receive_reply +CLIENT: Request 1 returns 1. +CLIENT: Issuing request 2. +CRI: in send_request +CRI: request 2 will be forwarded via send_request() +CRI: in send_request +CRI: in receive_reply +CLIENT: Request 2 returns 2. +CLIENT: Issuing request 3. +CRI: in send_request +CRI: in receive_other +CRI: in receive_other, before reply_status +(15042|46912532998624) EXCEPTION, CRI: exception +system exception, ID 'IDL:omg.org/CORBA/BAD_INV_ORDER:1.0' +OMG minor code (14), described as 'Invalid portable interceptor call', completed = NO + +CRI: in receive_other, after reply_status +CRI: in send_request +CRI: in receive_reply +CLIENT: Request 3 returns 4. +CRI: in send_request +SERVER: Server is shutting down at 4. +SERVER: Event loop finished. +CRI: in receive_other diff --git a/TAO/tests/Bug_3926_Regression/client.cpp b/TAO/tests/Bug_3926_Regression/client.cpp new file mode 100644 index 00000000000..e56deca7d19 --- /dev/null +++ b/TAO/tests/Bug_3926_Regression/client.cpp @@ -0,0 +1,104 @@ +// -*- C++ -*- +// $Id$ + +#include "testC.h" +#include "Client_ORBInitializer.h" + +#include "tao/ORBInitializer_Registry.h" + +#include "ace/Get_Opt.h" +#include "ace/Argv_Type_Converter.h" + +const ACE_TCHAR *ior = 0; + +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; + default: + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Usage: %s ") + ACE_TEXT ("-k IOR\n"), + argv[0]), + -1); + } + + return 0; +} + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + int status = 0; + + try + { +#if TAO_HAS_INTERCEPTORS == 1 + PortableInterceptor::ORBInitializer_ptr temp_initializer = + PortableInterceptor::ORBInitializer::_nil (); + + ACE_NEW_RETURN (temp_initializer, + Client_ORBInitializer, + -1); // No exceptions yet! + PortableInterceptor::ORBInitializer_var orb_initializer = + temp_initializer; + + PortableInterceptor::register_orb_initializer (orb_initializer.in ()); +#endif /* TAO_HAS_INTERCEPTORS == 1 */ + + ACE_Argv_Type_Converter narrow (argc, argv); + CORBA::ORB_var orb = + CORBA::ORB_init (narrow.get_argc (), narrow.get_ASCII_argv (), "ClientORB"); + + ACE_Argv_Type_Converter wide (narrow.get_argc (), narrow.get_ASCII_argv ()); + if (::parse_args (wide.get_argc (), wide.get_TCHAR_argv ()) != 0) + return -1; + + CORBA::Object_var object = + orb->string_to_object (ACE_TEXT_ALWAYS_CHAR (ior)); + + hello::GoodDay_var server = + hello::GoodDay::_narrow (object.in ()); + + if (CORBA::is_nil (server.in ())) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Object reference <%s> is nil\n"), + ior), + 1); + } + + for (int i = 1; i <= 3; ++i) + { + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("CLIENT: Issuing request %d.\n"), + i)); + + CORBA::Short number = server->number (); + + ACE_DEBUG ((LM_INFO, + ACE_TEXT ("CLIENT: Request %d returns %d.\n"), + i, + number)); + } + + server->shutdown (); + + orb->destroy (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Caught exception:"); + return -1; + } + + return status; +} diff --git a/TAO/tests/Bug_3926_Regression/run_test.pl b/TAO/tests/Bug_3926_Regression/run_test.pl new file mode 100755 index 00000000000..effdc975fb0 --- /dev/null +++ b/TAO/tests/Bug_3926_Regression/run_test.pl @@ -0,0 +1,74 @@ +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 ($server->ProcessStartWaitInterval()); + +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->DeleteFile($iorbase); +$client->DeleteFile($iorbase); + +exit $status; diff --git a/TAO/tests/Bug_3926_Regression/server.cpp b/TAO/tests/Bug_3926_Regression/server.cpp new file mode 100644 index 00000000000..99a2277b57c --- /dev/null +++ b/TAO/tests/Bug_3926_Regression/server.cpp @@ -0,0 +1,109 @@ +// -*- C++ -*- +// $Id$ + +#include "test_i.h" + +#include "ace/Get_Opt.h" +#include "ace/OS_NS_stdio.h" + +const ACE_TCHAR *ior_file = 0; + +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_file = get_opts.opt_arg (); + break; + default: + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("Usage: %s ") + ACE_TEXT ("-o IOR\n"), + argv[0]), + -1); + } + + 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"); + + if (CORBA::is_nil (poa_object.in ())) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("SERVER: Unable to initialize the POA.\n")), + 1); + + PortableServer::POA_var root_poa = + PortableServer::POA::_narrow (poa_object.in ()); + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (); + + if (::parse_args (argc, argv) != 0) + return -1; + + // Servant + test_i *servant = 0; + ACE_NEW_RETURN (servant, + test_i (0, orb.in ()), + -1); + PortableServer::ServantBase_var safe (servant); + + PortableServer::ObjectId_var oid = + root_poa->activate_object (servant); + + CORBA::Object_var obj = + root_poa->servant_to_reference (servant); + + CORBA::String_var ior = + orb->object_to_string (obj.in ()); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("SERVER: test_i servant: <%C>\n"), + ior.in ())); + + poa_manager->activate (); + + // IOR + FILE *output_file= ACE_OS::fopen (ior_file, "w"); + if (output_file == 0) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("SERVER: Cannot open output file <%s> ") + ACE_TEXT ("for writting IOR: %C"), + ior_file, + ior.in ()), + 1); + ACE_OS::fprintf (output_file, "%s", ior.in ()); + ACE_OS::fclose (output_file); + + // Run the ORB event loop. + orb->run (); + + root_poa->destroy (1, 1); + + orb->destroy (); + + ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("SERVER: Event loop finished.\n"))); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Caught exception:"); + return -1; + } + + return 0; +} diff --git a/TAO/tests/Bug_3926_Regression/test.idl b/TAO/tests/Bug_3926_Regression/test.idl new file mode 100644 index 00000000000..3c60aba7dd8 --- /dev/null +++ b/TAO/tests/Bug_3926_Regression/test.idl @@ -0,0 +1,8 @@ +// $Id$ + +module hello { + interface GoodDay { + short number (); + oneway void shutdown (); + }; +}; diff --git a/TAO/tests/Bug_3926_Regression/test_i.cpp b/TAO/tests/Bug_3926_Regression/test_i.cpp new file mode 100644 index 00000000000..bbaee56dd3e --- /dev/null +++ b/TAO/tests/Bug_3926_Regression/test_i.cpp @@ -0,0 +1,46 @@ +// -*- C++ -*- +// $Id$ + +#include "test_i.h" + +test_i::test_i (CORBA::Short num, + CORBA::ORB_ptr orb) + : number_ (num), + orb_ (CORBA::ORB::_duplicate (orb)) +{ +} + +test_i::~test_i (void) +{ +} + +CORBA::Short +test_i::number (void) +{ + ++this->number_; + if (this->number_ == 3) + { +#if 1 + // Either throw any of these 4 exceptions with completion status + // COMPLETED_NO and see how it's handled in receive_other() point. + throw ::CORBA::TRANSIENT (0, CORBA::COMPLETED_NO); + // throw ::CORBA::NO_RESPONSE (0, CORBA::COMPLETED_NO); + // throw ::CORBA::COMM_FAILURE (0, CORBA::COMPLETED_NO); + // throw ::CORBA::OBJ_ADAPTER (0, CORBA::COMPLETED_NO); +#else + // Or throw any other exception and see how it's handled in + // receive_exception() point on the client side. + throw ::CORBA::INTERNAL (0, CORBA::COMPLETED_NO); +#endif + } + return this->number_; +} + +void +test_i::shutdown (void) +{ + ACE_DEBUG ((LM_DEBUG, + "SERVER: Server is shutting down at %d.\n", + this->number_)); + this->orb_->shutdown (0); +} diff --git a/TAO/tests/Bug_3926_Regression/test_i.h b/TAO/tests/Bug_3926_Regression/test_i.h new file mode 100644 index 00000000000..81f75665a8d --- /dev/null +++ b/TAO/tests/Bug_3926_Regression/test_i.h @@ -0,0 +1,55 @@ +// -*- C++ -*- + +//============================================================================= +/** + * @file test_i.h + * + * $Id$ + * + * Implementation header for the "test" IDL interface for the + * PortableInterceptor::ForwardRequest test. + * + * @author Ossama Othman <ossama@uci.edu> + */ +//============================================================================= + +#ifndef TEST_I_H +#define TEST_I_H + +#include "testS.h" + +/** + * @class test_i + * + * @brief Simple test class. + * + * This class implements the "test" interface used in this test. + */ +class test_i : public virtual POA_hello::GoodDay +{ +public: + + /// Constructor. + test_i (CORBA::Short num, + CORBA::ORB_ptr orb); + + /// Destructor. + ~test_i (void); + + /// Return the number assigned to this object. + virtual CORBA::Short number (void); + + /// Shutdown the ORB. + virtual void shutdown (void); + +private: + + /// The number assigned to this object. + CORBA::Short number_; + + /// Pseudo-reference to the ORB. + CORBA::ORB_var orb_; + +}; + +#endif /* TEST_I_H */ |