diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2006-02-03 23:19:11 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2006-02-03 23:19:11 +0000 |
commit | b924bef4e6f95dc800b865e823ddc11f7e538602 (patch) | |
tree | 8e5e0bef4c0c5368ce6ce22d5ca41914c88e215a | |
parent | d1267c36c3911a768871fed5f3694576ebddeace (diff) | |
download | ATCD-b924bef4e6f95dc800b865e823ddc11f7e538602.tar.gz |
ChangeLogTag:Fri Feb 3 15:16:41 UTC 2006 Ossama Othman <ossama_othman at symantec dot com>
-rw-r--r-- | TAO/ChangeLog | 11 | ||||
-rw-r--r-- | TAO/tests/Hang_Shutdown/Test.idl | 16 | ||||
-rw-r--r-- | TAO/tests/Hang_Shutdown/client.cpp | 407 | ||||
-rw-r--r-- | TAO/tests/Hang_Shutdown/server.cpp | 177 | ||||
-rw-r--r-- | TAO/tests/Hang_Shutdown/test_i.h | 45 |
5 files changed, 328 insertions, 328 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index 87624c3b74e..946b394ecc2 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,14 @@ +Fri Feb 3 15:16:41 UTC 2006 Ossama Othman <ossama_othman at symantec dot com> + + * tests/Hang_Shutdown/Test.idl: + * tests/Hang_Shutdown/client.cpp: + * tests/Hang_Shutdown/server.cpp: + * tests/Hang_Shutdown/test_i.h: + + Removed outer "TAO" namespace. It served no useful purpose, and + conflicted with the versioned TAO namespace used in the core TAO + libraries. + Thu Feb 3 14:54:51 UTC 2006 Ossama Othman <ossama_othman at symantec dot com> * be/be_visitor_valuebox/valuebox_ci.cpp: diff --git a/TAO/tests/Hang_Shutdown/Test.idl b/TAO/tests/Hang_Shutdown/Test.idl index bef07d739ae..0ea5055f05a 100644 --- a/TAO/tests/Hang_Shutdown/Test.idl +++ b/TAO/tests/Hang_Shutdown/Test.idl @@ -1,13 +1,11 @@ // $Id$ -module TAO +module Test { - module Test - { - interface Hang - { - void send_stuff (in string foo, - in boolean flag); - }; - }; + interface Hang + { + void send_stuff (in string foo, + in boolean flag); + }; }; + diff --git a/TAO/tests/Hang_Shutdown/client.cpp b/TAO/tests/Hang_Shutdown/client.cpp index a3cc6350e74..066461f895a 100644 --- a/TAO/tests/Hang_Shutdown/client.cpp +++ b/TAO/tests/Hang_Shutdown/client.cpp @@ -8,265 +8,260 @@ ACE_RCSID(Hello, client, "$Id$") - - -namespace TAO +namespace Test { - namespace Test - { - const char *ior = "file://server.ior"; - - ACE_Profile_Timer profile_timer; - bool blocked = false; - - bool - parse_args (int argc, char *argv[]) - { - ACE_Get_Opt get_opts (argc, argv, "b:k:"); - int c; - - while ((c = get_opts ()) != -1) - switch (c) - { - case 'b': - { - int tmp = - ACE_OS::atoi (get_opts.opt_arg ()); - - if (tmp) - blocked = true; - else - blocked = false; - } - break; - case 'k': - { - ior = get_opts.opt_arg (); - } - break; - case '?': - default: - ACE_ERROR_RETURN ((LM_ERROR, - "usage: %s " - "-k <ior> " - "\n", - argv [0]), - false); - } + const char *ior = "file://server.ior"; - // Indicates sucessful parsing of the command line - return true; - } + ACE_Profile_Timer profile_timer; + bool blocked = false; - class Client_Task : public ACE_Task_Base - { - public: - Client_Task (Hang_ptr h) - : h_ (Hang::_duplicate (h)) - {} - - virtual int svc (void) - { - ACE_DECLARE_NEW_CORBA_ENV; - - ACE_TRY - { - this->h_->send_stuff ("Testing", - false - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - this->h_->send_stuff ("Testing", - false - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - this->h_->send_stuff ("Testing", - true - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - } - ACE_CATCH (CORBA::COMM_FAILURE, f) - { - ACE_UNUSED_ARG (f); - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) Caught COMM_FAILURE Exception \n")); - - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) This is expected \n")); + bool + parse_args (int argc, char *argv[]) + { + ACE_Get_Opt get_opts (argc, argv, "b:k:"); + int c; - return 0; - } - ACE_CATCH (CORBA::Exception, ex) + while ((c = get_opts ()) != -1) + switch (c) + { + case 'b': { - ex._tao_print_exception ("Caught CORBA Exception \n"); + int tmp = + ACE_OS::atoi (get_opts.opt_arg ()); - ACE_ERROR ((LM_ERROR, - "(%P|%t) Error in test \n")); - - return -1; + if (tmp) + blocked = true; + else + blocked = false; } - ACE_CATCHALL + break; + case 'k': { - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) Caught a C++ exception \n")); - ACE_ERROR ((LM_ERROR, - "(%P|%t) Error in test \n")); - - return -1; + ior = get_opts.opt_arg (); } - ACE_ENDTRY; + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + "usage: %s " + "-k <ior> " + "\n", + argv [0]), + false); + } - return 0; - } + // Indicates sucessful parsing of the command line + return true; + } - private: - Hang_var h_; - }; + class Client_Task : public ACE_Task_Base + { + public: + Client_Task (Hang_ptr h) + : h_ (Hang::_duplicate (h)) + {} - class Shutdown_Task : public ACE_Task_Base + virtual int svc (void) { - public: - Shutdown_Task (CORBA::ORB_ptr o) - : o_ (CORBA::ORB::_duplicate (o)) - {} + ACE_DECLARE_NEW_CORBA_ENV; - virtual int svc (void) - { - ACE_DECLARE_NEW_CORBA_ENV; + ACE_TRY + { + this->h_->send_stuff ("Testing", + false + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - ACE_TRY - { - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) Calling shutdown \n")); + this->h_->send_stuff ("Testing", + false + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; - // Just wait for the main thread to start sening out - // messages - ACE_OS::sleep (4); + this->h_->send_stuff ("Testing", + true + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + } + ACE_CATCH (CORBA::COMM_FAILURE, f) + { + ACE_UNUSED_ARG (f); + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Caught COMM_FAILURE Exception \n")); - // Start the timer - profile_timer.start (); + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) This is expected \n")); - this->o_->shutdown (blocked - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + return 0; + } + ACE_CATCH (CORBA::Exception, ex) + { + ex._tao_print_exception ("Caught CORBA Exception \n"); - // Stop the timer - profile_timer.stop (); + ACE_ERROR ((LM_ERROR, + "(%P|%t) Error in test \n")); - // Get the elampsed time - ACE_Profile_Timer::ACE_Elapsed_Time el; - profile_timer.elapsed_time (el); + return -1; + } + ACE_CATCHALL + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Caught a C++ exception \n")); + ACE_ERROR ((LM_ERROR, + "(%P|%t) Error in test \n")); - // The elapsed time is in secs - if (el.real_time > 1) - { - ACE_ERROR ((LM_ERROR, - "(%P|%t) ERROR: Too long to shutdown \n")); + return -1; + } + ACE_ENDTRY; - return 0; - } - } - ACE_CATCHALL - { - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) Caught exception during shutdown \n")); + return 0; + } - ACE_ERROR ((LM_ERROR, - "(%P|%t) Error in test \n")); - return -1; - } - ACE_ENDTRY; + private: + Hang_var h_; + }; - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) Returning from shutdown \n")); - return 0; - } - private: - CORBA::ORB_var o_; - }; + class Shutdown_Task : public ACE_Task_Base + { + public: + Shutdown_Task (CORBA::ORB_ptr o) + : o_ (CORBA::ORB::_duplicate (o)) + {} - static int - try_main (int argc, char *argv[]) + virtual int svc (void) { ACE_DECLARE_NEW_CORBA_ENV; ACE_TRY { - CORBA::ORB_var orb = - CORBA::ORB_init (argc, - argv, - "" - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Calling shutdown \n")); - if (parse_args (argc, argv) == false) - return -1; + // Just wait for the main thread to start sening out + // messages + ACE_OS::sleep (4); - CORBA::Object_var tmp = - orb->string_to_object (ior - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; + // Start the timer + profile_timer.start (); - Hang_var test = - Hang::_narrow (tmp.in () - ACE_ENV_ARG_PARAMETER); + this->o_->shutdown (blocked + ACE_ENV_ARG_PARAMETER); ACE_TRY_CHECK; - if (CORBA::is_nil (test.in ())) - { - ACE_ERROR_RETURN ((LM_DEBUG, - "Nil test reference <%s>\n", - ior), - 1); - } + // Stop the timer + profile_timer.stop (); - Client_Task ct (test.in ()); + // Get the elampsed time + ACE_Profile_Timer::ACE_Elapsed_Time el; + profile_timer.elapsed_time (el); - if (ct.activate (THR_NEW_LWP | THR_JOINABLE, 1) != 0) - ACE_ERROR_RETURN ((LM_ERROR, - "Cannot activate client threads\n"), - 1); - - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) Activating shutdown thread \n")); - - Shutdown_Task st (orb.in ()); - - if (st.activate (THR_NEW_LWP | THR_JOINABLE, 1) != 0) - ACE_ERROR_RETURN ((LM_ERROR, - "Cannot activate shutdown threads\n"), - 1); - - ACE_Thread_Manager::instance ()->wait (); - - orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; + // The elapsed time is in secs + if (el.real_time > 1) + { + ACE_ERROR ((LM_ERROR, + "(%P|%t) ERROR: Too long to shutdown \n")); - } - ACE_CATCHANY - { - ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, - "CORBA Exception caught \n"); - ACE_ERROR ((LM_ERROR, - "(%P|%t) Eror in test \n")); - return -1; + return 0; + } } ACE_CATCHALL { ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Caught exception during shutdown \n")); + + ACE_ERROR ((LM_ERROR, "(%P|%t) Error in test \n")); return -1; } ACE_ENDTRY; + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Returning from shutdown \n")); return 0; } + private: + CORBA::ORB_var o_; + }; + + static int + try_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; + + if (parse_args (argc, argv) == false) + return -1; + + CORBA::Object_var tmp = + orb->string_to_object (ior + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + Hang_var test = + Hang::_narrow (tmp.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + if (CORBA::is_nil (test.in ())) + { + ACE_ERROR_RETURN ((LM_DEBUG, + "Nil test reference <%s>\n", + ior), + 1); + } + + Client_Task ct (test.in ()); + + if (ct.activate (THR_NEW_LWP | THR_JOINABLE, 1) != 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot activate client threads\n"), + 1); + + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Activating shutdown thread \n")); + + Shutdown_Task st (orb.in ()); + + if (st.activate (THR_NEW_LWP | THR_JOINABLE, 1) != 0) + ACE_ERROR_RETURN ((LM_ERROR, + "Cannot activate shutdown threads\n"), + 1); + + ACE_Thread_Manager::instance ()->wait (); + + orb->destroy (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + } + ACE_CATCHANY + { + ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, + "CORBA Exception caught \n"); + ACE_ERROR ((LM_ERROR, + "(%P|%t) Eror in test \n")); + return -1; + } + ACE_CATCHALL + { + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) Error in test \n")); + return -1; + } + ACE_ENDTRY; + + return 0; } } int main (int argc, char *argv[]) { - return TAO::Test::try_main (argc, argv); + return Test::try_main (argc, argv); } diff --git a/TAO/tests/Hang_Shutdown/server.cpp b/TAO/tests/Hang_Shutdown/server.cpp index 136cbf249df..4f17562b879 100644 --- a/TAO/tests/Hang_Shutdown/server.cpp +++ b/TAO/tests/Hang_Shutdown/server.cpp @@ -4,102 +4,101 @@ #include "ace/Get_Opt.h" #include "ace/OS_NS_stdio.h" -namespace TAO +namespace Test { - namespace Test + const char *ior_output_file = "server.ior"; + + static int + try_main (int argc, + char *argv[]) { - const char *ior_output_file = "server.ior"; - - static int - try_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; - - 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_DECLARE_NEW_CORBA_ENV; + + ACE_TRY + { + 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; - - 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 (); - - test_i *test_impl; - ACE_NEW_RETURN (test_impl, - test_i (), - 1); - PortableServer::ServantBase_var owner_transfer (test_impl); - - Hang_var test = - test_impl->_this (); - - CORBA::String_var ior = - orb->object_to_string (test.in () - ACE_ENV_ARG_PARAMETER); - ACE_TRY_CHECK; - - // If the ior_output_file exists, output the ior to it - 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); - - poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); - ACE_TRY_CHECK; - - ACE_Time_Value tv (10); - - orb->run (&tv); - - 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, - "Caught CORBA exception \n"); - return -1; - } - ACE_ENDTRY; - - return 0; - } + 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; + + test_i *test_impl; + ACE_NEW_RETURN (test_impl, + test_i (), + 1); + PortableServer::ServantBase_var owner_transfer (test_impl); + + Hang_var test = + test_impl->_this (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + CORBA::String_var ior = + orb->object_to_string (test.in () + ACE_ENV_ARG_PARAMETER); + ACE_TRY_CHECK; + + // If the ior_output_file exists, output the ior to it + 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); + + poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER); + ACE_TRY_CHECK; + + ACE_Time_Value tv (10); + + orb->run (&tv); + + 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, + "Caught CORBA exception \n"); + return -1; + } + ACE_ENDTRY; + + return 0; } } int main (int argc, char *argv[]) { - return TAO::Test::try_main (argc, argv); + return Test::try_main (argc, argv); } diff --git a/TAO/tests/Hang_Shutdown/test_i.h b/TAO/tests/Hang_Shutdown/test_i.h index 1368f3c36c8..28f6ef82e23 100644 --- a/TAO/tests/Hang_Shutdown/test_i.h +++ b/TAO/tests/Hang_Shutdown/test_i.h @@ -9,36 +9,33 @@ #include "ace/OS_NS_unistd.h" -namespace TAO +namespace Test { - namespace Test + class test_i + : public virtual POA_Test::Hang { - class test_i - : public virtual POA_TAO::Test::Hang + public: + // = The skeleton methods + virtual void send_stuff (const char* str, + CORBA::Boolean flag + ACE_ENV_ARG_DECL_NOT_USED) + ACE_THROW_SPEC ((CORBA::SystemException)) { - public: - // = The skeleton methods - virtual void send_stuff (const char* str, - CORBA::Boolean flag - ACE_ENV_ARG_DECL_NOT_USED) - ACE_THROW_SPEC ((CORBA::SystemException)) - { - ACE_DEBUG ((LM_DEBUG, - "(%P|%t) - [%C]\n", str)); + ACE_DEBUG ((LM_DEBUG, + "(%P|%t) - [%C]\n", str)); - if (flag) - { - ACE_OS::sleep (10); + if (flag) + { + ACE_OS::sleep (10); - ACE_DEBUG ((LM_DEBUG, - "TAO (%P|%t) - Returning from send_stuff\n", str)); - } + ACE_DEBUG ((LM_DEBUG, + "TAO (%P|%t) - Returning from send_stuff\n", str)); + } - return; - } - private: - }; - } + return; + } + private: + }; } #include /**/ "ace/post.h" |