summaryrefslogtreecommitdiff
path: root/TAO/tests/DLL_ORB/Test_Client_Module.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tests/DLL_ORB/Test_Client_Module.cpp')
-rw-r--r--TAO/tests/DLL_ORB/Test_Client_Module.cpp56
1 files changed, 28 insertions, 28 deletions
diff --git a/TAO/tests/DLL_ORB/Test_Client_Module.cpp b/TAO/tests/DLL_ORB/Test_Client_Module.cpp
index 9deb390c8ee..0408425d5b4 100644
--- a/TAO/tests/DLL_ORB/Test_Client_Module.cpp
+++ b/TAO/tests/DLL_ORB/Test_Client_Module.cpp
@@ -90,7 +90,7 @@ Test_Client_Module::init (int argc, char *argv[])
// Initialize the ORB.
this->orb_ = CORBA::ORB_init (new_argc,
new_argv.get_buffer (),
- ""
+ "CLIENT"
ACE_ENV_ARG_PARAMETER);
ACE_TRY_CHECK;
@@ -142,33 +142,8 @@ Test_Client_Module::init (int argc, char *argv[])
int
Test_Client_Module::fini (void)
{
- ACE_DECLARE_NEW_CORBA_ENV;
- ACE_TRY
- {
- // Make sure the ORB is destroyed.
- if (!CORBA::is_nil (this->orb_.in ()))
- {
- this->orb_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
- ACE_TRY_CHECK;
- }
- }
- ACE_CATCHANY
- {
- ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
- ACE_TEXT ("Test_Client_Module::fini"));
- return -1;
- }
- ACE_ENDTRY;
- ACE_CHECK_RETURN (-1);
-
- // This is a bit of a hack. The ORB Core's lifetime is tied to the
- // lifetime of an object reference. We need to wipe out all object
- // references before we call fini() on the TAO_Singleton_Manager.
- //
- // Note that this is only necessary if the default resource factory
- // is used, i.e. one isn't explicitly loaded prior to initializing
- // the ORB.
- (void) this->test_.out ();
+ ACE_DEBUG ((LM_INFO,
+ "Client is being finalized.\n"));
// ------------------------------------------------------------
// Pre-Test_Client_Module termination steps.
@@ -197,6 +172,31 @@ Test_Client_Module::svc (void)
/// Shutdown the remote ORB.
this->test_->shutdown (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_TRY_CHECK;
+
+ // Make sure the ORB is destroyed here - before the thread
+ // exits, because it may be holding global resources, owned by
+ // the Object Manager (thru its core, which is in turn owned by
+ // the ORB table; which is owned by the Object Manager).
+ // Otherwise the Object Manager will have clobbered them by the
+ // time it gets to destroy the ORB Table, which calls our
+ // fini(). Had we destroyed the ORB in our fini(), its core
+ // fininalization would have required access to those already
+ // deleted resources.
+ if (!CORBA::is_nil (this->orb_.in ()))
+ {
+ this->orb_->destroy (ACE_ENV_SINGLE_ARG_PARAMETER);
+ ACE_TRY_CHECK;
+ }
+
+ // This is a bit of a hack. The ORB Core's lifetime is tied to the
+ // lifetime of an object reference. We need to wipe out all object
+ // references before we call fini() on the TAO_Singleton_Manager.
+ //
+ // Note that this is only necessary if the default resource factory
+ // is used, i.e. one isn't explicitly loaded prior to initializing
+ // the ORB.
+ (void) this->test_.out ();
+
}
ACE_CATCHANY
{