summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2009-04-21 09:27:29 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2009-04-21 09:27:29 +0000
commit370fe14393c4a752fd20c88fc8c861ba8069b69a (patch)
treecdac05420172edb10e57d142c7ebdca0482ce6e4
parent15301dd093c323c8a78da0dfbdc8d65268d2189c (diff)
downloadATCD-370fe14393c4a752fd20c88fc8c861ba8069b69a.tar.gz
-rw-r--r--TAO/ChangeLog5
-rw-r--r--TAO/tests/RTCORBA/Bug_3643_Regression/Bug_3643_Regression.mpc37
-rw-r--r--TAO/tests/RTCORBA/Bug_3643_Regression/client.cpp245
-rwxr-xr-xTAO/tests/RTCORBA/Bug_3643_Regression/run_test.pl115
-rw-r--r--TAO/tests/RTCORBA/Bug_3643_Regression/server.cpp354
-rw-r--r--TAO/tests/RTCORBA/Bug_3643_Regression/svc.conf.dynamic1
-rw-r--r--TAO/tests/RTCORBA/Bug_3643_Regression/test.idl12
-rw-r--r--TAO/tests/RTCORBA/Bug_3643_Regression/test_i.cpp68
-rw-r--r--TAO/tests/RTCORBA/Bug_3643_Regression/test_i.h42
9 files changed, 879 insertions, 0 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index fc29d1e55a9..4e69bbd2951 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,8 @@
+Tue Apr 21 10:17:06 UTC 2009 Johnny Willemsen <jwillemsen@remedy.nl>
+
+ * tests/RTCORBA/Bug_3643_Regression/*:
+ New regression test
+
Tue Apr 21 09:52:06 UTC 2009 Johnny Willemsen <jwillemsen@remedy.nl>
* utils/nslist/nslist.cpp:
diff --git a/TAO/tests/RTCORBA/Bug_3643_Regression/Bug_3643_Regression.mpc b/TAO/tests/RTCORBA/Bug_3643_Regression/Bug_3643_Regression.mpc
new file mode 100644
index 00000000000..fd607f158e1
--- /dev/null
+++ b/TAO/tests/RTCORBA/Bug_3643_Regression/Bug_3643_Regression.mpc
@@ -0,0 +1,37 @@
+// -*- MPC -*-
+// $Id$
+
+project(*idl): taoidldefaults {
+ idlflags += -Sp
+ IDL_Files {
+ test.idl
+ }
+ custom_only = 1
+}
+
+project(*Server): rt_server {
+ after += *idl
+ Source_Files {
+ test_i.cpp
+ server.cpp
+ }
+ Source_Files {
+ testC.cpp
+ testS.cpp
+ }
+ IDL_Files {
+ }
+}
+
+project(*Client): rt_client {
+ after += *idl
+ Source_Files {
+ client.cpp
+ }
+ Source_Files {
+ testC.cpp
+ }
+ IDL_Files {
+ }
+}
+
diff --git a/TAO/tests/RTCORBA/Bug_3643_Regression/client.cpp b/TAO/tests/RTCORBA/Bug_3643_Regression/client.cpp
new file mode 100644
index 00000000000..a6565a33595
--- /dev/null
+++ b/TAO/tests/RTCORBA/Bug_3643_Regression/client.cpp
@@ -0,0 +1,245 @@
+// $Id$
+
+#include "ace/Get_Opt.h"
+#include "testC.h"
+#include "tao/RTCORBA/RTCORBA.h"
+#include "tao/ORB_Core.h"
+#include "ace/Task.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_time.h"
+
+ACE_RCSID(Thread_Pool, client, "$Id$")
+
+const char *ior = "file://ior_1";
+int iterations = 1000;
+int shutdown_server = 0;
+bool decreased = false;
+
+const char *
+sched_policy_name (int sched_policy)
+{
+ const char *name = 0;
+
+ switch (sched_policy)
+ {
+ case ACE_SCHED_OTHER:
+ name = "SCHED_OTHER";
+ break;
+ case ACE_SCHED_RR:
+ name = "SCHED_RR";
+ break;
+ case ACE_SCHED_FIFO:
+ name = "SCHED_FIFO";
+ break;
+ }
+
+ return name;
+}
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "xk:i:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'x':
+ shutdown_server = 1;
+ break;
+
+ case 'k':
+ ior = get_opts.opt_arg ();
+ break;
+
+ case 'i':
+ iterations = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-k <ior> "
+ "-i <iterations> "
+ "-x [shutdown server] "
+ "\n",
+ argv [0]),
+ -1);
+ }
+
+ // Indicates sucessful parsing of the command line
+ return 0;
+}
+
+class Task : public ACE_Task_Base
+{
+public:
+
+ Task (ACE_Thread_Manager &thread_manager,
+ CORBA::ORB_ptr orb);
+
+ int svc (void);
+
+ CORBA::ORB_var orb_;
+
+};
+
+Task::Task (ACE_Thread_Manager &thread_manager,
+ CORBA::ORB_ptr orb)
+ : ACE_Task_Base (&thread_manager),
+ orb_ (CORBA::ORB::_duplicate (orb))
+{
+}
+
+int
+Task::svc (void)
+{
+ try
+ {
+ CORBA::Object_var object =
+ this->orb_->string_to_object (ior);
+
+ test_var test =
+ test::_narrow (object.in ());
+
+ pid_t pid =
+ ACE_OS::getpid ();
+
+ CORBA::Long tc = 0;
+
+ struct timespec millis;
+ millis.tv_sec = 0L;
+ millis.tv_nsec = 50 * 1000000L; // 1e6 nanos per milli
+
+ ACE_hrtime_t start = ACE_OS::gethrtime();
+
+ for (int i = 0; i != iterations; ++i)
+ {
+ // ~20 req/sec means to sleep 50 millis between each
+ ACE_OS::nanosleep(&millis); // ignore signals
+
+ CORBA::Long mtc = 0;
+ CORBA::Long r =
+ test->method (pid,
+ i,
+ mtc);
+
+ ACE_ASSERT (r == i);
+ // Assert disappears on with optimizations on.
+ ACE_UNUSED_ARG (r);
+
+ if (mtc > tc)
+ {
+ // Number of threads increased, so store this.
+ ACE_DEBUG ((LM_DEBUG, "Thread count increased to %d\n", mtc));
+ tc = mtc;
+ }
+ else if (mtc < tc)
+ {
+ // Number of threads decreased!
+ ACE_DEBUG ((LM_DEBUG, "Thread count decreased to %d\n", mtc));
+ decreased = true;
+ tc = mtc;
+ }
+ }
+ ACE_hrtime_t duration = ACE_OS::gethrtime() - start;
+ double tp = ((double) iterations) / (duration / 1000000);
+ tp *= 1000.0;
+ ACE_DEBUG ((LM_DEBUG, "Throughput: %d\n", tp));
+
+ ACE_OS::sleep (10);
+
+ CORBA::Long end = 0;
+ CORBA::Long re =
+ test->method (pid,
+ 0,
+ end);
+
+ ACE_ASSERT (re == 0);
+ // Assert disappears on with optimizations on.
+ ACE_UNUSED_ARG (re);
+
+ if (end != 0)
+ {
+ ACE_ERROR ((LM_ERROR, "Dynamic thread count should be 0, not %d\n", end));
+ }
+
+ if (shutdown_server)
+ {
+ test->shutdown ();
+ }
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught:");
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_TMAIN(int argc, ACE_TCHAR *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv);
+
+ int result =
+ parse_args (argc, argv);
+ if (result != 0)
+ return result;
+
+ // Thread Manager for managing task.
+ ACE_Thread_Manager thread_manager;
+
+ // Create task.
+ Task task (thread_manager,
+ orb.in ());
+
+ // Task activation flags.
+ long flags =
+ THR_NEW_LWP |
+ THR_JOINABLE |
+ orb->orb_core ()->orb_params ()->thread_creation_flags ();
+
+ // Activate task.
+ result = task.activate (flags);
+
+ if (result == -1)
+ {
+ if (errno == EPERM)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot create thread with scheduling policy %s\n"
+ "because the user does not have the appropriate privileges, terminating program....\n"
+ "Check svc.conf options and/or run as root\n",
+ sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())),
+ 2);
+ }
+ else
+ // Unexpected error.
+ ACE_ASSERT (0);
+ }
+
+ // Wait for task to exit.
+ result =
+ thread_manager.wait ();
+ ACE_ASSERT (result != -1);
+
+ if (decreased == false)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Number of threads didn't decrease\n"), -1);
+ }
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught");
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/TAO/tests/RTCORBA/Bug_3643_Regression/run_test.pl b/TAO/tests/RTCORBA/Bug_3643_Regression/run_test.pl
new file mode 100755
index 00000000000..d51b5d263d5
--- /dev/null
+++ b/TAO/tests/RTCORBA/Bug_3643_Regression/run_test.pl
@@ -0,0 +1,115 @@
+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;
+
+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";
+
+$number_of_clients = 4;
+$status = 0;
+$continuous = ($^O eq 'hpux');
+
+@configurations =
+ ({
+ file => "ior_1",
+ description => "Invoking methods on servant in default thread pool",
+ },{
+ file => "ior_2",
+ description => "Invoking methods on servant in first RT thread pool (without lanes)",
+ },{
+ file => "ior_3",
+ description => "Invoking methods on servant in second RT thread pool (with lanes)",
+ },
+ );
+
+for $test (@configurations) {
+ $server->DeleteFile ($test->{file});
+ $client->DeleteFile ($test->{file});
+}
+
+sub run_clients
+{
+ my @parms = @_;
+ $arg = $parms[0];
+ $clients = $parms[1];
+
+
+ for ($i = 0; $i < $clients; $i++) {
+ $CL[$i] = $client->CreateProcess ("client", $arg);
+ $CL[$i]->Spawn ();
+ }
+
+ for ($i = 0; $i < $clients; $i++) {
+ $client_status = $CL[$i]->WaitKill ($client->ProcessStopWaitInterval (120));
+ if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+ goto kill_server;
+ }
+ }
+ print STDERR "Finished running clients";
+}
+
+$SV = $server->CreateProcess ("server");
+
+if ($continuous) {
+ $SV->Arguments ("-ORBSvcConf continuous$PerlACE::svcconf_ext");
+}
+
+$SV->Spawn ();
+
+for $test (@configurations) {
+ if ($server->WaitForFileTimed ($test->{file},
+ $server->ProcessStartWaitInterval()) == -1) {
+ $server_status = $SV->TimedWait (1);
+ if ($server_status == 2) {
+ # Mark as no longer running to avoid errors on exit.
+ $SV->{RUNNING} = 0;
+ exit $status;
+ }
+ else {
+ print STDERR "ERROR: cannot find ior file: $test->{file}\n";
+ $status = 1;
+ goto kill_server;
+ }
+ }
+}
+
+for $test (@configurations) {
+ print STDERR "\n*************************************************************\n";
+ print STDERR "$test->{description}\n";
+ print STDERR "*************************************************************\n\n";
+
+ $iorfile = $client->LocalFile ($test->{file});
+ run_clients ("-k file://$iorfile", $number_of_clients);
+ print STDERR "Prepare next cycle";
+}
+
+print STDERR "\n************************\n";
+print STDERR "Shutting down the server\n";
+print STDERR "************************\n\n";
+
+$client_iorfile = $client->LocalFile ($configurations[0]->{file});
+run_clients ("-k file://$client_iorfile -i 0 -x", 1);
+
+kill_server:
+
+$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval () + (2 * $number_of_clients * 100));
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ $status = 1;
+}
+
+for $test (@configurations) {
+ $client->DeleteFile ($test->{file});
+ $server->DeleteFile ($test->{file});
+}
+
+exit $status
diff --git a/TAO/tests/RTCORBA/Bug_3643_Regression/server.cpp b/TAO/tests/RTCORBA/Bug_3643_Regression/server.cpp
new file mode 100644
index 00000000000..96745267fb2
--- /dev/null
+++ b/TAO/tests/RTCORBA/Bug_3643_Regression/server.cpp
@@ -0,0 +1,354 @@
+// $Id$
+
+#include "test_i.h"
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_unistd.h"
+#include "tao/ORB_Core.h"
+#include "ace/Task.h"
+#include "tao/RTPortableServer/RTPortableServer.h"
+#include "../check_supported_priorities.cpp"
+
+ACE_RCSID(Thread_Pool, server, "$Id$")
+
+const ACE_TCHAR *ior_output_file = ACE_TEXT("ior");
+int ior_count = 1;
+CORBA::ULong static_threads = 1;
+CORBA::ULong dynamic_threads = 25;
+long nap_time = 1000;
+
+int
+parse_args (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("o:s:d:t:h"));
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o':
+ ior_output_file = get_opts.opt_arg ();
+ break;
+
+ case 's':
+ static_threads = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+
+ case 'd':
+ dynamic_threads = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+
+ case 't':
+ nap_time = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+
+ case 'h':
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-o <iorfile> "
+ "-s <static_threads> "
+ "-d <dynamic_threads> "
+ "-t <nap_time> "
+ "\n",
+ argv [0]),
+ -1);
+ }
+
+ // Indicates sucessful parsing of the command line
+ return 0;
+}
+
+int
+write_ior_to_file (CORBA::ORB_ptr orb,
+ test_ptr test)
+{
+ CORBA::String_var ior =
+ orb->object_to_string (test);
+
+ char filename[BUFSIZ];
+ ACE_OS::sprintf (filename,
+ "%s_%d",
+ ior_output_file,
+ ior_count++);
+
+ FILE *output_file =
+ ACE_OS::fopen (filename,
+ "w");
+
+ if (output_file == 0)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot open output file for writing IOR: %s",
+ filename),
+ -1);
+
+ ACE_OS::fprintf (output_file,
+ "%s",
+ ior.in ());
+
+ ACE_OS::fclose (output_file);
+
+ return 0;
+}
+
+int
+create_POA_and_register_servant (CORBA::Policy_ptr threadpool_policy,
+ const char *poa_name,
+ PortableServer::POAManager_ptr poa_manager,
+ PortableServer::POA_ptr root_poa,
+ CORBA::ORB_ptr orb,
+ RTCORBA::RTORB_ptr rt_orb)
+{
+ // Policies for the firstPOA to be created.
+ CORBA::PolicyList policies (3); policies.length (3);
+
+ // Implicit_activation policy.
+ policies[0] =
+ root_poa->create_implicit_activation_policy
+ (PortableServer::IMPLICIT_ACTIVATION);
+
+ // Thread pool policy.
+ policies[1] =
+ CORBA::Policy::_duplicate (threadpool_policy);
+
+ // Priority Model policy.
+ policies[2] =
+ rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED,
+ 0);
+
+ // Create the POA under the RootPOA.
+ PortableServer::POA_var poa =
+ root_poa->create_POA (poa_name,
+ poa_manager,
+ policies);
+
+ // Creation of POAs is over. Destroy the Policy objects.
+ for (CORBA::ULong i = 0;
+ i < policies.length ();
+ ++i)
+ {
+ policies[i]->destroy ();
+ }
+
+ test_i *servant =
+ new test_i (orb,
+ poa.in (),
+ nap_time);
+
+ PortableServer::ServantBase_var safe_servant (servant);
+ ACE_UNUSED_ARG (safe_servant);
+
+ PortableServer::ObjectId_var id =
+ poa->activate_object (servant);
+
+ CORBA::Object_var object = poa->id_to_reference (id.in ());
+
+ test_var test =
+ test::_narrow (object.in ());
+
+ int result =
+ write_ior_to_file (orb,
+ test.in ());
+
+ return result;
+}
+
+class Task : public ACE_Task_Base
+{
+public:
+
+ Task (ACE_Thread_Manager &thread_manager,
+ CORBA::ORB_ptr orb);
+
+ int svc (void);
+
+ CORBA::ORB_var orb_;
+
+};
+
+Task::Task (ACE_Thread_Manager &thread_manager,
+ CORBA::ORB_ptr orb)
+ : ACE_Task_Base (&thread_manager),
+ orb_ (CORBA::ORB::_duplicate (orb))
+{
+}
+
+int
+Task::svc (void)
+{
+ try
+ {
+ CORBA::Object_var object =
+ this->orb_->resolve_initial_references ("RootPOA");
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (object.in ());
+
+ PortableServer::POAManager_var poa_manager =
+ root_poa->the_POAManager ();
+
+ object =
+ this->orb_->resolve_initial_references ("RTORB");
+
+ RTCORBA::RTORB_var rt_orb =
+ RTCORBA::RTORB::_narrow (object.in ());
+
+ object =
+ this->orb_->resolve_initial_references ("RTCurrent");
+
+ RTCORBA::Current_var current =
+ RTCORBA::Current::_narrow (object.in ());
+
+ RTCORBA::Priority default_thread_priority =
+ get_implicit_thread_CORBA_priority (this->orb_.in ());
+
+ test_i servant (this->orb_.in (),
+ root_poa.in (),
+ nap_time);
+ PortableServer::ObjectId_var id =
+ root_poa->activate_object (&servant);
+
+ CORBA::Object_var object_act = root_poa->id_to_reference (id.in ());
+
+ test_var test =
+ test::_narrow (object_act.in ());
+
+ int result =
+ write_ior_to_file (this->orb_.in (),
+ test.in ());
+
+ if (result != 0)
+ return result;
+
+ poa_manager->activate ();
+
+ CORBA::ULong stacksize = 0;
+ CORBA::Boolean allow_request_buffering = 0;
+ CORBA::ULong max_buffered_requests = 0;
+ CORBA::ULong max_request_buffer_size = 0;
+
+ RTCORBA::ThreadpoolId threadpool_id_1 =
+ rt_orb->create_threadpool (stacksize,
+ static_threads,
+ dynamic_threads,
+ default_thread_priority,
+ allow_request_buffering,
+ max_buffered_requests,
+ max_request_buffer_size);
+
+ CORBA::Policy_var threadpool_policy_1 =
+ rt_orb->create_threadpool_policy (threadpool_id_1);
+
+ CORBA::Boolean allow_borrowing = 0;
+ RTCORBA::ThreadpoolLanes lanes (1);
+ lanes.length (1);
+
+ lanes[0].lane_priority = default_thread_priority;
+ lanes[0].static_threads = static_threads;
+ lanes[0].dynamic_threads = dynamic_threads;
+
+ RTCORBA::ThreadpoolId threadpool_id_2 =
+ rt_orb->create_threadpool_with_lanes (stacksize,
+ lanes,
+ allow_borrowing,
+ allow_request_buffering,
+ max_buffered_requests,
+ max_request_buffer_size);
+
+ CORBA::Policy_var threadpool_policy_2 =
+ rt_orb->create_threadpool_policy (threadpool_id_2);
+
+ result =
+ create_POA_and_register_servant (threadpool_policy_1.in (),
+ "first_poa",
+ poa_manager.in (),
+ root_poa.in (),
+ this->orb_.in (),
+ rt_orb.in ());
+ if (result != 0)
+ return result;
+
+ result =
+ create_POA_and_register_servant (threadpool_policy_2.in (),
+ "second_poa",
+ poa_manager.in (),
+ root_poa.in (),
+ this->orb_.in (),
+ rt_orb.in ());
+ if (result != 0)
+ return result;
+
+ this->orb_->run ();
+
+ this->orb_->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught:");
+ return -1;
+ }
+
+ return 0;
+}
+
+int
+ACE_TMAIN(int argc, ACE_TCHAR *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv);
+
+ int result =
+ parse_args (argc, argv);
+ if (result != 0)
+ return result;
+
+ // Make sure we can support multiple priorities that are required
+ // for this test.
+ if (!check_supported_priorities (orb.in ()))
+ return 2;
+
+ // Thread Manager for managing task.
+ ACE_Thread_Manager thread_manager;
+
+ // Create task.
+ Task task (thread_manager,
+ orb.in ());
+
+ // Task activation flags.
+ long flags =
+ THR_NEW_LWP |
+ THR_JOINABLE |
+ orb->orb_core ()->orb_params ()->thread_creation_flags ();
+
+ // Activate task.
+ result =
+ task.activate (flags);
+ if (result == -1)
+ {
+ if (errno == EPERM)
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Cannot create thread with scheduling policy %s\n"
+ "because the user does not have the appropriate privileges, terminating program....\n"
+ "Check svc.conf options and/or run as root\n",
+ sched_policy_name (orb->orb_core ()->orb_params ()->ace_sched_policy ())),
+ 2);
+ }
+ else
+ // Unexpected error.
+ ACE_ASSERT (0);
+ }
+
+ // Wait for task to exit.
+ result =
+ thread_manager.wait ();
+ ACE_ASSERT (result != -1);
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught");
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/TAO/tests/RTCORBA/Bug_3643_Regression/svc.conf.dynamic b/TAO/tests/RTCORBA/Bug_3643_Regression/svc.conf.dynamic
new file mode 100644
index 00000000000..c288d674567
--- /dev/null
+++ b/TAO/tests/RTCORBA/Bug_3643_Regression/svc.conf.dynamic
@@ -0,0 +1 @@
+static RT_ORB_Loader "-RTORBDynamicThreadIdleTimeout 1000000"
diff --git a/TAO/tests/RTCORBA/Bug_3643_Regression/test.idl b/TAO/tests/RTCORBA/Bug_3643_Regression/test.idl
new file mode 100644
index 00000000000..3bc8f9af25c
--- /dev/null
+++ b/TAO/tests/RTCORBA/Bug_3643_Regression/test.idl
@@ -0,0 +1,12 @@
+//
+// $Id$
+//
+
+interface test
+{
+ long method (in long client_id,
+ in long iteration,
+ out long thread_count);
+
+ oneway void shutdown ();
+};
diff --git a/TAO/tests/RTCORBA/Bug_3643_Regression/test_i.cpp b/TAO/tests/RTCORBA/Bug_3643_Regression/test_i.cpp
new file mode 100644
index 00000000000..55d36ae90e3
--- /dev/null
+++ b/TAO/tests/RTCORBA/Bug_3643_Regression/test_i.cpp
@@ -0,0 +1,68 @@
+// $Id$
+
+#include "test_i.h"
+#include "ace/OS_NS_unistd.h"
+#include "tao/ORB_Core.h"
+#include "tao/RTCORBA/Thread_Pool.h"
+
+ACE_RCSID(Thread_Pools, test_i, "$Id$")
+
+test_i::test_i (CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ long msec_sleep)
+ : orb_ (CORBA::ORB::_duplicate (orb)),
+ poa_ (PortableServer::POA::_duplicate (poa)),
+ nap_time_ ()
+{
+ this->nap_time_.msec (msec_sleep);
+}
+
+CORBA::Long
+test_i::method (CORBA::Long client_id,
+ CORBA::Long iteration,
+ CORBA::Long_out thread_count)
+{
+ // Get the ORB_Core's TSS resources.
+ TAO_ORB_Core_TSS_Resources *tss =
+ this->orb_->orb_core ()->get_tss_resources ();
+
+ /// Get the lane attribute in TSS.
+ TAO_Thread_Lane *lane =
+ static_cast <TAO_Thread_Lane *> (tss->lane_);
+
+#ifndef NDEBUG
+ if (lane)
+ ACE_DEBUG ((LM_DEBUG,
+ "Request in thread %t (pool id = %d; lane id = %d) for client %d iteration %d\n",
+ lane->pool ().id (),
+ lane->id (),
+ client_id,
+ iteration));
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ "Request in thread %t (default thread pool) for client %d iteration %d\n",
+ client_id,
+ iteration));
+#endif // NDEBUG
+
+ ACE_OS::sleep (this->nap_time_);
+
+ if (lane)
+ thread_count = lane->current_threads ();
+ else
+ thread_count = 0;
+
+ return iteration;
+}
+
+PortableServer::POA_ptr
+test_i::_default_POA (void)
+{
+ return PortableServer::POA::_duplicate (this->poa_.in ());
+}
+
+void
+test_i::shutdown (void)
+{
+ this->orb_->shutdown (0);
+}
diff --git a/TAO/tests/RTCORBA/Bug_3643_Regression/test_i.h b/TAO/tests/RTCORBA/Bug_3643_Regression/test_i.h
new file mode 100644
index 00000000000..f6fa6a9fbee
--- /dev/null
+++ b/TAO/tests/RTCORBA/Bug_3643_Regression/test_i.h
@@ -0,0 +1,42 @@
+//=============================================================================
+/**
+ * @file test_i.h
+ *
+ * $Id$
+ *
+ * @author Irfan Pyarali
+ */
+// ===================================================================
+
+#include "testS.h"
+
+class test_i :
+ public POA_test
+{
+public:
+ /// Constructor.
+ test_i (CORBA::ORB_ptr orb,
+ PortableServer::POA_ptr poa,
+ long msec_sleep);
+
+ /// Test method.
+ CORBA::Long method (CORBA::Long client_id,
+ CORBA::Long iteration,
+ CORBA::Long_out thread_count);
+
+ /// Shutdown the server.
+ void shutdown (void);
+
+ /// Our POA.
+ PortableServer::POA_ptr _default_POA (void);
+
+private:
+ /// ORB.
+ CORBA::ORB_var orb_;
+
+ /// Our POA.
+ PortableServer::POA_var poa_;
+
+ /// Time spent in executing the upcall.
+ ACE_Time_Value nap_time_;
+};