diff options
author | bala <balanatarajan@users.noreply.github.com> | 2004-11-14 05:02:41 +0000 |
---|---|---|
committer | bala <balanatarajan@users.noreply.github.com> | 2004-11-14 05:02:41 +0000 |
commit | e98ab23c68c10e4f93e408700f227a3c10e746bb (patch) | |
tree | ad0067744337dd9dedad2db1688ae6e120790679 | |
parent | a231a62216a09218f5166ece49d6ce1501e17ff5 (diff) | |
download | ATCD-e98ab23c68c10e4f93e408700f227a3c10e746bb.tar.gz |
ChangeLogTag:Sun Nov 14 05:01:28 2004 Balachandran Natarajan <bala@dre.vanderbilt.edu>
-rw-r--r-- | TAO/ChangeLog | 18 | ||||
-rw-r--r-- | TAO/tao/PortableServer/Object_Adapter.cpp | 104 | ||||
-rw-r--r-- | TAO/tao/PortableServer/Object_Adapter.h | 3 | ||||
-rw-r--r-- | TAO/tests/Bug_1535_Regression/Bug_1535_Regression.mpc | 8 | ||||
-rw-r--r-- | TAO/tests/Bug_1535_Regression/Test.idl | 6 | ||||
-rw-r--r-- | TAO/tests/Bug_1535_Regression/bug_1535_regression.cpp | 228 | ||||
-rwxr-xr-x | TAO/tests/Bug_1535_Regression/run_test.pl | 27 |
7 files changed, 328 insertions, 66 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 2356fc4cbf3..3b7f935f197 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,21 @@ +Sun Nov 14 05:01:28 2004 Balachandran Natarajan <bala@dre.vanderbilt.edu> + + * tao/PortableServer/Object_Adapter.cpp: + * tao/PortableServer/Object_Adapter.h: + + Fix for Bug 1535. Please see + + http://deuce.doc.wustl.edu/bugzilla/show_bug.cgi?id=1535 + + for details. + + * tests/Bug_1535_Regression/Bug_1535_Regression.mpc: + * tests/Bug_1535_Regression/Test.idl: + * tests/Bug_1535_Regression/bug_1535_regression.cpp: + * tests/Bug_1535_Regression/run_test.pl: + + Regression test for Bug 1535. + Fri Nov 12 14:51:19 2004 Jeff Parsons <j.parsons@vanderbilt.edu> * TAO_IDL/be/be_visitor_typecode/typecode_defn.cpp: diff --git a/TAO/tao/PortableServer/Object_Adapter.cpp b/TAO/tao/PortableServer/Object_Adapter.cpp index ced76a36912..fb7640d6f01 100644 --- a/TAO/tao/PortableServer/Object_Adapter.cpp +++ b/TAO/tao/PortableServer/Object_Adapter.cpp @@ -814,41 +814,26 @@ CORBA::Object_ptr TAO_Object_Adapter::create_collocated_object (TAO_Stub *stub, const TAO_MProfile &mp) { - ACE_DECLARE_NEW_CORBA_ENV; - ACE_TRY - { - TAO_ServantBase *sb = - this->get_collocated_servant (mp - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + TAO_ServantBase *sb = this->get_collocated_servant (mp); - // Set the servant ORB. Do not duplicate the ORB here since - // TAO_Stub::servant_orb() duplicates it. - stub->servant_orb (this->orb_core_.orb ()); + // Set the servant ORB. Do not duplicate the ORB here since + // TAO_Stub::servant_orb() duplicates it. + stub->servant_orb (this->orb_core_.orb ()); - // It is ok to create a collocated object even when <sb> is - // zero. - CORBA::Object_ptr x; - ACE_NEW_RETURN (x, - CORBA::Object (stub, - 1, - sb), - CORBA::Object::_nil ()); + // It is ok to create a collocated object even when <sb> is + // zero. + CORBA::Object_ptr x; + ACE_NEW_RETURN (x, + CORBA::Object (stub, + 1, + sb), + CORBA::Object::_nil ()); - // Here we set the strategized Proxy Broker. - x->_proxy_broker (the_tao_collocated_object_proxy_broker ()); - - // Success. - return x; - } - ACE_CATCHANY - { - // Ignore the exception and continue with the next one. - } - ACE_ENDTRY; + // Here we set the strategized Proxy Broker. + x->_proxy_broker (the_tao_collocated_object_proxy_broker ()); - // Failure. - return CORBA::Object::_nil (); + // Success. + return x; } CORBA::Long @@ -857,40 +842,23 @@ TAO_Object_Adapter::initialize_collocated_object (TAO_Stub *stub, { // @@ What about forwarding. With this approach we are never // forwarded when we use collocation! - const TAO_MProfile &mp = - stub->base_profiles (); - - ACE_DECLARE_NEW_CORBA_ENV; - - ACE_TRY - { - TAO_ServantBase *sb = - this->get_collocated_servant (mp - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + const TAO_MProfile &mp = stub->base_profiles (); - // Set the servant ORB. Do not duplicate the ORB here since - // TAO_Stub::servant_orb() duplicates it. - stub->servant_orb (this->orb_core_.orb ()); + TAO_ServantBase *sb = this->get_collocated_servant (mp); - // It is ok to set the object as a collocated object even when - // <sb> is zero. - obj->set_collocated_servant (sb); + // Set the servant ORB. Do not duplicate the ORB here since + // TAO_Stub::servant_orb() duplicates it. + stub->servant_orb (this->orb_core_.orb ()); - // Here we set the strategized Proxy Broker. - obj->_proxy_broker (the_tao_collocated_object_proxy_broker ()); + // It is ok to set the object as a collocated object even when + // <sb> is zero. + obj->set_collocated_servant (sb); - // Success. - return 0; - } - ACE_CATCHANY - { - // Ignore exceptions.. - } - ACE_ENDTRY; + // Here we set the strategized Proxy Broker. + obj->_proxy_broker (the_tao_collocated_object_proxy_broker ()); - // Failure. - return -1; + // Success. + return 0; } TAO_ServantBase * @@ -911,10 +879,18 @@ TAO_Object_Adapter::get_collocated_servant (const TAO_MProfile &mp TAO_ServantBase *servant = 0; - this->find_servant (objkey.in (), - servant - ACE_ENV_ARG_PARAMETER); - ACE_CHECK_RETURN (0); + ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + this->find_servant (objkey.in (), + servant + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + } + ACE_ENDTRY; return servant; } diff --git a/TAO/tao/PortableServer/Object_Adapter.h b/TAO/tao/PortableServer/Object_Adapter.h index 2f245dedd04..582f6390c85 100644 --- a/TAO/tao/PortableServer/Object_Adapter.h +++ b/TAO/tao/PortableServer/Object_Adapter.h @@ -846,8 +846,7 @@ public: private: /// Helper method to get collocated servant - TAO_ServantBase *get_collocated_servant (const TAO_MProfile &mp - ACE_ENV_ARG_DECL); + TAO_ServantBase *get_collocated_servant (const TAO_MProfile &mp); private: diff --git a/TAO/tests/Bug_1535_Regression/Bug_1535_Regression.mpc b/TAO/tests/Bug_1535_Regression/Bug_1535_Regression.mpc new file mode 100644 index 00000000000..afe193898ee --- /dev/null +++ b/TAO/tests/Bug_1535_Regression/Bug_1535_Regression.mpc @@ -0,0 +1,8 @@ +// -*- MPC -*- +// $Id$ + +project(bug_1535_regression) : taoexe, utils, portableserver { + Source_Files { + bug_1535_regression.cpp + } +} diff --git a/TAO/tests/Bug_1535_Regression/Test.idl b/TAO/tests/Bug_1535_Regression/Test.idl new file mode 100644 index 00000000000..c3b752788a4 --- /dev/null +++ b/TAO/tests/Bug_1535_Regression/Test.idl @@ -0,0 +1,6 @@ +// $Id$ + +interface Test +{ + void print_hello_world(); +}; diff --git a/TAO/tests/Bug_1535_Regression/bug_1535_regression.cpp b/TAO/tests/Bug_1535_Regression/bug_1535_regression.cpp new file mode 100644 index 00000000000..b7795e220c7 --- /dev/null +++ b/TAO/tests/Bug_1535_Regression/bug_1535_regression.cpp @@ -0,0 +1,228 @@ +// $Id$ + +#include "TestS.h" +#include "tao/Utils/ORB_Destroyer.h" +#include "tao/Utils/RIR_Narrow.h" +#include "tao/Utils/PolicyList_Destroyer.h" +#include "tao/Utils/Servant_Var.h" + +ACE_RCSID (Bug_1535_Regression, + bug_1535_regression, + "$Id$") + +PortableServer::POA_ptr +create_persistent_POA (PortableServer::POA_ptr parent, + char const * name + ACE_ENV_ARG_DECL) +{ + TAO::Utils::PolicyList_Destroyer plist (3); + plist.length(3); + + plist[0] = + parent->create_lifespan_policy (PortableServer::PERSISTENT + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + plist[1] = + parent->create_id_assignment_policy (PortableServer::USER_ID + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + plist[2] = + parent->create_implicit_activation_policy ( + PortableServer::NO_IMPLICIT_ACTIVATION + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + PortableServer::POAManager_var mgr = + parent->the_POAManager(); + + return parent->create_POA (name, + mgr.in(), + plist + ACE_ENV_ARG_PARAMETER); +} + +void +test_create_object_before_servant_reactivation ( + CORBA::ORB_ptr orb, + PortableServer::POA_ptr root_poa + ACE_ENV_ARG_DECL) +{ + // Create a persistent POA and then create a reference in it... + PortableServer::POA_var persistent_poa = + create_persistent_POA(root_poa, + "T1" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + + PortableServer::ObjectId_var oid = + PortableServer::string_to_ObjectId ("TestServant" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Object_var object = + persistent_poa->create_reference_with_id ( + oid.in (), + _tc_Test->id() + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (object.in ())) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) nil reference in create_reference_with_id \n")); + + return; + } + + CORBA::String_var ior = + orb->object_to_string (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Now destroy the POA... + persistent_poa->destroy (true, + true); + + // Now create the POA again... + persistent_poa = + create_persistent_POA (root_poa, + "T1" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // And try to create the object again... + object = + orb->string_to_object (ior.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if(CORBA::is_nil (object.in ())) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) nil reference in string_to_object (servant reactivation) \n")); + return; + } + + persistent_poa->destroy (true, + true + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +void +test_create_object_before_POA_reactivation( + CORBA::ORB_ptr orb, + PortableServer::POA_ptr root_poa + ACE_ENV_ARG_DECL) +{ + // Create a persistent POA and then create a reference in it... + PortableServer::POA_var persistent_poa = + create_persistent_POA (root_poa, + "T2" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + PortableServer::ObjectId_var oid = + PortableServer::string_to_ObjectId ("TestServant" + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + CORBA::Object_var object = + persistent_poa->create_reference_with_id (oid.in (), + _tc_Test->id () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (object.in ())) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) nil reference in create_reference_with_id \n")); + return; + } + + CORBA::String_var ior = + orb->object_to_string (object.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // Now destroy the POA... + persistent_poa->destroy (true, + true + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + // And try to create the object again... + object = orb->string_to_object (ior.in () + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; + + if (CORBA::is_nil (object.in ())) + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) nil reference in string_to_object (POA reactivation) \n")); + + return; + } + + persistent_poa->destroy (true, + true + ACE_ENV_ARG_PARAMETER); + ACE_CHECK; +} + +int +main (int argc, char *argv[]) +{ + ACE_DECLARE_NEW_CORBA_ENV; + + ACE_TRY + { + CORBA::ORB_var orb = + CORBA::ORB_init (argc, + argv, + "" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + TAO::Utils::ORB_Destroyer orb_destroyer (orb.in()); + + PortableServer::POA_var root_poa = + TAO::Utils::RIR_Narrow<PortableServer::POA>::narrow (orb.in (), + "RootPOA" + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + PortableServer::POAManager_var poa_manager = + root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + test_create_object_before_POA_reactivation (orb.in(), + root_poa.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + test_create_object_before_servant_reactivation (orb.in (), + root_poa.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "Caught a CORBA exception \n"); + return 1; + } + ACE_CATCHALL + { + return 1; + } + ACE_ENDTRY; + ACE_CHECK; + return 0; +} diff --git a/TAO/tests/Bug_1535_Regression/run_test.pl b/TAO/tests/Bug_1535_Regression/run_test.pl new file mode 100755 index 00000000000..3182220ecf1 --- /dev/null +++ b/TAO/tests/Bug_1535_Regression/run_test.pl @@ -0,0 +1,27 @@ +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; + +$SV = new PerlACE::Process ("bug_1535_regression", ""); + + +$SV->Spawn (); + +$server = $SV->WaitKill (10); + +if ($server != 0) { + print STDERR "ERROR: server returned $server\n"; + $status = 1; +} + +unlink $iorfile; + +exit $status; |