summaryrefslogtreecommitdiff
path: root/TAO/tests/Bug_3193_Regression
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tests/Bug_3193_Regression')
-rw-r--r--TAO/tests/Bug_3193_Regression/Bug_3193_Regression.mpc31
-rw-r--r--TAO/tests/Bug_3193_Regression/README6
-rw-r--r--TAO/tests/Bug_3193_Regression/client.cpp223
-rwxr-xr-xTAO/tests/Bug_3193_Regression/run_test.pl56
-rw-r--r--TAO/tests/Bug_3193_Regression/server.cpp98
-rw-r--r--TAO/tests/Bug_3193_Regression/svc.conf2
-rw-r--r--TAO/tests/Bug_3193_Regression/test.idl12
-rw-r--r--TAO/tests/Bug_3193_Regression/test_i.cpp36
-rw-r--r--TAO/tests/Bug_3193_Regression/test_i.h45
9 files changed, 509 insertions, 0 deletions
diff --git a/TAO/tests/Bug_3193_Regression/Bug_3193_Regression.mpc b/TAO/tests/Bug_3193_Regression/Bug_3193_Regression.mpc
new file mode 100644
index 00000000000..1c82d874281
--- /dev/null
+++ b/TAO/tests/Bug_3193_Regression/Bug_3193_Regression.mpc
@@ -0,0 +1,31 @@
+// -*- MPC -*-
+// $Id$
+
+project(*idl): taoidldefaults {
+ IDL_Files {
+ test.idl
+ }
+ custom_only = 1
+}
+
+project(*Server): taoserver {
+ after += *idl
+ Source_Files {
+ testC.cpp
+ testS.cpp
+ test_i.cpp
+ server.cpp
+ }
+ IDL_Files {
+ }
+}
+
+project(*Client): taoclient, messaging {
+ after += *Server
+ Source_Files {
+ testC.cpp
+ client.cpp
+ }
+ IDL_Files {
+ }
+}
diff --git a/TAO/tests/Bug_3193_Regression/README b/TAO/tests/Bug_3193_Regression/README
new file mode 100644
index 00000000000..48c86ae5e36
--- /dev/null
+++ b/TAO/tests/Bug_3193_Regression/README
@@ -0,0 +1,6 @@
+# $Id$
+
+Test to reproduce Bug 3193 issue.
+
+The aim is to fill up the TCP buffers then get a one-way invocation with
+ SYNC_WITH_TRANSPORT synch scope and Block flushing to timeout.
diff --git a/TAO/tests/Bug_3193_Regression/client.cpp b/TAO/tests/Bug_3193_Regression/client.cpp
new file mode 100644
index 00000000000..dafe0143ae4
--- /dev/null
+++ b/TAO/tests/Bug_3193_Regression/client.cpp
@@ -0,0 +1,223 @@
+// $Id$
+
+#include "testC.h"
+
+#include "tao/Messaging/Messaging.h"
+#include "tao/AnyTypeCode/Any.h"
+#include "ace/Get_Opt.h"
+#include "ace/Task.h"
+#include "ace/OS_NS_unistd.h"
+
+ACE_RCSID(Timeout, client, "$Id$")
+
+const char *ior = "file://test.ior";
+int min_timeout = 20;
+int inv_count = 100;
+int timeouts_received = 0;
+int sleep_time = 100; // msec
+
+class OPool : public ACE_Task_Base
+{
+private:
+ CORBA::ORB_var orb_;
+
+public:
+ OPool (CORBA::ORB_ptr orb)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+ {
+ if (CORBA::is_nil (orb_.in()) == 1) {
+ ACE_ERROR ((LM_ERROR, "OPool> Ctr> Orb is NULL\n"));
+ }
+ };
+
+ virtual ~OPool ()
+ { };
+
+ virtual int svc ()
+ {
+ if (CORBA::is_nil (orb_.in()) == 0) {
+ orb_->run();
+ }
+
+ return -1;
+ };
+};
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "k:l:i:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'k':
+ ior = get_opts.opt_arg ();
+ break;
+
+ case 'l':
+ min_timeout = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+
+ case 'i':
+ inv_count = ACE_OS::atoi (get_opts.opt_arg ());
+ break;
+
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-k <ior> "
+ "-l <timeout> "
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates successful parsing of the command line
+ return 0;
+}
+
+char* aStr;
+
+void
+send_echo (Simple_Server_ptr server,
+ CORBA::Long msec)
+{
+ try
+ {
+ server->echo (0, msec, aStr);
+ }
+ catch (const CORBA::TIMEOUT& )
+ {
+ // Trap this exception and continue...
+ ACE_DEBUG ((LM_DEBUG,
+ "==> Trapped a TIMEOUT exception \n"));
+
+ timeouts_received++;
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught:");
+ }
+}
+
+
+int main (int argc, char* argv[])
+{
+ aStr = new char [5000];
+ memset(aStr,'A',4999);
+ aStr[4999] = 0;
+
+ try
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv, "");
+
+ int orb_thr_pool = 1;
+ OPool orbPool (orb.in());
+ if (orb_thr_pool > 0) {
+ orbPool.activate (THR_NEW_LWP | THR_JOINABLE |THR_INHERIT_SCHED, orb_thr_pool);
+ }
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ CORBA::Object_var object = orb->string_to_object (ior);
+
+ Simple_Server_var server = Simple_Server::_narrow (object.in ());
+ if (CORBA::is_nil (server.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "Object reference <%s> is nil\n",
+ ior),
+ 1);
+ }
+
+ // convert from msec to "TimeT" (0.1 usec units)
+ TimeBase::TimeT mid_value = 10000 * min_timeout;
+
+ CORBA::Any any_object;
+ any_object <<= mid_value; // - 20000; // midvalue + 2 msec
+
+ CORBA::PolicyList policy_list (1);
+ policy_list.length (1);
+ policy_list[0] =
+ orb->create_policy (Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
+ any_object);
+ object =
+ server->_set_policy_overrides (policy_list,
+ CORBA::SET_OVERRIDE);
+
+ Simple_Server_var timeout_server = Simple_Server::_narrow (object.in ());
+
+ policy_list[0]->destroy ();
+ policy_list.length(0);
+
+ //for(int i = 0; i != 1000000;++i)
+ for(int i = 0; i != inv_count;++i)
+ {
+ if( (i % 10) == 0)
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "client(%P) sent %d messages\n",i));
+ }
+ send_echo (timeout_server.in (), sleep_time);
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "Invocations: %d, Timeouts received: %d\n"
+ , inv_count, timeouts_received));
+
+ // Set the policy value.
+ Messaging::SyncScope sync_with_target = Messaging::SYNC_WITH_TARGET;
+ CORBA::Any sync_with_target_any;
+ sync_with_target_any <<= sync_with_target;
+
+ policy_list.length (1);
+ policy_list[0] =
+ orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE, sync_with_target_any);
+ // Apply the policy at the ORB level.
+ CORBA::Object_var obj = orb->resolve_initial_references ("ORBPolicyManager");
+ CORBA::PolicyManager_var policy_manager =
+ CORBA::PolicyManager::_narrow(obj.in());
+
+ policy_manager->set_policy_overrides (policy_list, CORBA::ADD_OVERRIDE);
+ // Destroy the Policy objects.
+ for (CORBA::ULong i = 0; i < policy_list.length(); ++i) {
+ policy_list[i]->destroy ();
+ }
+ policy_list.length(0);
+
+ ACE_DEBUG ((LM_DEBUG,
+ "\n\n\nclient(%P) Test completed, "
+ "resynch with server\n"));
+
+ send_echo (timeout_server.in (), 0);
+
+ server->shutdown ();
+
+ orb->destroy ();
+
+ orbPool.wait();
+
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ACE_ERROR ((LM_ERROR, "ERROR: caught CORBA::Exception\n"));
+ ex._tao_print_exception ("Exception caught:");
+ return 1;
+ }
+
+ if (timeouts_received < 1) {
+ // We should have received one timeout for the single SYNCH_WITH_TARGET case.
+ ACE_ERROR ((LM_ERROR, "ERROR: No Timeout received for SYNCH_WITH_TARGET scope.\n"));
+ return -1;
+ }
+ else if (timeouts_received < 2) {
+ // We didn't receive any timeouts for the SYNC_WITH_TRANSPORT case.
+ ACE_ERROR ((LM_ERROR, "ERROR: No Timeout received for SYNC_WITH_TRANSPORT scope.\n"));
+ return -1;
+ }
+
+ return 0;
+}
diff --git a/TAO/tests/Bug_3193_Regression/run_test.pl b/TAO/tests/Bug_3193_Regression/run_test.pl
new file mode 100755
index 00000000000..a750f3d546d
--- /dev/null
+++ b/TAO/tests/Bug_3193_Regression/run_test.pl
@@ -0,0 +1,56 @@
+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::Run_Test;
+
+$status = 0;
+
+$iorfile = PerlACE::LocalFile ("server.ior");
+unlink $iorfile;
+
+if (PerlACE::is_vxworks_test()) {
+ $SV = new PerlACE::ProcessVX ("server", "-o server.ior");
+}
+else {
+ $SV = new PerlACE::Process ("server", "-o $iorfile");
+}
+$CL = new PerlACE::Process ("client", "-ORBDebugLevel 0 -k file://$iorfile -l 20 ");
+
+print $SV->CommandLine()."\n";
+$server_spawn = $SV->Spawn ();
+
+if ($server_spawn != 0) {
+ print STDERR "ERROR: server returned $server_spawn\n";
+ exit 1;
+}
+
+if (PerlACE::waitforfile_timed ($iorfile,
+ $PerlACE::wait_interval_for_process_creation) == -1) {
+ print STDERR "ERROR: cannot find file <$iorfile>\n";
+ $SV->Kill ();
+ exit 1;
+}
+
+print $CL->CommandLine()."\n";
+$client = $CL->SpawnWaitKill (120);
+
+if ($client != 0) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1;
+}
+
+$server = $SV->WaitKill (5);
+
+if ($server != 0) {
+ print STDERR "ERROR: server returned $server\n";
+ $status = 1;
+}
+
+unlink $iorfile;
+
+exit $status;
diff --git a/TAO/tests/Bug_3193_Regression/server.cpp b/TAO/tests/Bug_3193_Regression/server.cpp
new file mode 100644
index 00000000000..e37a437a3dc
--- /dev/null
+++ b/TAO/tests/Bug_3193_Regression/server.cpp
@@ -0,0 +1,98 @@
+// $Id$
+
+#include "test_i.h"
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_stdio.h"
+
+ACE_RCSID(Timeout, server, "$Id$")
+
+const char *ior_output_file = 0;
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "o:");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'o':
+ ior_output_file = get_opts.opt_arg ();
+ break;
+
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-o <iorfile>"
+ "\n",
+ argv [0]),
+ -1);
+ }
+
+ // Indicates sucessful parsing of the command line
+ return 0;
+}
+
+int
+main (int argc, char *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv, "");
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ CORBA::Object_var poa_object =
+ orb->resolve_initial_references("RootPOA");
+
+ if (CORBA::is_nil (poa_object.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Unable to initialize the POA.\n"),
+ 1);
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (poa_object.in ());
+
+ PortableServer::POAManager_var poa_manager =
+ root_poa->the_POAManager ();
+
+ Simple_Server_i server_impl (orb.in ());
+
+ Simple_Server_var server =
+ server_impl._this ();
+
+ CORBA::String_var ior =
+ orb->object_to_string (server.in ());
+
+ // ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n", ior.in ()));
+
+ poa_manager->activate ();
+
+ // If the ior_output_file exists, output the ior to it
+ if (ior_output_file != 0)
+ {
+ 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);
+ }
+
+ orb->run ();
+
+ // ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Caught exception:");
+ return 1;
+ }
+ return 0;
+}
diff --git a/TAO/tests/Bug_3193_Regression/svc.conf b/TAO/tests/Bug_3193_Regression/svc.conf
new file mode 100644
index 00000000000..b63238901e0
--- /dev/null
+++ b/TAO/tests/Bug_3193_Regression/svc.conf
@@ -0,0 +1,2 @@
+static Client_Strategy_Factory "-ORBWaitStrategy rw -ORBTransportMuxStrategy exclusive -ORBConnectStrategy blocked -ORBConnectionHandlerCleanup 1"
+static Resource_Factory "-ORBFlushingStrategy blocking"
diff --git a/TAO/tests/Bug_3193_Regression/test.idl b/TAO/tests/Bug_3193_Regression/test.idl
new file mode 100644
index 00000000000..2bbd204c6de
--- /dev/null
+++ b/TAO/tests/Bug_3193_Regression/test.idl
@@ -0,0 +1,12 @@
+//
+// $Id$
+//
+
+interface Simple_Server {
+
+ /// Returns <x>, but sleep for <msecs> milliseconds before returning
+ oneway void echo (in long x, in long msecs, in string msg);
+
+ /// Shutdown the ORB
+ oneway void shutdown ();
+};
diff --git a/TAO/tests/Bug_3193_Regression/test_i.cpp b/TAO/tests/Bug_3193_Regression/test_i.cpp
new file mode 100644
index 00000000000..e532731a663
--- /dev/null
+++ b/TAO/tests/Bug_3193_Regression/test_i.cpp
@@ -0,0 +1,36 @@
+// $Id$
+
+#include "test_i.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/High_Res_Timer.h"
+
+ACE_RCSID(Timeout, test_i, "$Id$")
+
+ACE_High_Res_Timer sleep_duration;
+
+
+Simple_Server_i::Simple_Server_i (CORBA::ORB_ptr orb)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+ , echo_count_ (0)
+{
+ sleep_duration.calibrate();
+}
+
+void
+Simple_Server_i::echo (CORBA::Long ,
+ CORBA::Long msecs, const char* )
+{
+ ACE_Time_Value tv;
+ tv.msec (msecs);
+ echo_count_++;
+ ACE_OS::sleep (tv);
+}
+
+void
+Simple_Server_i::shutdown (void)
+{
+ ACE_DEBUG ((LM_DEBUG,
+ "server (%P) Received shutdown request from client\n"));
+
+ this->orb_->shutdown (0);
+}
diff --git a/TAO/tests/Bug_3193_Regression/test_i.h b/TAO/tests/Bug_3193_Regression/test_i.h
new file mode 100644
index 00000000000..2468e14267e
--- /dev/null
+++ b/TAO/tests/Bug_3193_Regression/test_i.h
@@ -0,0 +1,45 @@
+// $Id$
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO/tests/Timeout
+//
+// = FILENAME
+// test_i.h
+//
+// = AUTHOR
+// Carlos O'Ryan
+//
+// ============================================================================
+
+#ifndef TAO_TIMEOUT_TEST_I_H
+#define TAO_TIMEOUT_TEST_I_H
+
+#include "testS.h"
+
+class Simple_Server_i : public POA_Simple_Server
+{
+ // = TITLE
+ // Simpler Server implementation
+ //
+ // = DESCRIPTION
+ // Implements the Simple_Server interface in test.idl
+ //
+public:
+ Simple_Server_i (CORBA::ORB_ptr orb);
+ // ctor
+
+ // = The Simple_Server methods.
+ void echo (CORBA::Long x,
+ CORBA::Long msecs, const char* msg);
+ void shutdown (void);
+
+private:
+ CORBA::ORB_var orb_;
+ // The ORB
+
+ int echo_count_;
+};
+
+#endif /* TAO_TIMEOUT_TEST_I_H */