summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohnc <johnc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-01-30 23:16:05 +0000
committerjohnc <johnc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2008-01-30 23:16:05 +0000
commit980aa7a10066fccd3d6842ecba05d1dd5ae6d6c7 (patch)
treea17dba5e669d5892f195db6f16e6562be7603ea9
parentad8c192cedfcce5c796c41a70df1ff4697e2159c (diff)
downloadATCD-980aa7a10066fccd3d6842ecba05d1dd5ae6d6c7.tar.gz
ChangeLogTag: Wed Jan 30 23:11:05 UTC 2008 Ciju John <johnc at ociweb dot com>
-rw-r--r--TAO/ChangeLog5
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/Client.cpp465
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/Client.h50
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/Client_Task.h33
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/ORB_Task.h32
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/Oneway_scenarios.mpc21
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/Server.cpp205
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/Server.h37
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/Server_Task.h70
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/Test.idl18
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/Test_i.cpp87
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/Test_i.h33
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/block_flush.conf1
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/lf_flush.conf1
-rw-r--r--TAO/tests/Oneway_Send_Timeouts/main.cpp139
-rwxr-xr-xTAO/tests/Oneway_Send_Timeouts/run_test.pl62
16 files changed, 1259 insertions, 0 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 6908a0787fc..8e7b7679866 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,8 @@
+Wed Jan 30 23:11:05 UTC 2008 Ciju John <johnc at ociweb dot com>
+
+ * tests/Oneway_Send_Timeouts:
+ New test for RTT validation during send/flush.
+
Wed Jan 30 18:02:59 UTC 2008 Ciju John <johnc at ociweb dot com>
* tao/Transport.cpp:
diff --git a/TAO/tests/Oneway_Send_Timeouts/Client.cpp b/TAO/tests/Oneway_Send_Timeouts/Client.cpp
new file mode 100644
index 00000000000..49b038598b3
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/Client.cpp
@@ -0,0 +1,465 @@
+
+#include "tao/Messaging/Messaging.h"
+#include "tao/AnyTypeCode/Any.h"
+
+#include "ace/Get_Opt.h"
+#include "ace/Time_Value.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/OS_NS_strings.h"
+
+#include "Client.h"
+#include "TestC.h"
+
+Client::Client (int argc, ACE_TCHAR* argv[])
+ : init_ (false), one_way_test_ (false)
+{
+ if (this->init (argc, argv)) {
+ init_ = true;
+ }
+}
+
+Client::~Client ()
+{
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) ~Client>\n"));
+}
+
+bool
+Client::init (int argc, ACE_TCHAR* argv[])
+{
+ try {
+ orb_ = CORBA::ORB_init (argc, argv, "Client");
+
+ if (!this->parse_args (argc, argv)) {
+ return false;
+ }
+
+ // Timeout
+ TimeBase::TimeT timeout = 5 * 1000000; // 5 seconds
+ CORBA::Any any_object;
+ any_object <<= timeout;
+
+ CORBA::PolicyList policy_list (2);
+ policy_list.length (2);
+ policy_list[0] =
+ orb_->create_policy (Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE,
+ any_object);
+
+
+ // Timeout with SYNC_SCOPE SYNC_WITH_TRANSPORT
+ Messaging::SyncScope sync_with_transport = Messaging::SYNC_WITH_TRANSPORT;
+ CORBA::Any sync_with_transport_any;
+ sync_with_transport_any <<= sync_with_transport;
+ policy_list[1] = orb_->create_policy
+ (Messaging::SYNC_SCOPE_POLICY_TYPE, sync_with_transport_any);
+ CORBA::Object_var obj = test_obj_->_set_policy_overrides
+ (policy_list, CORBA::SET_OVERRIDE);
+ test_obj_transport_timeout_ = Test::_narrow (obj.in ());
+ policy_list[1]->destroy ();
+
+
+
+ // Timeout with SYNC_SCOPE SYNC_NONE
+ Messaging::SyncScope sync_none = Messaging::SYNC_NONE;
+ CORBA::Any sync_none_any;
+ sync_none_any <<= sync_none;
+ policy_list[1] = orb_->create_policy
+ (Messaging::SYNC_SCOPE_POLICY_TYPE, sync_none_any);
+ // Apply the policy at the object level
+ obj = test_obj_->_set_policy_overrides
+ (policy_list, CORBA::SET_OVERRIDE);
+ test_obj_none_timeout_ = Test::_narrow (obj.in ());
+ policy_list[1]->destroy ();
+
+
+ // Timeout with TAO specific SYNC_SCOPE SYNC_EAGER_BUFFERING
+ //Messaging::SyncScope eager_buffering = TAO::SYNC_EAGER_BUFFERING;
+ Messaging::SyncScope eager_buffering = Messaging::SYNC_NONE;
+ CORBA::Any eager_any;
+ eager_any <<= eager_buffering;
+ policy_list[1] = orb_->create_policy
+ (Messaging::SYNC_SCOPE_POLICY_TYPE, eager_any);
+ obj = test_obj_->_set_policy_overrides
+ (policy_list, CORBA::SET_OVERRIDE);
+ test_obj_eager_timeout_ = Test::_narrow (obj.in ());
+ policy_list[1]->destroy ();
+
+
+ // Timeout with TAO specific SYNC_SCOPE SYNC_DELAYED_BUFFERING
+ Messaging::SyncScope delayed_buffering = TAO::SYNC_DELAYED_BUFFERING;
+ CORBA::Any delayed_any;
+ delayed_any <<= delayed_buffering;
+ policy_list[1] = orb_->create_policy
+ (Messaging::SYNC_SCOPE_POLICY_TYPE, delayed_any);
+ obj = test_obj_->_set_policy_overrides
+ (policy_list, CORBA::SET_OVERRIDE);
+ test_obj_delayed_timeout_ = Test::_narrow (obj.in ());
+ policy_list[1]->destroy ();
+
+
+ // Timeout with default SYNC_SCOPE SYNC_WITH_SERVER
+ Messaging::SyncScope sync_with_server = Messaging::SYNC_WITH_SERVER;
+ CORBA::Any sync_with_server_any;
+ sync_with_server_any <<= sync_with_server;
+ policy_list[1] = orb_->create_policy
+ (Messaging::SYNC_SCOPE_POLICY_TYPE, sync_with_server_any);
+ obj = test_obj_->_set_policy_overrides
+ (policy_list, CORBA::SET_OVERRIDE);
+ test_obj_server_timeout_ = Test::_narrow (obj.in ());
+ policy_list[1]->destroy ();
+
+
+ // Timeout with default SYNC_SCOPE (SYNC_WITH_TARGET)
+ Messaging::SyncScope sync_with_target = Messaging::SYNC_WITH_TARGET;
+ CORBA::Any sync_with_target_any;
+ sync_with_target_any <<= sync_with_target;
+ policy_list[1] = orb_->create_policy
+ (Messaging::SYNC_SCOPE_POLICY_TYPE, sync_with_target_any);
+ // Apply the policy at the object level
+ obj = test_obj_->_set_policy_overrides
+ (policy_list, CORBA::SET_OVERRIDE);
+ test_obj_target_timeout_ = Test::_narrow (obj.in ());
+
+ policy_list[0]->destroy ();
+ policy_list[1]->destroy ();
+ policy_list.length(0);
+
+ }
+ catch( CORBA::Exception& ex) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) Client::Init> Caught CORBA::Exception %s"
+ , ex._info().c_str()));
+ return false;
+ }
+
+ return true;
+}
+
+bool
+Client::parse_args (int argc, ACE_TCHAR* argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "b:k:1::f:", 0);
+ int c;
+ std::string test_ior;
+ std::string back_ior;
+ std::string flush_strategy ("lf");
+
+ while ((c = get_opts ()) != -1) {
+ switch (c)
+ {
+ case '1':
+ one_way_test_ = true;
+ break;
+ case 'k':
+ test_ior = get_opts.opt_arg ();
+ break;
+ case 'b':
+ back_ior = get_opts.opt_arg ();
+ break;
+ case 'f':
+ flush_strategy = get_opts.opt_arg ();
+ break;
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR, "Invalid option \'-%c\'\n", c)
+ , false);
+ }
+ }
+
+ CORBA::Object_var obj = orb_->string_to_object (test_ior.c_str());
+ test_obj_ = Test::_narrow (obj.in ());
+
+ obj = orb_->string_to_object (back_ior.c_str());
+ management_ = Test::_narrow (obj.in ());
+
+ if (ACE_OS::strcasecmp ("lf", flush_strategy.c_str()) == 0) {
+ flush_strategy_ = LF;
+ }
+ else if (ACE_OS::strcasecmp ("blocking", flush_strategy.c_str()) == 0) {
+ flush_strategy_ = BLOCKING;
+ }
+ else if (ACE_OS::strcasecmp ("reactive", flush_strategy.c_str()) == 0) {
+ flush_strategy_ = REACTIVE;
+ }
+
+ return true;
+}
+
+bool
+Client::run ()
+{
+ bool status = true;
+
+ try {
+ if (one_way_test_)
+ {
+ ACE_Time_Value tv (0);
+ bool flooded = false;
+ bool test_condition_met = false;
+ if (flush_strategy_ == BLOCKING) {
+ test_obj_->sleep (tv.sec(), tv.msec());
+ test_condition_met = true;
+ }
+ else {
+ flooded = this->flood_connection (tv);
+ if (flooded) {
+ test_condition_met = true;
+ }
+ }
+
+ if (test_condition_met) {
+ if (!this->test_oneway_timeout (flooded, !flooded)) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: Client::run> "
+ "test_oneway_timeout failed.\n"));
+ status = false;
+ }
+
+ management_->unsleep ();
+ }
+
+ // flush out the channel
+ test_obj_->dummy_two_way ();
+
+ // now run same test without the transport flooded.
+ if (!this->test_oneway_timeout (false, false)) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: Client::run> "
+ "test_oneway_timeout 2 failed.\n"));
+ status = false;
+ }
+ }
+
+ test_obj_->shutdown ();
+
+ orb_->shutdown (1);
+ orb_->destroy ();
+ orb_ = CORBA::ORB::_nil();
+ }
+ catch( CORBA::Exception& ex) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) Client::run> Caught CORBA::Exception %s"
+ , ex._info().c_str()));
+ status = false;
+ }
+
+ return status;
+}
+
+bool
+Client::test_oneway_timeout (bool flooded, bool simulate_flooding)
+{
+ bool status = true;
+
+ std::auto_ptr<char> tmp;
+ char* msg = new char [6000000];
+ tmp.reset (msg);
+ ACE_OS::memset (msg,'A',5999999);
+ msg[5999999] = 0;
+
+
+ // Timeout with SYNC_SCOPE SYNC_NONE
+ try {
+ if (simulate_flooding) {
+ test_obj_none_timeout_->dummy_one_way (msg);
+ }
+ else {
+ test_obj_none_timeout_->dummy_one_way ("SYNC_NONE");
+ }
+ if (!simulate_flooding) {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) No Timeout for SYNC_NONE\n"));
+ }
+ else {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: Timeout expected for SYNC_NONE.\n"));
+ }
+ }
+ catch (CORBA::TIMEOUT&) {
+ if (simulate_flooding) {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Expected timeout received for SYNC_NONE.\n"));
+ }
+ else {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Unexpected "
+ "timeout exception with synch scope SYNC_NONE.\n"));
+ status = false;
+ }
+ }
+
+
+ // Timeout with TAO specific SYNC_SCOPE SYNC_EAGER_BUFFERING
+ try {
+ if (simulate_flooding) {
+ management_->unsleep ();
+ test_obj_->sleep (0, 0);
+ test_obj_eager_timeout_->dummy_one_way (msg);
+ }
+ else {
+ test_obj_eager_timeout_->dummy_one_way ("SYNC_EAGER_BUFFERING");
+ }
+ if (!simulate_flooding) {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) No Timeout for SYNC_EAGER_BUFFERING\n"));
+ }
+ else {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) No Timeout for SYNC_EAGER_BUFFERING\n"));
+ }
+ }
+ catch (CORBA::TIMEOUT&) {
+ if (simulate_flooding) {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Expected timeout received for SYNC_EAGER_BUFFERING\n"));
+ }
+ else {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Unexpected "
+ "timeout exception with synch scope SYNC_EAGER_BUFFERING.\n"));
+ status = false;
+ }
+ }
+
+ // Timeout with TAO specific SYNC_SCOPE SYNC_DELAYED_BUFFERING
+ try {
+ if (simulate_flooding) {
+ management_->unsleep ();
+ test_obj_->sleep (0, 0);
+ test_obj_delayed_timeout_->dummy_one_way (msg);
+ }
+ else {
+ test_obj_delayed_timeout_->dummy_one_way ("SYNC_DELAYED_BUFFERING");
+ }
+ if (!simulate_flooding) {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) No Timeout for SYNC_DELAYED_BUFFERING\n"));
+ }
+ else {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) No Timeout for SYNC_DELAYED_BUFFERING\n"));
+ }
+ }
+ catch (CORBA::TIMEOUT&) {
+ if (simulate_flooding) {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Expected timeout received for SYNC_DELAYED_BUFFERING\n"));
+ }
+ else {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Unexpected "
+ "timeout exception with synch scope SYNC_DELAYED_BUFFERING.\n"));
+ status = false;
+ }
+ }
+
+ // Timeout with SYNC_SCOPE SYNC_WITH_TRANSPORT
+ try {
+ if (simulate_flooding) {
+ management_->unsleep ();
+ test_obj_->sleep (0, 0);
+ test_obj_transport_timeout_->dummy_one_way (msg);
+ }
+ else {
+ test_obj_transport_timeout_->dummy_one_way ("SYNC_WITH_TRANSPORT");
+ }
+ if (flooded || simulate_flooding) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Expected "
+ "timeout not received for synch scope SYNC_WITH_TRANSPORT.\n"
+ ));
+ status = false;
+ } else {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) No Timeout for SYNC_WITH_TRANSPORT\n"));
+ }
+ }
+ catch (CORBA::TIMEOUT&) {
+ if (!flooded && !simulate_flooding) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> No timeout "
+ "expected for synch scope SYNC_WITH_TRANSPORT.\n"));
+ status = false;
+ } else {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Timeout for SYNC_WITH_TRANSPORT\n"));
+ }
+ }
+
+
+ // Timeout with default SYNC_SCOPE SYNC_WITH_SERVER
+ try {
+ if (simulate_flooding) {
+ management_->unsleep ();
+ test_obj_->sleep (0, 0);
+ test_obj_server_timeout_->dummy_one_way (msg);
+ }
+ else {
+ test_obj_server_timeout_->dummy_one_way ("SYNC_WITH_SERVER");
+ }
+ if (flooded || simulate_flooding) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Expected "
+ "timeout not received for SYNC_SCOPE SYNC_WITH_SERVER.\n"));
+ status = false;
+ } else {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) No Timeout for SYNC_WITH_SERVER.\n"));
+ }
+ }
+ catch (CORBA::TIMEOUT&) {
+ if (!flooded && !simulate_flooding) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> No timeout "
+ "expected for synch scope SYNC_WITH_SERVER.\n"));
+ status = false;
+ } else {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Timeout for SYNC_WITH_SERVER\n"));
+ }
+ }
+
+
+ // Timeout with default SYNC_SCOPE (SYNC_WITH_TARGET)
+ try {
+ if (simulate_flooding) {
+ management_->unsleep ();
+ test_obj_->sleep (0, 0);
+ test_obj_target_timeout_->dummy_one_way (msg);
+ }
+ else {
+ test_obj_target_timeout_->dummy_one_way ("SYNC_WITH_TARGET");
+ }
+ if (flooded || simulate_flooding) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> Expected "
+ "timeout not received for SYNC_SCOPE SYNC_WITH_TARGET.\n"));
+ status = false;
+ } else {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) No Timeout for SYNC_WITH_TARGET.\n"));
+ }
+ }
+ catch (CORBA::TIMEOUT&) {
+ if (!flooded && !simulate_flooding) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: test_oneway_timeout> No timeout "
+ "expected for synch scope SYNC_WITH_TARGET.\n"));
+ status = false;
+ } else {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Timeout for SYNC_WITH_TARGET\n"));
+ }
+ }
+
+ return status;
+}
+
+bool
+Client::flood_connection (ACE_Time_Value& tv)
+{
+ // Set the policy value.
+ // SYNC_DELAYED_BUFFERING is used to ensure that the tcp buffer gets filled before
+ // buffering starts.
+ Messaging::SyncScope sync_scope = TAO::SYNC_DELAYED_BUFFERING;
+ //Messaging::SyncScope sync_scope = Messaging::SYNC_NONE;
+ CORBA::Any sync_scope_any;
+ sync_scope_any <<= sync_scope;
+
+ CORBA::PolicyList policy_list (1);
+ policy_list.length (1);
+ policy_list[0] = orb_->create_policy
+ (Messaging::SYNC_SCOPE_POLICY_TYPE, sync_scope_any);
+ // Apply the policy at the object level
+ CORBA::Object_var obj = test_obj_->_set_policy_overrides
+ (policy_list, CORBA::SET_OVERRIDE);
+ Test_var mod_test_obj = Test::_narrow (obj.in ());
+
+ policy_list[0]->destroy ();
+ policy_list.length(0);
+
+ std::auto_ptr<char> tmp;
+ char* msg = new char [2000000];
+ tmp.reset (msg);
+ ACE_OS::memset (msg,'A',1999999);
+ msg[1999999] = 0;
+
+ test_obj_->sleep (tv.sec(), tv.msec());
+ mod_test_obj->dummy_one_way (msg);
+
+ orb_->perform_work ();
+
+ //ACE_OS::sleep (ACE_Time_Value (5000));
+
+ return true;
+}
diff --git a/TAO/tests/Oneway_Send_Timeouts/Client.h b/TAO/tests/Oneway_Send_Timeouts/Client.h
new file mode 100644
index 00000000000..103749e83e7
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/Client.h
@@ -0,0 +1,50 @@
+#ifndef _CLIENT_
+#define _CLIENT_
+
+#include "TestC.h"
+
+#include "ace/Time_Value.h"
+
+#include <string>
+
+class Client
+{
+ public:
+ Client (int argc, ACE_TCHAR* argv[]);
+ ~Client ();
+
+ bool run ();
+
+ private:
+ bool init (int argc, ACE_TCHAR* argv[]);
+ bool parse_args (int argc, ACE_TCHAR* argv[]);
+
+ enum Flushing_Strategy
+ {
+ LF,
+ BLOCKING,
+ REACTIVE
+ };
+
+ bool init_;
+ bool one_way_test_;
+ CORBA::ORB_var orb_;
+ Test_var test_obj_;
+ Test_var management_;
+ Flushing_Strategy flush_strategy_;
+
+ Test_var test_obj_none_timeout_;
+ Test_var test_obj_eager_timeout_;
+ Test_var test_obj_delayed_timeout_;
+ Test_var test_obj_transport_timeout_;
+ Test_var test_obj_server_timeout_;
+ Test_var test_obj_target_timeout_;
+
+ // flood up connection for 'tv' time.
+ // if tv is 0, remember to unsleep server.
+ bool flood_connection (ACE_Time_Value& tv);
+ bool unplug_transport ();
+ bool test_oneway_timeout (bool flooded, bool simulate_flooding);
+};
+
+#endif //_CLIENT_
diff --git a/TAO/tests/Oneway_Send_Timeouts/Client_Task.h b/TAO/tests/Oneway_Send_Timeouts/Client_Task.h
new file mode 100644
index 00000000000..b40ae16d536
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/Client_Task.h
@@ -0,0 +1,33 @@
+#ifndef _CLIENT_TASK_
+#define _CLIENT_TASK_
+
+#include "Client.h"
+
+#include "ace/ARGV.h"
+
+class Client_Task : public ACE_Task_Base
+{
+ public:
+
+ Client_Task (const std::string& args)
+ : args_ (args)
+ { }
+
+ virtual int svc ()
+ {
+ ACE_ARGV my_args (args_.c_str());
+
+ {
+ Client client (my_args.argc(), my_args.argv());
+ client.run();
+ }
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Client_Task::svc>\n"));
+ return 0;
+ }
+
+ private:
+ std::string args_;
+};
+
+#endif //_CLIENT_TASK_
diff --git a/TAO/tests/Oneway_Send_Timeouts/ORB_Task.h b/TAO/tests/Oneway_Send_Timeouts/ORB_Task.h
new file mode 100644
index 00000000000..60b870e3799
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/ORB_Task.h
@@ -0,0 +1,32 @@
+#ifndef _ORB_TASK_
+#define _ORB_TASK_
+
+#include "tao/ORB_Core.h"
+
+#include "ace/Task.h"
+
+class ORB_Task : public ACE_Task_Base
+{
+ private:
+ CORBA::ORB_var orb_;
+
+ public:
+ ORB_Task (CORBA::ORB_ptr orb)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+ {
+ if (CORBA::is_nil (orb_.in()) == 1) {
+ ACE_ERROR ((LM_ERROR, "ORB_Task> Ctr> Orb is NULL\n"));
+ }
+ };
+
+ virtual int svc ()
+ {
+ if (CORBA::is_nil (orb_.in()) == 0) {
+ orb_->run();
+ }
+
+ return -1;
+ };
+};
+
+#endif // _ORB_TASK_
diff --git a/TAO/tests/Oneway_Send_Timeouts/Oneway_scenarios.mpc b/TAO/tests/Oneway_Send_Timeouts/Oneway_scenarios.mpc
new file mode 100644
index 00000000000..0fbcc65496d
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/Oneway_scenarios.mpc
@@ -0,0 +1,21 @@
+
+project(*idl): taoidldefaults {
+ IDL_Files {
+ Test.idl
+ }
+ custom_only = 1
+}
+
+project (*Oneway_scenarios) : taoexe, messaging, iortable {
+ exename = oneway_test
+ after += *idl
+
+ Source_Files {
+ main.cpp
+ Server.cpp
+ Client.cpp
+ TestC.cpp
+ TestS.cpp
+ Test_i.cpp
+ }
+}
diff --git a/TAO/tests/Oneway_Send_Timeouts/Server.cpp b/TAO/tests/Oneway_Send_Timeouts/Server.cpp
new file mode 100644
index 00000000000..f11a84dbe31
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/Server.cpp
@@ -0,0 +1,205 @@
+
+#include "Server.h"
+
+#include "ace/Get_Opt.h"
+#include "ace/ARGV.h"
+#include "ace/OS_NS_strings.h"
+
+void replace (ACE_TCHAR** a, ACE_TCHAR** b)
+ {
+ ACE_TCHAR* tmp = *a;
+
+ *a = *b;
+ *b = tmp;
+ }
+
+Server::Server (int , ACE_TCHAR* argv[])
+ : init_ (false), shutdown_ (false)
+ , orb_shutdown_ (false), management_orb_shutdown_ (false)
+{
+ try {
+ ACE_ARGV args_1 (argv);
+ ACE_ARGV args_2 (argv);
+
+ /*
+ for (int my_count = 0; my_count < args_1.argc(); my_count++) {
+ ACE_DEBUG ((LM_DEBUG, "<%d, %s> ", my_count, (args_1.argv())[my_count]));
+ }
+ ACE_DEBUG ((LM_DEBUG, "\n"));
+ */
+
+ ACE_TCHAR** my_argv = args_1.argv ();
+ int my_argc = args_1.argc ();
+ int count = 0;
+ for (count = my_argc-1; count > -1; count--) {
+ if (ACE_OS::strcasecmp ("-ORBEndpoint", my_argv[count]) == 0) {
+ break;
+ }
+ }
+ if (count > my_argc-2){
+ // check if less than 2-last position.
+ return;
+ }
+ replace (&(my_argv[count]), &(my_argv[my_argc-2]));
+ replace (&(my_argv[count+1]), &(my_argv[my_argc-1]));
+
+ my_argc--; my_argc--;
+ orb_ = CORBA::ORB_init (my_argc, my_argv, "Server");
+
+ my_argv = args_2.argv();
+ my_argc = args_2.argc();
+ for (count = 0; count < my_argc; count++) {
+ if (ACE_OS::strcasecmp ("-ORBEndpoint", my_argv[count]) == 0) {
+ break;
+ }
+ }
+ if (count > my_argc-2) {
+ // check if less than 2-last position.
+ return;
+ }
+ replace (&(my_argv[count]), &(my_argv[my_argc-2]));
+ replace (&(my_argv[count+1]), &(my_argv[my_argc-1]));
+
+ // initialize management ORB
+ my_argc--; my_argc--;
+ management_orb_ = CORBA::ORB_init (my_argc, my_argv, "Management");
+
+ if (!this->parse_args (my_argc, my_argv))
+ return;
+
+ CORBA::Object_var obj = orb_->resolve_initial_references ("RootPOA");
+ PortableServer::POA_var root_poa = PortableServer::POA::_narrow (obj.in ());
+ PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();
+
+ test_i_.reset (new Test_i (orb_.in()));
+ PortableServer::ObjectId_var oid = root_poa->activate_object (test_i_.get());
+ obj = root_poa->id_to_reference (oid);
+ Test_var test_obj = Test::_narrow (obj);
+
+ std::string ior = orb_->object_to_string (test_obj.in ());
+ obj = orb_->resolve_initial_references("IORTable");
+ IORTable::Table_var table = IORTable::Table::_narrow (obj.in());
+ table->bind ("Test", ior.c_str());
+
+ poa_manager->activate ();
+
+ // initialize management objects
+
+ obj = management_orb_->resolve_initial_references ("RootPOA");
+ PortableServer::POA_var management_root_poa = PortableServer::POA::_narrow (obj.in ());
+ PortableServer::POAManager_var management_poa_manager = management_root_poa->the_POAManager ();
+
+ oid = management_root_poa->activate_object (test_i_.get());
+ obj = management_root_poa->id_to_reference (oid);
+ test_obj = Test::_narrow (obj);
+
+ ior = orb_->object_to_string (test_obj.in ());
+ obj = management_orb_->resolve_initial_references("IORTable");
+ table = IORTable::Table::_narrow (obj.in());
+ table->bind ("Management", ior.c_str());
+
+ management_poa_manager->activate ();
+ }
+ catch( CORBA::Exception& ex) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) Server> Caught CORBA::Exception %s"
+ , ex._info().c_str()));
+ return;
+ }
+
+ init_ = true;
+}
+
+Server::~Server ()
+{
+ this->shutdown ();
+}
+
+bool
+Server::parse_args (int argc, ACE_TCHAR* argv[])
+{
+ for (int my_count = 0; my_count < argc; my_count++) {
+ ACE_DEBUG ((LM_DEBUG, "<%d, %s> ", my_count, argv[my_count]));
+ }
+ ACE_DEBUG ((LM_DEBUG, "\n"));
+
+
+ ACE_Get_Opt get_opts (argc, argv, "");
+ int c;
+
+ while ((c = get_opts ()) != -1) {
+ switch (c)
+ {
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR, "Invalid option \'-%c\'\n", c)
+ , false);
+ }
+ }
+
+ return true;
+}
+
+bool
+Server::run (bool management)
+{
+ bool status = true;
+
+ try {
+ if (!management) {
+ orb_->run ();
+ orb_shutdown_ = true;
+ }
+ }
+ catch( CORBA::Exception& ex) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) Server::run> Caught CORBA::Exception %s in worker ORB\n"
+ , ex._info().c_str()));
+ status = false;
+ }
+
+ try {
+ if (management) {
+ management_orb_->run();
+ management_orb_shutdown_ = true;
+ }
+ }
+ catch( CORBA::Exception& ex) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) Server::run> Caught CORBA::Exception %s in management ORB\n"
+ , ex._info().c_str()));
+ status = false;
+ }
+
+ return status;
+}
+
+void
+Server::shutdown ()
+{
+ ACE_GUARD (ACE_SYNCH_MUTEX, ace_mon, this->mutex_);
+ if (shutdown_) {
+ return;
+ }
+
+ try {
+ management_orb_->shutdown (1);
+
+ ACE_Time_Value sleep_time;
+ sleep_time.msec (10);
+ while (true) {
+ ACE_OS::sleep (sleep_time);
+ if (management_orb_shutdown_ && orb_shutdown_) {
+ break;
+ }
+ }
+
+ orb_->destroy ();
+ orb_ = CORBA::ORB::_nil();
+ management_orb_->destroy ();
+ management_orb_ = CORBA::ORB::_nil();
+ }
+ catch( CORBA::Exception& ex) {
+ ACE_ERROR ((LM_ERROR, "(%P|%t) Server::run> Caught CORBA::Exception %s"
+ , ex._info().c_str()));
+
+ }
+
+ shutdown_ = true;
+}
diff --git a/TAO/tests/Oneway_Send_Timeouts/Server.h b/TAO/tests/Oneway_Send_Timeouts/Server.h
new file mode 100644
index 00000000000..a19949e28fc
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/Server.h
@@ -0,0 +1,37 @@
+#ifndef _SERVER_
+#define _SERVER_
+
+#include "Test_i.h"
+
+#include "ORB_Task.h"
+
+#include "tao/IORTable/IORTable.h"
+#include "tao/PortableServer/POAC.h"
+#include "tao/PortableServer/POAManagerC.h"
+
+#include <string>
+
+class Server
+{
+ public:
+ Server (int argc, ACE_TCHAR* argv[]);
+ ~Server ();
+
+ bool run (bool management);
+ void shutdown ();
+
+ bool init_;
+
+ private:
+ bool parse_args (int argc, ACE_TCHAR* argv[]);
+
+ CORBA::ORB_var orb_;
+ CORBA::ORB_var management_orb_;
+ bool shutdown_;
+ TAO_SYNCH_MUTEX mutex_;
+ std::auto_ptr<Test_i> test_i_;
+ bool orb_shutdown_;
+ bool management_orb_shutdown_;
+};
+
+#endif //_SERVER_
diff --git a/TAO/tests/Oneway_Send_Timeouts/Server_Task.h b/TAO/tests/Oneway_Send_Timeouts/Server_Task.h
new file mode 100644
index 00000000000..eed5452d9b0
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/Server_Task.h
@@ -0,0 +1,70 @@
+#ifndef _SERVER_TASK_
+#define _SERVER_TASK_
+
+#include "Server.h"
+
+#include "ace/Task.h"
+#include "ace/ARGV.h"
+
+class Server_Task : public ACE_Task_Base
+{
+ public:
+
+ Server_Task (const std::string& args)
+ : args_ (args)
+ { }
+ ~Server_Task ()
+ {
+ this->force_shutdown ();
+ }
+
+ virtual int svc ()
+ {
+ bool initializer = false;
+ {
+ ACE_GUARD_RETURN (ACE_SYNCH_MUTEX, ace_mon, this->mutex_, -1);
+ if (server_.get() == 0) {
+ ACE_ARGV my_args (args_.c_str());
+
+ // Initialize Server ORB in new thread
+ server_.reset (new Server (my_args.argc(), my_args.argv()));
+ ACE_ASSERT (server_.get() != 0);
+ initializer = true;
+ }
+ }
+
+ if (initializer) {
+ server_->run (false);
+ }
+ else {
+ server_->run (true);
+ }
+
+ this->force_shutdown ();
+
+ return 0;
+ }
+
+ bool ready ()
+ {
+ if (server_.get() != 0) {
+ return server_->init_;
+ }
+
+ return false;
+ }
+
+ void force_shutdown ()
+ {
+ if (server_.get() != 0) {
+ server_->shutdown ();
+ }
+ }
+
+ private:
+ std::string args_;
+ std::auto_ptr<Server> server_;
+ TAO_SYNCH_MUTEX mutex_;
+};
+
+#endif //_SERVER_TASK_
diff --git a/TAO/tests/Oneway_Send_Timeouts/Test.idl b/TAO/tests/Oneway_Send_Timeouts/Test.idl
new file mode 100644
index 00000000000..9f0a7fcf03e
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/Test.idl
@@ -0,0 +1,18 @@
+
+interface Test
+{
+ // sleep for the said time, unless u head from
+ // client earlier. If both sec and msec are 0,
+ // sleep untill client wakes u up.
+ oneway void sleep (in long sec, in long msec);
+ void unsleep ();
+
+ // the server will ignore the message string.
+ // An interface to send variable length strings across the
+ // physical layer.
+ oneway void dummy_one_way (in string msg);
+
+ void dummy_two_way ();
+
+ void shutdown ();
+};
diff --git a/TAO/tests/Oneway_Send_Timeouts/Test_i.cpp b/TAO/tests/Oneway_Send_Timeouts/Test_i.cpp
new file mode 100644
index 00000000000..b472a1f8430
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/Test_i.cpp
@@ -0,0 +1,87 @@
+
+#include "Test_i.h"
+
+#include "ace/High_Res_Timer.h"
+#include "ace/OS_NS_unistd.h"
+
+Test_i::Test_i (CORBA::ORB_ptr orb)
+ : sleep_ (false), unsleep_ (true)
+ , orb_ (CORBA::ORB::_duplicate (orb))
+{ }
+
+Test_i::~Test_i ()
+{
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) ~Test_i>\n"));
+}
+
+void
+Test_i::sleep (CORBA::Long sec, CORBA::Long msec)
+ ACE_THROW_SPEC ((::CORBA::SystemException))
+{
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Test_i::sleep> enter\n"));
+ sleep_ = true;
+ unsleep_ = false;
+
+ ACE_Time_Value duration (sec);
+ duration.msec (msec);
+
+ if (sec == 0 && msec == 0) {
+ // 1000 seconds is infinity
+ duration.sec (1000);
+ }
+
+ ACE_Time_Value current = ACE_High_Res_Timer::gettimeofday_hr ();
+ ACE_Time_Value timeout = current + duration;
+
+ ACE_Time_Value sleep_time;
+ sleep_time.msec (10);
+ while (current < timeout) {
+ if (!sleep_) {
+ break;
+ }
+ ACE_OS::sleep (sleep_time);
+ current += sleep_time;
+ }
+ sleep_ = false;
+ unsleep_ = true;
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Test_i::sleep> exit\n"));
+}
+
+void
+Test_i::unsleep ()
+ ACE_THROW_SPEC ((::CORBA::SystemException))
+{
+ sleep_ = false;
+
+ ACE_Time_Value sleep_time;
+ sleep_time.msec (10);
+ while (unsleep_ == false) {
+ ACE_OS::sleep (sleep_time);
+ }
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Test_i::unsleep>\n"));
+}
+
+void
+Test_i::dummy_one_way (const char* msg)
+ ACE_THROW_SPEC ((::CORBA::SystemException))
+{
+ if (msg != 0) {
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Test_i::dummy_one_way> %.25s\n", msg));
+ }
+ // do nothing
+}
+
+void
+Test_i::dummy_two_way ()
+ ACE_THROW_SPEC ((::CORBA::SystemException))
+{
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Test_i::dummy_two_way>\n"));
+}
+
+void
+Test_i::shutdown ()
+ ACE_THROW_SPEC ((::CORBA::SystemException))
+{
+ orb_->shutdown (0);
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) Test_i::shutdown>\n"));
+}
diff --git a/TAO/tests/Oneway_Send_Timeouts/Test_i.h b/TAO/tests/Oneway_Send_Timeouts/Test_i.h
new file mode 100644
index 00000000000..7bbc346cd26
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/Test_i.h
@@ -0,0 +1,33 @@
+#ifndef _TEST_I_
+#define _TEST_I_
+
+#include "TestS.h"
+
+class Test_i : public virtual POA_Test
+{
+ public:
+ Test_i (CORBA::ORB_ptr orb);
+ virtual ~Test_i ();
+
+ virtual void sleep (CORBA::Long sec, CORBA::Long msec)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual void unsleep ()
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual void dummy_one_way (const char* msg)
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual void dummy_two_way ()
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ virtual void shutdown ()
+ ACE_THROW_SPEC ((::CORBA::SystemException));
+
+ private:
+ volatile bool sleep_;
+ volatile bool unsleep_;
+ CORBA::ORB_var orb_;
+};
+
+#endif // _TEST_I_
diff --git a/TAO/tests/Oneway_Send_Timeouts/block_flush.conf b/TAO/tests/Oneway_Send_Timeouts/block_flush.conf
new file mode 100644
index 00000000000..9c379527209
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/block_flush.conf
@@ -0,0 +1 @@
+static Resource_Factory "-ORBFlushingStrategy blocking"
diff --git a/TAO/tests/Oneway_Send_Timeouts/lf_flush.conf b/TAO/tests/Oneway_Send_Timeouts/lf_flush.conf
new file mode 100644
index 00000000000..82425ab8e93
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/lf_flush.conf
@@ -0,0 +1 @@
+static Resource_Factory "-ORBFlushingStrategy leader_follower"
diff --git a/TAO/tests/Oneway_Send_Timeouts/main.cpp b/TAO/tests/Oneway_Send_Timeouts/main.cpp
new file mode 100644
index 00000000000..112b3a44271
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/main.cpp
@@ -0,0 +1,139 @@
+#include "Server_Task.h"
+#include "Client_Task.h"
+
+#include "ace/Log_Msg.h"
+#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_strings.h"
+#include "ace/High_Res_Timer.h"
+
+class MyMain
+{
+public:
+ MyMain (int argc, const ACE_TCHAR* argv[]);
+ ~MyMain ();
+
+ void run ();
+
+private:
+ void print_usage ();
+ bool init_server (const ACE_TCHAR* args);
+ bool init_client (const ACE_TCHAR* args);
+
+ std::auto_ptr<Server_Task> server_task_;
+ std::auto_ptr<Client_Task> client_task_;
+
+ bool s_init_;
+ bool shutdown_;
+};
+
+void
+MyMain::print_usage ()
+{
+}
+
+bool
+MyMain::init_server (const ACE_TCHAR* args)
+{
+ std::string my_args (args);
+ // main thread and extra thread for backdoor operations
+ int thread_pool = 2;
+
+ server_task_.reset (new Server_Task (my_args));
+ ACE_ASSERT (server_task_.get() != 0);
+
+ server_task_->activate (THR_NEW_LWP | THR_JOINABLE |THR_INHERIT_SCHED
+ , thread_pool);
+
+ int duration = 4; //wait 3 seconds for initialization
+ ACE_Time_Value current = ACE_High_Res_Timer::gettimeofday_hr ();
+ ACE_Time_Value timeout = current + ACE_Time_Value(duration);
+
+ while (current < timeout) {
+ if (server_task_->ready()) {
+ break;
+ }
+ ACE_Time_Value sleep_time;
+ sleep_time.msec (10);
+ ACE_OS::sleep (sleep_time);
+ current += sleep_time;
+ }
+
+ if (!server_task_->ready()) {
+ server_task_->force_shutdown ();
+ server_task_.reset (0);
+ return false;
+ }
+
+ return true;
+}
+
+bool
+MyMain::init_client (const ACE_TCHAR* args)
+{
+ std::string my_args (args);
+ int thread_pool = 1;
+
+ client_task_.reset (new Client_Task (my_args));
+ ACE_ASSERT (client_task_.get() != 0);
+
+ client_task_->activate (THR_NEW_LWP | THR_JOINABLE |THR_INHERIT_SCHED
+ , thread_pool);
+
+ return true;
+}
+
+MyMain::MyMain (int argc, const ACE_TCHAR* argv[])
+ : s_init_ (false), shutdown_ (false)
+{
+ argc--;
+ for (int p = 1; p <= argc; p++)
+ {
+ if (ACE_OS::strcmp (argv[p], "-?") == 0) {
+ print_usage ();
+ return;
+ }
+
+ if (ACE_OS::strcasecmp (argv[p], "-s") == 0) {
+ const ACE_TCHAR* s_args = (((p+1) <= argc) ? argv[p+1] : NULL);
+ s_init_ = this->init_server (s_args);
+ p++;
+ }
+ else if (ACE_OS::strcasecmp (argv[p], "-c") == 0) {
+ const ACE_TCHAR* s_args = (((p+1) <= argc) ? argv[p+1] : NULL);
+ if (s_init_) {
+ this->init_client (s_args);
+ }
+ p++;
+ }
+ }
+}
+
+void
+MyMain::run ()
+{
+ if (server_task_.get() != 0) {
+ server_task_->wait ();
+ }
+
+ if (client_task_.get() != 0) {
+ client_task_->wait ();
+ }
+
+ shutdown_ = true;
+}
+
+MyMain::~MyMain ()
+{
+ if (!shutdown_) {
+ this->run ();
+ }
+}
+
+int ACE_TMAIN (int argc, const ACE_TCHAR* argv[])
+{
+ MyMain my_main (argc, argv);
+
+ my_main.run ();
+
+ return 0;
+}
diff --git a/TAO/tests/Oneway_Send_Timeouts/run_test.pl b/TAO/tests/Oneway_Send_Timeouts/run_test.pl
new file mode 100755
index 00000000000..4846b2b0768
--- /dev/null
+++ b/TAO/tests/Oneway_Send_Timeouts/run_test.pl
@@ -0,0 +1,62 @@
+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;
+$debug_level = '0';
+$test_port = 12345;
+$management_port = 12346;
+$client_conf = "lf_flush.conf";
+$flush_strategy = "LF";
+
+foreach $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = '10';
+ }
+ elsif ($i eq '-blocking') {
+ $client_conf = "block_flush.conf";
+ $flush_strategy = "BLOCKING";
+ }
+ else {
+ print STDERR "ERROR: Unknown option: $i\n";
+ exit 1;
+ }
+}
+
+my $test_opts = "-s \'-ORBEndpoint iiop://localhost:$test_port -ORBEndpoint " .
+ "iiop://localhost:$management_port -ORBDebuglevel $debug_level -ORBCollocation " .
+ "no -ORBGestalt LOCAL\' -c \'-k corbaloc::localhost:$test_port/Test -b " .
+ #"no\' -c \'-k corbaloc::localhost:$test_port/Test -b " .
+ "corbaloc::localhost:$management_port/Management -ORBDebuglevel $debug_level " .
+ "-ORBCollocation no -1 -ORBSvcConf $client_conf -f $flush_strategy " .
+ "-ORBGestalt LOCAL\'";
+
+if (PerlACE::is_vxworks_test()) {
+ $TV = new PerlACE::ProcessVX ("oneway_test", "$test_opts");
+}
+else {
+ $TV = new PerlACE::Process ("oneway_test", "$test_opts");
+}
+
+print $TV->CommandLine()."\n";
+$test = $TV->Spawn ();
+
+if ($test != 0) {
+ print STDERR "ERROR: test returned $test\n";
+ exit 1;
+}
+
+$test = $TV->WaitKill (10);
+
+if ($test != 0) {
+ print STDERR "ERROR 2: test returned $test\n";
+ $status = 1;
+}
+
+exit $status;