diff options
author | vzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-02-23 09:57:24 +0000 |
---|---|---|
committer | vzykov <vzykov@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 2010-02-23 09:57:24 +0000 |
commit | 18bebcede370ca7a3f4ff81d165120a4ec458911 (patch) | |
tree | 82b5c7dca2e4e78429408c7b9e6cf4353ac6e1ab | |
parent | 5cbc08e3689e38d1a9a8af2e2dbd0404ebe49801 (diff) | |
download | ATCD-18bebcede370ca7a3f4ff81d165120a4ec458911.tar.gz |
Tue Feb 23 09:46:57 UTC 2010 Vladimir Zykov <vladimir.zykov@prismtech.com>
* tests/Bug_3827_Regression/test.cpp:
* tests/Bug_3827_Regression/Message.idl:
* tests/Bug_3827_Regression/run_test.pl:
* tests/Bug_3827_Regression/README:
* tests/Bug_3827_Regression/Bug_3827_Regression.mpc:
* tao/ORB_Core.cpp:
* tao/ORB.cpp:
* tao/ORB_Core.h:
Added a test for bug#3827 and fixed it. Now access or changes to
valuetype_adapter_ in ORB_Core is protected by a lock.
* tests/Bug_3826_Regression/orb_svc.conf:
* tests/Bug_3826_Regression/server.cpp:
* tests/Bug_3826_Regression/README:
* tests/Bug_3826_Regression/Bug_3826_Regression.mpc:
* tests/Bug_3826_Regression/run_test.pl:
* tao/TAO_Internal.cpp:
Added a test for bug#3826 and fixed it. If the first ORB in created
with -ORBGestalt LOCAL it will have a local configuration and this
configuration will not leak into any ORBs created afterwards.
* bin/tao_orb_tests.lst:
Scheduled tests for bug#3826 and bug#3827 to run in the nightly
builds.
-rw-r--r-- | TAO/ChangeLog | 27 | ||||
-rw-r--r-- | TAO/bin/tao_orb_tests.lst | 2 | ||||
-rw-r--r-- | TAO/tao/ORB.cpp | 37 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.cpp | 84 | ||||
-rw-r--r-- | TAO/tao/ORB_Core.h | 15 | ||||
-rw-r--r-- | TAO/tao/TAO_Internal.cpp | 110 | ||||
-rw-r--r-- | TAO/tests/Bug_3826_Regression/Bug_3826_Regression.mpc | 10 | ||||
-rw-r--r-- | TAO/tests/Bug_3826_Regression/README | 27 | ||||
-rw-r--r-- | TAO/tests/Bug_3826_Regression/orb_svc.conf | 3 | ||||
-rwxr-xr-x | TAO/tests/Bug_3826_Regression/run_test.pl | 52 | ||||
-rw-r--r-- | TAO/tests/Bug_3826_Regression/server.cpp | 114 | ||||
-rw-r--r-- | TAO/tests/Bug_3827_Regression/Bug_3827_Regression.mpc | 19 | ||||
-rw-r--r-- | TAO/tests/Bug_3827_Regression/Message.idl | 8 | ||||
-rw-r--r-- | TAO/tests/Bug_3827_Regression/README | 18 | ||||
-rwxr-xr-x | TAO/tests/Bug_3827_Regression/run_test.pl | 30 | ||||
-rw-r--r-- | TAO/tests/Bug_3827_Regression/test.cpp | 122 |
16 files changed, 619 insertions, 59 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog index cfcb189d59f..86d1ca22fbd 100644 --- a/TAO/ChangeLog +++ b/TAO/ChangeLog @@ -1,3 +1,30 @@ +Tue Feb 23 09:46:57 UTC 2010 Vladimir Zykov <vladimir.zykov@prismtech.com> + + * tests/Bug_3827_Regression/test.cpp: + * tests/Bug_3827_Regression/Message.idl: + * tests/Bug_3827_Regression/run_test.pl: + * tests/Bug_3827_Regression/README: + * tests/Bug_3827_Regression/Bug_3827_Regression.mpc: + * tao/ORB_Core.cpp: + * tao/ORB.cpp: + * tao/ORB_Core.h: + Added a test for bug#3827 and fixed it. Now access or changes to + valuetype_adapter_ in ORB_Core is protected by a lock. + + * tests/Bug_3826_Regression/orb_svc.conf: + * tests/Bug_3826_Regression/server.cpp: + * tests/Bug_3826_Regression/README: + * tests/Bug_3826_Regression/Bug_3826_Regression.mpc: + * tests/Bug_3826_Regression/run_test.pl: + * tao/TAO_Internal.cpp: + Added a test for bug#3826 and fixed it. If the first ORB in created + with -ORBGestalt LOCAL it will have a local configuration and this + configuration will not leak into any ORBs created afterwards. + + * bin/tao_orb_tests.lst: + Scheduled tests for bug#3826 and bug#3827 to run in the nightly + builds. + Mon Feb 22 23:04:23 UTC 2010 Yan Dai <dai_y@ociweb.com> diff --git a/TAO/bin/tao_orb_tests.lst b/TAO/bin/tao_orb_tests.lst index ffa5485e5e4..acb06795063 100644 --- a/TAO/bin/tao_orb_tests.lst +++ b/TAO/bin/tao_orb_tests.lst @@ -172,6 +172,8 @@ TAO/tests/Bug_3755_Regression/run_test.pl: !STATIC !CORBA_E_COMPACT !CORBA_E_MIC TAO/tests/Bug_3766_Regression/run_test.pl: TAO/tests/Bug_3790_Regression/run_test.pl: TAO/tests/Bug_3821_Regression/run_test.pl: +TAO/tests/Bug_3826_Regression/run_test.pl: +TAO/tests/Bug_3827_Regression/run_test.pl: 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/tao/ORB.cpp b/TAO/tao/ORB.cpp index 7dca097ea4e..3f9023adf5a 100644 --- a/TAO/tao/ORB.cpp +++ b/TAO/tao/ORB.cpp @@ -1722,25 +1722,9 @@ CORBA::ValueFactory CORBA::ORB::register_value_factory (const char *repository_id, CORBA::ValueFactory factory) { - TAO_Valuetype_Adapter *vta = this->orb_core ()->valuetype_adapter (); - - if (vta) - { - int const result = vta->vf_map_rebind (repository_id, factory); - - if (result == 0) // No previous factory found - { - return 0; - } - - if (result == -1) - { - // Error on bind. - throw ::CORBA::MARSHAL (); - } - } + this->check_shutdown (); - return factory; // previous factory was found + return this->orb_core_->register_value_factory (repository_id, factory); } #endif @@ -1748,13 +1732,9 @@ CORBA::ORB::register_value_factory (const char *repository_id, void CORBA::ORB::unregister_value_factory (const char *repository_id) { - TAO_Valuetype_Adapter *vta = this->orb_core ()->valuetype_adapter (); + this->check_shutdown (); - if (vta) - { - // Dont care whther it was successful or not! - (void) vta->vf_map_unbind (repository_id); - } + this->orb_core_->unregister_value_factory (repository_id); } #endif @@ -1762,14 +1742,9 @@ CORBA::ORB::unregister_value_factory (const char *repository_id) CORBA::ValueFactory CORBA::ORB::lookup_value_factory (const char *repository_id) { - TAO_Valuetype_Adapter *vta = this->orb_core ()->valuetype_adapter (); - - if (vta) - { - return vta->vf_map_find (repository_id); - } + this->check_shutdown (); - return 0; + return this->orb_core_->lookup_value_factory (repository_id); } #endif diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp index a8a2bb42e09..feaa9585a37 100644 --- a/TAO/tao/ORB_Core.cpp +++ b/TAO/tao/ORB_Core.cpp @@ -2307,8 +2307,12 @@ TAO_ORB_Core::shutdown (CORBA::Boolean wait_for_completion) tm->wait (); // Explicitly destroy the valuetype adapter - delete this->valuetype_adapter_; - this->valuetype_adapter_ = 0; + { + ACE_GUARD (TAO_SYNCH_MUTEX, monitor, this->lock_); + + delete this->valuetype_adapter_; + this->valuetype_adapter_ = 0; + } // Explicitly destroy the object reference table since it // contains references to objects, which themselves may contain @@ -3470,6 +3474,82 @@ TAO_ORB_Core::valuetype_adapter (void) return this->valuetype_adapter_; } +// ************************************************************* +// Valuetype factory operations +// ************************************************************* + +#if !defined(CORBA_E_MICRO) +CORBA::ValueFactory +TAO_ORB_Core::register_value_factory (const char *repository_id, + CORBA::ValueFactory factory) +{ + if (this->valuetype_adapter ()) + { + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0); + + if (this->valuetype_adapter_ == 0) + { + return 0; + } + + int const result = + this->valuetype_adapter_->vf_map_rebind (repository_id, factory); + + if (result == 0) // No previous factory found + { + return 0; + } + + if (result == -1) + { + // Error on bind. + throw ::CORBA::MARSHAL (); + } + } + + return factory; // previous factory was found +} +#endif + +#if !defined(CORBA_E_MICRO) +void +TAO_ORB_Core::unregister_value_factory (const char *repository_id) +{ + if (this->valuetype_adapter ()) + { + ACE_GUARD (TAO_SYNCH_MUTEX, ace_mon, this->lock_); + + if (this->valuetype_adapter_ == 0) + { + return; + } + + // Dont care whther it was successful or not! + (void) this->valuetype_adapter_->vf_map_unbind (repository_id); + } +} +#endif + +#if !defined(CORBA_E_MICRO) +CORBA::ValueFactory +TAO_ORB_Core::lookup_value_factory (const char *repository_id) +{ + if (this->valuetype_adapter ()) + { + ACE_GUARD_RETURN (TAO_SYNCH_MUTEX, ace_mon, this->lock_, 0); + + if (this->valuetype_adapter_ == 0) + { + return 0; + } + + return this->valuetype_adapter_->vf_map_find (repository_id); + } + + return 0; +} +#endif + // **************************************************************** TAO_Export TAO_ORB_Core * diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h index 42c2e3b296a..603a5543866 100644 --- a/TAO/tao/ORB_Core.h +++ b/TAO/tao/ORB_Core.h @@ -820,6 +820,21 @@ public: /// Return the valuetype adapter TAO_Valuetype_Adapter *valuetype_adapter (void); +#if !defined(CORBA_E_MICRO) + // Value factory operations (CORBA 2.3 ptc/98-10-05 Ch. 4.2 p.4-7) + CORBA::ValueFactory register_value_factory ( + const char *repository_id, + CORBA::ValueFactory factory); +#endif + +#if !defined(CORBA_E_MICRO) + void unregister_value_factory (const char * repository_id); +#endif + +#if !defined(CORBA_E_MICRO) + CORBA::ValueFactory lookup_value_factory (const char *repository_id); +#endif + /// Get the IOR Interceptor adapter. If not created, this method will try /// to create one. TAO_IORInterceptor_Adapter *ior_interceptor_adapter (void); diff --git a/TAO/tao/TAO_Internal.cpp b/TAO/tao/TAO_Internal.cpp index 32780f0ffb1..309ce2cca1b 100644 --- a/TAO/tao/TAO_Internal.cpp +++ b/TAO/tao/TAO_Internal.cpp @@ -79,10 +79,23 @@ namespace * @brief Modifies the argc to reflect any arguments it has * "consumed" */ - int - parse_svcconf_args_i (int &argc, - ACE_TCHAR **argv, - ACE_ARGV &svc_config_argv); + int parse_svcconf_args_i (int &argc, + ACE_TCHAR **argv, + ACE_ARGV &svc_config_argv); + + /** + * Checks if there is -ORBGestalt option with non-GLOBAL value. + * + * @brief Modifies the argc to reflect any arguments it has + * "consumed" + * + * If the first ORB has some special configuration and uses non + * GLOBAL gestalt then it's expected the this configuration will + * not become default for other ORBs created after it. This function + * allows to avoid the above situation. + */ + bool using_global_gestalt_i (int &argc, + ACE_TCHAR **argv); /** * Initialize the ACE Service Configurator with the process-global @@ -111,11 +124,10 @@ namespace * @brief Modifies the argc to reflect any arguments it has * "consumed" */ - int - parse_private_args_i (int &argc, - ACE_TCHAR **argv, - ACE_ARGV & svc_config_argv, - bool & skip_service_config_open); + int parse_private_args_i (int &argc, + ACE_TCHAR **argv, + ACE_ARGV & svc_config_argv, + bool & skip_service_config_open); /** * Initialize ORB-local (private) ACE Service Configurator @@ -268,12 +280,16 @@ TAO::ORB::open_global_services (int argc, ACE_TCHAR **argv) true) == -1) return -1; - bool skip_service_config_open = false; // by default we shouldn't + if (using_global_gestalt_i (tmpargc, + tmpargv)) + { + if (parse_svcconf_args_i (tmpargc, + tmpargv, + global_svc_config_argv) == -1) + return -1; + } - if (parse_svcconf_args_i (tmpargc, - tmpargv, - global_svc_config_argv) == -1) - return -1; + bool skip_service_config_open = false; // by default we shouldn't if (parse_private_args_i (tmpargc, tmpargv, @@ -769,6 +785,21 @@ namespace svc_config_argv.add (ACE_TEXT ("-f")); svc_config_argv.add (current_arg, true); } + else if (arg_shifter.cur_arg_strncasecmp + (ACE_TEXT ("-ORBSvcConfDirective")) == 0) + { + const ACE_TCHAR *current_arg = + arg_shifter.get_the_parameter (ACE_TEXT ("-ORBSvcConfDirective")); + + // This is used to pass arguments to the Service + // Configurator using the "command line" to provide + // configuration information rather than using a svc.conf + // file. Pass the "-S" to the service configurator. + svc_config_argv.add (ACE_TEXT ("-S")); + svc_config_argv.add (current_arg, true); // quote args! + + arg_shifter.consume_arg (); + } else { // Any arguments that don't match are ignored so that the @@ -801,18 +832,6 @@ namespace arg_shifter.consume_arg (); } else if (0 != (current_arg = arg_shifter.get_the_parameter - (ACE_TEXT ("-ORBSvcConfDirective")))) - { - // This is used to pass arguments to the Service - // Configurator using the "command line" to provide - // configuration information rather than using a svc.conf - // file. Pass the "-S" to the service configurator. - svc_config_argv.add (ACE_TEXT ("-S")); - svc_config_argv.add (current_arg, true); // quote args! - - arg_shifter.consume_arg (); - } - else if (0 != (current_arg = arg_shifter.get_the_parameter (ACE_TEXT ("-ORBServiceConfigLoggerKey")))) { svc_config_argv.add (ACE_TEXT ("-k")); @@ -927,4 +946,43 @@ namespace } return 0; } /* parse_global_args_i */ + + bool + using_global_gestalt_i (int &argc, + ACE_TCHAR **argv) + { + bool with_global_gestalt = true; + + ACE_Arg_Shifter arg_shifter (argc, argv); + + while (arg_shifter.is_anything_left ()) + { + if (0 == arg_shifter.cur_arg_strncasecmp (ACE_TEXT ("-ORBGestalt"))) + { + // Skip -ORBGestalt. This option is necessary in later stages. + arg_shifter.ignore_arg (); + + // This should set current_arg to the value of ORBGestalt option. + const ACE_TCHAR *current_arg = arg_shifter.get_current (); + + if (0 != current_arg && + ACE_OS::strcasecmp (current_arg, ACE_TEXT("GLOBAL")) != 0) + { + with_global_gestalt = false; + } + + // Skip anything that goes after -ORBGestalt. + arg_shifter.ignore_arg (); + } + // Can't interpret this argument. + // Move on to the next argument. + else + { + // Any arguments that don't match are ignored so + // that the caller can still use them. + arg_shifter.ignore_arg (); + } + } + return with_global_gestalt; + } /* using_global_gestalt_i */ } // anonymous namespace. diff --git a/TAO/tests/Bug_3826_Regression/Bug_3826_Regression.mpc b/TAO/tests/Bug_3826_Regression/Bug_3826_Regression.mpc new file mode 100644 index 00000000000..ab00104856d --- /dev/null +++ b/TAO/tests/Bug_3826_Regression/Bug_3826_Regression.mpc @@ -0,0 +1,10 @@ +// -*- MPC -*- +// $Id$ + +project(*Server) : taoexe { + exename=server + + Source_Files { + server.cpp + } +} diff --git a/TAO/tests/Bug_3826_Regression/README b/TAO/tests/Bug_3826_Regression/README new file mode 100644 index 00000000000..63740e99086 --- /dev/null +++ b/TAO/tests/Bug_3826_Regression/README @@ -0,0 +1,27 @@ +// $Id$ + +This test checks that if the first ORB is created with -ORBGestalt LOCAL +then the settings from this ORB will not become default for the other ORBs +created afterwards. + +_Success_ + +$> ./run_test.pl +Testing with -ORBSvcConf +Initialize ORB instances... +After ORB_init... +'-ORBConnectionCacheMax' is applied to the first ORB only as expected. +Testing with -ORBSvcConfDirective +Initialize ORB instances... +After ORB_init... +'-ORBConnectionCacheMax' is applied to the first ORB only as expected. + +_Regression_ + +$> ./run_test.pl +Testing with -ORBSvcConf +Initialize ORB instances... +After ORB_init... +ERROR: '-ORBConnectionCacheMax' is applied globally while it's expected to apply to the first ORB only. +ERROR: <server> failed: +ERROR: server returned 255 diff --git a/TAO/tests/Bug_3826_Regression/orb_svc.conf b/TAO/tests/Bug_3826_Regression/orb_svc.conf new file mode 100644 index 00000000000..7288e7d425b --- /dev/null +++ b/TAO/tests/Bug_3826_Regression/orb_svc.conf @@ -0,0 +1,3 @@ +# $Id$ + +static Resource_Factory "-ORBConnectionCacheMax 1" diff --git a/TAO/tests/Bug_3826_Regression/run_test.pl b/TAO/tests/Bug_3826_Regression/run_test.pl new file mode 100755 index 00000000000..f203124b39e --- /dev/null +++ b/TAO/tests/Bug_3826_Regression/run_test.pl @@ -0,0 +1,52 @@ +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 $svc_conf = "orb_svc.conf"; +my $server_svc_conf = $server->LocalFile ($svc_conf); + +print STDOUT "Testing with -ORBSvcConf\n"; + +$SV = $server->CreateProcess ("server", + "-a \"AAA -ORBdebuglevel $debug_level -ORBSvcConf $server_svc_conf -ORBGestalt LOCAL\" " . + "-b \"BBB\""); + +$server_status = $SV->SpawnWaitKill ($server->ProcessStartWaitInterval()); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + exit 1; +} + +print STDOUT "Testing with -ORBSvcConfDirective\n"; + +$SV = $server->CreateProcess ("server", + "-a \"AAA -ORBdebuglevel $debug_level -ORBGestalt LOCAL " . + "-ORBSvcConfDirective \\\"static Resource_Factory \\\\\\\"-ORBConnectionCacheMax 1\\\\\\\"\\\"\" " . + "-b \"BBB\""); + +$server_status = $SV->SpawnWaitKill ($server->ProcessStartWaitInterval()); + +if ($server_status != 0) { + print STDERR "ERROR: server returned $server_status\n"; + exit 1; +} + +exit $status; diff --git a/TAO/tests/Bug_3826_Regression/server.cpp b/TAO/tests/Bug_3826_Regression/server.cpp new file mode 100644 index 00000000000..93600fc53d2 --- /dev/null +++ b/TAO/tests/Bug_3826_Regression/server.cpp @@ -0,0 +1,114 @@ +// $Id$ + +#include "ace/Get_Opt.h" +#include "ace/ARGV.h" +#include "tao/ORB.h" +#include "tao/ORB_Core.h" +#include "tao/Resource_Factory.h" + +ACE_TCHAR const *orb1_args = + ACE_TEXT ("AAA -ORBGestalt LOCAL -ORBSvcConf MY_TEST_ORB_1.conf"); +ACE_TCHAR const *orb2_args = + ACE_TEXT ("BBB"); + +int +parse_args (int argc, ACE_TCHAR *argv[]) +{ + ACE_Get_Opt get_opts (argc, argv, ACE_TEXT ("a:b:")); + int c; + + while ((c = get_opts ()) != -1) + switch (c) + { + case 'a': + orb1_args = get_opts.opt_arg (); + break; + case 'b': + orb2_args = get_opts.opt_arg (); + break; + case '?': + default: + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("usage: %s") + ACE_TEXT (" -a <orb1_args>") + ACE_TEXT (" -b <orb2_args>") + ACE_TEXT ("\n"), + argv [0]), + -1); + } + // Indicates sucessful parsing of the command line + return 0; +} + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + try + { + if (parse_args (argc, argv) != 0) + { + return 1; + } + + ACE_ARGV orb1_argv (orb1_args); + int orb1_argc = orb1_argv.argc (); + + ACE_ARGV orb2_argv (orb2_args); + int orb2_argc = orb2_argv.argc (); + + ACE_DEBUG ((LM_DEBUG, + "Initialize ORB instances...\n")); + + CORBA::ORB_var orb1 = + CORBA::ORB_init (orb1_argc, orb1_argv.argv (), "AAA"); + + CORBA::ORB_var orb2 = + CORBA::ORB_init (orb2_argc, orb2_argv.argv (), "BBB"); + + ACE_DEBUG ((LM_DEBUG, + "After ORB_init...\n")); + + TAO_Resource_Factory *trf1 = orb1->orb_core ()->resource_factory (); + + if (trf1 == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ERROR: Can not resolve ") + ACE_TEXT ("Resource Factory for orb1.\n")), + -1); + } + + TAO_Resource_Factory *trf2 = orb2->orb_core ()->resource_factory (); + + if (trf2 == 0) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ERROR: Can not resolve ") + ACE_TEXT ("Resource Factory for orb2.\n")), + -1); + } + + if (trf1->cache_maximum () == trf2->cache_maximum ()) + { + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("ERROR: '-ORBConnectionCacheMax' is ") + ACE_TEXT ("applied globally while it's expected ") + ACE_TEXT ("to apply to the first ORB only.\n")), + -1); + } + + orb1->destroy (); + orb2->destroy (); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("'-ORBConnectionCacheMax' is applied to the first ") + ACE_TEXT ("ORB only as expected.\n"))); + } + catch (CORBA::Exception const &ex) + { + ex._tao_print_exception ("Caught Exception in main:\n"); + return 1; + } + + return 0; +} diff --git a/TAO/tests/Bug_3827_Regression/Bug_3827_Regression.mpc b/TAO/tests/Bug_3827_Regression/Bug_3827_Regression.mpc new file mode 100644 index 00000000000..e289841bc90 --- /dev/null +++ b/TAO/tests/Bug_3827_Regression/Bug_3827_Regression.mpc @@ -0,0 +1,19 @@ +// -*- MPC -*- +// $Id$ + +project(*IDL): taoidldefaults, anytypecode { + IDL_Files { + Message.idl + } + custom_only = 1 +} + +project (*test) : taoexe, valuetype { + after += *IDL + exename = test + + Source_Files { + MessageC.cpp + test.cpp + } +} diff --git a/TAO/tests/Bug_3827_Regression/Message.idl b/TAO/tests/Bug_3827_Regression/Message.idl new file mode 100644 index 00000000000..848d48e50a4 --- /dev/null +++ b/TAO/tests/Bug_3827_Regression/Message.idl @@ -0,0 +1,8 @@ +// $Id$ + +valuetype Message +{ + public string user; + public string subject; + public string text; +}; diff --git a/TAO/tests/Bug_3827_Regression/README b/TAO/tests/Bug_3827_Regression/README new file mode 100644 index 00000000000..1c4b36b791b --- /dev/null +++ b/TAO/tests/Bug_3827_Regression/README @@ -0,0 +1,18 @@ +// $Id$ + +Valuetype factory related operations from different threads +after orb was just shutdown could result in SIGSEGV. + +_Expected Success Output_ +$> ./run_test.pl +(29829|140197396228368) Event loop started +(29829|140197437130512) Shutting down / destroying ORB +(29829|140197396228368) Event loop finished + +_Expected Regression Output_ +$> ./run_test.pl +(751|139948587792656) Event loop started +(751|139948628694800) Shutting down / destroying ORB +(751|139948587792656) Event loop finished +ERROR: <test> exited with signal 11 : SEGV +ERROR: server returned 255 diff --git a/TAO/tests/Bug_3827_Regression/run_test.pl b/TAO/tests/Bug_3827_Regression/run_test.pl new file mode 100755 index 00000000000..6134ec898b3 --- /dev/null +++ b/TAO/tests/Bug_3827_Regression/run_test.pl @@ -0,0 +1,30 @@ +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 $test = PerlACE::TestTarget::create_target (1) || die "Create target 1 failed\n"; + +$SV = $test->CreateProcess ("test"); +$test_status = $SV->SpawnWaitKill ($test->ProcessStartWaitInterval()); + +if ($test_status != 0) { + print STDERR "ERROR: test returned $test_status\n"; + exit 1; +} + +exit $status; diff --git a/TAO/tests/Bug_3827_Regression/test.cpp b/TAO/tests/Bug_3827_Regression/test.cpp new file mode 100644 index 00000000000..22259070653 --- /dev/null +++ b/TAO/tests/Bug_3827_Regression/test.cpp @@ -0,0 +1,122 @@ +// $Id$ + +#include "MessageC.h" +#include "ace/Task.h" +#include "ace/OS_NS_unistd.h" + +int status = 0; + +class ORB_Task : public ACE_Task_Base +{ +public: + ORB_Task (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) + { + } + + virtual int svc (void) + { + try + { + ACE_DEBUG ((LM_DEBUG, "(%P|%t) Event loop started\n")); + this->orb_->run (); + ACE_DEBUG ((LM_DEBUG, "(%P|%t) Event loop finished\n")); + } + catch (const CORBA::Exception& ) + { + } + return 0; + } + +private: + CORBA::ORB_var orb_; +}; + +class Worker_Task : public ACE_Task_Base +{ +public: + Worker_Task (CORBA::ORB_ptr orb) + : orb_ (CORBA::ORB::_duplicate (orb)) + { + } + + virtual int svc (void) + { + try + { + Message_init *mi = new Message_init (); + CORBA::ValueFactoryBase_var safe (mi); + + while (1) + { + CORBA::ValueFactoryBase_var tmp1 = + this->orb_->register_value_factory (mi->tao_repository_id (), mi); + + CORBA::ValueFactoryBase_var tmp2 = + this->orb_->lookup_value_factory (mi->tao_repository_id ()); + + this->orb_->unregister_value_factory (mi->tao_repository_id ()); + } + } + catch (const CORBA::BAD_INV_ORDER&) + { + // It's ok to ignore BAD_INV_ORDER which can be thrown after orb + // is shutdown from other thread. + } + catch (const CORBA::Exception&) + { + ACE_ERROR ((LM_ERROR, + ACE_TEXT ("ERROR: Unexpected exception.\n"))); + status = 1; + } + return 0; + } + +private: + CORBA::ORB_var orb_; +}; + +int +ACE_TMAIN (int argc, ACE_TCHAR *argv[]) +{ + try + { + CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); + + ORB_Task orb_runner (orb.in ()); + if (orb_runner.activate (THR_NEW_LWP | THR_JOINABLE, 1) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "ERROR: Can not start ORB thread\n"), + -1); + } + + ACE_OS::sleep (1); + + Worker_Task work_runner (orb.in ()); + if (work_runner.activate (THR_NEW_LWP | THR_JOINABLE, 10) == -1) + { + ACE_ERROR_RETURN ((LM_ERROR, + "ERROR: Can not start work threads\n"), + -1); + } + + ACE_OS::sleep (1); + + ACE_DEBUG ((LM_DEBUG, + ACE_TEXT ("(%P|%t) Shutting down / destroying ORB\n"))); + + orb->shutdown (false); + + ACE_Thread_Manager::instance ()->wait (); + + orb->destroy (); + } + catch (const CORBA::Exception& ex) + { + ex._tao_print_exception ("Exception caught:"); + return 1; + } + + return status; +} |