summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfields_t <fields_t@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2012-05-08 22:06:35 +0000
committerfields_t <fields_t@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2012-05-08 22:06:35 +0000
commite4802ffc13494e4f5a050a67299184cb15e94cc4 (patch)
tree3053e9094ebdf43282fcf2091bd2ba97396f7400
parenta2d4b5b499b3af8808c264c2964c3e7b6e53ed7b (diff)
downloadATCD-e4802ffc13494e4f5a050a67299184cb15e94cc4.tar.gz
ChangeLogTag: Tue May 8 22:01:10 UTC 2012 Trevor Fields <fields_t@ociweb.com>
-rw-r--r--TAO/ChangeLog26
-rw-r--r--TAO/bin/tao_orb_tests.lst1
-rw-r--r--TAO/tao/Synch_Invocation.cpp29
-rw-r--r--TAO/tests/Bug_4010_Regression/Bug_4010_Regression.mpc34
-rw-r--r--TAO/tests/Bug_4010_Regression/Hello.cpp19
-rw-r--r--TAO/tests/Bug_4010_Regression/Hello.h31
-rw-r--r--TAO/tests/Bug_4010_Regression/README42
-rw-r--r--TAO/tests/Bug_4010_Regression/Test.idl21
-rw-r--r--TAO/tests/Bug_4010_Regression/client.conf3
-rw-r--r--TAO/tests/Bug_4010_Regression/client.cpp145
-rwxr-xr-xTAO/tests/Bug_4010_Regression/run_test.pl131
-rw-r--r--TAO/tests/Bug_4010_Regression/server.cpp101
12 files changed, 583 insertions, 0 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index d32b34de9a2..33e26b25b09 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,29 @@
+Tue May 8 22:01:10 UTC 2012 Trevor Fields <fields_t@ociweb.com>
+
+ * tao/Synch_Invocation.cpp:
+
+ Change to oneway calls with Receive-Wait wait strategy and the
+ -ORBConnectionHandlerCleanup 1 to register the handle with the
+ reactor to detect connection closure. This fixes Bug 4010.
+
+ * tests/Bug_4010_Regression:
+ * tests/Bug_4010_Regression/Bug_4010_Regression.mpc:
+ * tests/Bug_4010_Regression/client.conf:
+ * tests/Bug_4010_Regression/client.cpp:
+ * tests/Bug_4010_Regression/Hello.cpp:
+ * tests/Bug_4010_Regression/Hello.h:
+ * tests/Bug_4010_Regression/README:
+ * tests/Bug_4010_Regression/run_test.pl:
+ * tests/Bug_4010_Regression/server.cpp:
+ * tests/Bug_4010_Regression/Test.idl:
+
+ Test for detecting connection loss from server restart after oneway
+ call.
+
+ * bin/tao_orb_tests.lst:
+
+ Added bug 4010 regression test.
+
Tue May 8 12:25:13 UTC 2012 Marijke Hengstmengel <m.hengstmengel@remedy.nl>
* TAO_IDL/be/be_visitor_operation/operation_ch.cpp:
diff --git a/TAO/bin/tao_orb_tests.lst b/TAO/bin/tao_orb_tests.lst
index b320a756b51..6df71cf2845 100644
--- a/TAO/bin/tao_orb_tests.lst
+++ b/TAO/bin/tao_orb_tests.lst
@@ -206,6 +206,7 @@ TAO/tests/Bug_3941_Regression/run_test.pl: !CORBA_E_MICRO
TAO/tests/Bug_3942_Regression/run_test.pl: !FIXED_BUGS_ONLY
TAO/tests/Bug_3953_Regression/run_test.pl: !CORBA_E_MICRO
TAO/tests/Bug_3954_Regression/run_test.pl:
+TAO/tests/Bug_4010_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/Synch_Invocation.cpp b/TAO/tao/Synch_Invocation.cpp
index c7ebfc0a670..40064362ca6 100644
--- a/TAO/tao/Synch_Invocation.cpp
+++ b/TAO/tao/Synch_Invocation.cpp
@@ -705,6 +705,35 @@ namespace TAO
s = this->send_message (cdr,
TAO_Message_Semantics (TAO_Message_Semantics::TAO_ONEWAY_REQUEST),
max_wait_time);
+
+ if (transport->wait_strategy ()->non_blocking () == 0 &&
+ transport->orb_core ()->client_factory ()->use_cleanup_options ())
+ {
+ if (!transport->wait_strategy ()->is_registered())
+ {
+ ACE_Event_Handler * const eh =
+ transport->event_handler_i ();
+
+ ACE_Reactor * const r =
+ transport->orb_core ()->reactor ();
+
+ if (r->register_handler (eh, ACE_Event_Handler::READ_MASK) == -1)
+ {
+ if (TAO_debug_level > 0)
+ ACE_ERROR ((LM_ERROR,
+ "TAO (%P|%t) - Synch_Oneway_Invocation::"
+ "remote_oneway transport[%d] registration with"
+ "reactor returned an error\n",
+ transport->id ()));
+ }
+ else
+ {
+ // Only set this flag when registration succeeds
+ transport->wait_strategy ()->is_registered(true);
+ }
+ }
+ }
+
}
else
{
diff --git a/TAO/tests/Bug_4010_Regression/Bug_4010_Regression.mpc b/TAO/tests/Bug_4010_Regression/Bug_4010_Regression.mpc
new file mode 100644
index 00000000000..444fdf21a37
--- /dev/null
+++ b/TAO/tests/Bug_4010_Regression/Bug_4010_Regression.mpc
@@ -0,0 +1,34 @@
+project(*idl): taoidldefaults {
+ idlflags += -Sp
+ IDL_Files {
+ Test.idl
+ }
+ custom_only = 1
+}
+
+project(*Server): taoserver {
+ after += *idl
+ Source_Files {
+ Hello.cpp
+ server.cpp
+ }
+ Source_Files {
+ TestC.cpp
+ TestS.cpp
+ }
+ IDL_Files {
+ }
+}
+
+project(*Client): taoclient {
+ after += *idl
+ Source_Files {
+ client.cpp
+ }
+ Source_Files {
+ TestC.cpp
+ }
+ IDL_Files {
+ }
+}
+
diff --git a/TAO/tests/Bug_4010_Regression/Hello.cpp b/TAO/tests/Bug_4010_Regression/Hello.cpp
new file mode 100644
index 00000000000..df49d37a507
--- /dev/null
+++ b/TAO/tests/Bug_4010_Regression/Hello.cpp
@@ -0,0 +1,19 @@
+// $Id$
+#include "Hello.h"
+
+Hello::Hello (CORBA::ORB_ptr orb)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+{
+}
+
+char *
+Hello::get_string (void)
+{
+ return CORBA::string_dup ("Hello there!");
+}
+
+void
+Hello::shutdown (void)
+{
+ this->orb_->shutdown (0);
+}
diff --git a/TAO/tests/Bug_4010_Regression/Hello.h b/TAO/tests/Bug_4010_Regression/Hello.h
new file mode 100644
index 00000000000..3a840d3d88d
--- /dev/null
+++ b/TAO/tests/Bug_4010_Regression/Hello.h
@@ -0,0 +1,31 @@
+//
+// $Id$
+//
+
+#ifndef HELLO_H
+#define HELLO_H
+#include /**/ "ace/pre.h"
+
+#include "TestS.h"
+
+/// Implement the Test::Hello interface
+class Hello
+ : public virtual POA_Test::Hello
+{
+public:
+ /// Constructor
+ Hello (CORBA::ORB_ptr orb);
+
+ // = The skeleton methods
+ virtual char * get_string (void);
+
+ virtual void shutdown (void);
+
+private:
+ /// Use an ORB reference to convert strings to objects and shutdown
+ /// the application.
+ CORBA::ORB_var orb_;
+};
+
+#include /**/ "ace/post.h"
+#endif /* HELLO_H */
diff --git a/TAO/tests/Bug_4010_Regression/README b/TAO/tests/Bug_4010_Regression/README
new file mode 100644
index 00000000000..8002cebf056
--- /dev/null
+++ b/TAO/tests/Bug_4010_Regression/README
@@ -0,0 +1,42 @@
+/**
+
+@page Bug 4010 Regression Test
+
+This test demonstrates bug 4010.
+
+The IDL and server code are unchanged from the basic Hello test.
+
+The client is modified to perform the Hello test periodically for
+different instances of the server.
+
+The server is run twice to demonstrate the client's attempt to reuse a stale
+connection from the first instance to contact an object reference from the second.
+The endpoint is assigned for the server to demonstrate the COMM_FAILURE exception on
+a stale transport.
+
+
+ To run the test use the run_test.pl script:
+
+$ ./run_test.pl
+
+ the script returns 0 if the test was successful.
+
+The expected output would look something like this -
+
+(7715|3072272080) - string returned <Hello there!>
+(7714|3070171360) server - event loop finished
+(7715|3072272080) - shutdown requested
+(7715|3072272080) - string returned <Hello there!>
+(7715|3072272080) - shutdown requested
+(7716|3071477984) server - event loop finished
+
+With the bug, the output looks like this -
+(7731|3072239312) - string returned <Hello there!>
+(7724|3072022752) server - event loop finished
+(7731|3072239312) - shutdown requested
+(7731|3072239312) EXCEPTION, Exception caught:
+system exception, ID 'IDL:omg.org/CORBA/COMM_FAILURE:1.0'
+TAO exception, minor code = 0 (failed to recv request response; unspecified errno), completed = MAYBE
+
+*/
+
diff --git a/TAO/tests/Bug_4010_Regression/Test.idl b/TAO/tests/Bug_4010_Regression/Test.idl
new file mode 100644
index 00000000000..385943134bd
--- /dev/null
+++ b/TAO/tests/Bug_4010_Regression/Test.idl
@@ -0,0 +1,21 @@
+//
+// $Id$
+//
+
+/// Put the interfaces in a module, to avoid global namespace pollution
+module Test
+{
+ /// A very simple interface
+ interface Hello
+ {
+ /// Return a simple string
+ string get_string ();
+
+ /// A method to shutdown the ORB
+ /**
+ * This method is used to simplify the test shutdown process
+ */
+ oneway void shutdown ();
+// void shutdown ();
+ };
+};
diff --git a/TAO/tests/Bug_4010_Regression/client.conf b/TAO/tests/Bug_4010_Regression/client.conf
new file mode 100644
index 00000000000..aecebacb387
--- /dev/null
+++ b/TAO/tests/Bug_4010_Regression/client.conf
@@ -0,0 +1,3 @@
+static Client_Strategy_Factory "-ORBWaitStrategy rw -ORBTransportMuxStrategy exclusive -ORBConnectStrategy blocked -ORBConnectionHandlerCleanup 1"
+static Resource_Factory "-ORBFlushingStrategy blocking"
+
diff --git a/TAO/tests/Bug_4010_Regression/client.cpp b/TAO/tests/Bug_4010_Regression/client.cpp
new file mode 100644
index 00000000000..2ab34b3a5e7
--- /dev/null
+++ b/TAO/tests/Bug_4010_Regression/client.cpp
@@ -0,0 +1,145 @@
+#include "TestC.h"
+#include "ace/Get_Opt.h"
+#include "tao/ORB_Core.h"
+#include "ace/Reactor.h"
+#include "ace/Event_Handler.h"
+
+const ACE_TCHAR *ior = ACE_TEXT ("file://test.ior");
+int iterations = 3;
+int timeout = 10;
+int process_result = 1;
+
+int parse_args (int argc, ACE_TCHAR *argv[])
+{
+ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("k:i:t:"));
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'k':
+ ior = get_opts.opt_arg ();
+ break;
+ case 'i':
+ iterations = ACE_OS::atoi(get_opts.opt_arg ());
+ break;
+ case 't':
+ timeout = ACE_OS::atoi(get_opts.opt_arg ());
+ break;
+
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-k <ior> "
+ "-i <iterations> "
+ "-t <timeout> "
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates successful parsing of the command line
+ return 0;
+}
+
+class PeriodicTask : public ACE_Event_Handler
+{
+public:
+
+ explicit PeriodicTask(CORBA::ORB_var orbIn)
+ : ACE_Event_Handler(),
+ orb(orbIn),
+ iterationsLeft(iterations),
+ successfulConnections(0)
+ {
+ }
+
+ virtual ~PeriodicTask()
+ {
+ }
+
+ virtual int handle_timeout(const ACE_Time_Value &, const void *)
+ {
+ --iterationsLeft;
+
+ try
+ {
+ ACE_DEBUG ((LM_DEBUG,
+ "\n(%P|%t) - handling timeout with %d iterations left\n",
+ iterationsLeft + 1));
+ CORBA::Object_var tmp = orb->string_to_object(ior);
+
+ Test::Hello_var hello = Test::Hello::_narrow(tmp.in ());
+
+ if (CORBA::is_nil (hello.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ "Nil Test::Hello reference <%s>\n",
+ ior),
+ 1);
+ }
+
+ CORBA::String_var the_string = hello->get_string ();
+
+ ++successfulConnections;
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n",
+ the_string.in ()));
+ ACE_OS::sleep(2);
+ hello->shutdown ();
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) - shutdown requested\n"));
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught:");
+ process_result = 1;
+ orb->shutdown();
+ }
+
+ if(successfulConnections == 2)
+ {
+ process_result = 0;
+ orb->shutdown();
+ }
+
+ return 0;
+ }
+
+protected:
+
+private:
+
+ PeriodicTask(const PeriodicTask &);
+ PeriodicTask & operator=(const PeriodicTask &);
+ CORBA::ORB_var orb;
+ int iterationsLeft;
+ int successfulConnections;
+};
+
+int
+ACE_TMAIN(int argc, ACE_TCHAR *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ PeriodicTask periodicTask(orb);
+
+ orb->orb_core()->reactor()->schedule_timer(&periodicTask, 0, ACE_Time_Value::zero, ACE_Time_Value(timeout));
+
+ orb->run();
+
+ orb->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught:");
+ return 1;
+ }
+
+ return process_result;
+}
+
diff --git a/TAO/tests/Bug_4010_Regression/run_test.pl b/TAO/tests/Bug_4010_Regression/run_test.pl
new file mode 100755
index 00000000000..e5af4599a7d
--- /dev/null
+++ b/TAO/tests/Bug_4010_Regression/run_test.pl
@@ -0,0 +1,131 @@
+eval '(exit $?0)' && eval 'exec perl -S $0 ${1+"$@"}'
+ & eval 'exec perl -S $0 $argv:q'
+ if 0;
+
+use lib "$ENV{ACE_ROOT}/bin";
+use PerlACE::TestTarget;
+
+$status = 0;
+$debug_level = '0';
+$cdebug_level = '0';
+foreach $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = '10';
+ }
+ if ($i eq '-cdebug') {
+ $cdebug_level = '10';
+ }
+}
+
+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";
+
+my $iorbase = "server.ior";
+my $server_iorfile = $server->LocalFile ($iorbase);
+my $client_iorfile = $client->LocalFile ($iorbase);
+$server->DeleteFile($iorbase);
+$client->DeleteFile($iorbase);
+
+my $client_conf_file = "client.conf";
+my $client_conf = $client->LocalFile ($client_conf_file);
+
+# copy the configuation file
+if ($client->PutFile ($client_conf_file) == -1) {
+ print STDERR "ERROR: cannot set file <$client_conf>\n";
+ exit 1;
+}
+
+$port = $server->RandomPort ();
+$iterations = 4;
+$loop_time = $server->ProcessStartWaitInterval() + $server->ProcessStopWaitInterval() + 2;
+
+$SV1 = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile -ORBListenEndpoints iiop://:${port}");
+$SV2 = $server->CreateProcess ("server", "-ORBdebuglevel $debug_level -o $server_iorfile -ORBListenEndpoints iiop://:${port}");
+$CL = $client->CreateProcess ("client", "-ORBdebuglevel $cdebug_level -ORBSvcConf $client_conf -k file://$client_iorfile -t $loop_time -i $iterations");
+
+print $SV1->CommandLine() . "\n\n";
+print $CL->CommandLine() . "\n\n";
+
+$server_status = $SV1->Spawn ();
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ exit 1;
+}
+
+if ($server->WaitForFileTimed ($iorbase,
+ $server->ProcessStartWaitInterval()) == -1) {
+ print STDERR "ERROR: cannot find file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+
+if ($server->GetFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+
+$client_status = $CL->Spawn ();
+
+$server_status = $SV1->WaitKill ($loop_time + $server->ProcessStopWaitInterval());
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ $status = 1;
+}
+
+$server->DeleteFile($iorbase);
+$client->DeleteFile($iorbase);
+
+sleep 10;
+print "\nSpawning second server\n\n";
+$server_status = $SV2->Spawn ();
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ $status = 1;
+}
+
+if ($server->WaitForFileTimed ($iorbase,
+ $server->ProcessStartWaitInterval()) == -1) {
+ print STDERR "ERROR: cannot find file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+
+if ($server->GetFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot retrieve file <$server_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+if ($client->PutFile ($iorbase) == -1) {
+ print STDERR "ERROR: cannot set file <$client_iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+
+$server_status = $SV2->WaitKill ( (2 * $loop_time) + $server->ProcessStopWaitInterval());
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ $status = 1;
+}
+
+$client_status = $CL->WaitKill ($client->ProcessStopWaitInterval());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$server->DeleteFile($iorbase);
+$client->DeleteFile($iorbase);
+
+exit $status;
+
diff --git a/TAO/tests/Bug_4010_Regression/server.cpp b/TAO/tests/Bug_4010_Regression/server.cpp
new file mode 100644
index 00000000000..205a7c179e0
--- /dev/null
+++ b/TAO/tests/Bug_4010_Regression/server.cpp
@@ -0,0 +1,101 @@
+// $Id$
+
+#include "Hello.h"
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_stdio.h"
+
+const ACE_TCHAR *ior_output_file = ACE_TEXT ("test.ior");
+
+int
+parse_args (int argc, ACE_TCHAR *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, ACE_TEXT("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 successful parsing of the command line
+ return 0;
+}
+
+int
+ACE_TMAIN(int argc, ACE_TCHAR *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb =
+ CORBA::ORB_init (argc, argv);
+
+ CORBA::Object_var poa_object =
+ orb->resolve_initial_references("RootPOA");
+
+ PortableServer::POA_var root_poa =
+ PortableServer::POA::_narrow (poa_object.in ());
+
+ if (CORBA::is_nil (root_poa.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Panic: nil RootPOA\n"),
+ 1);
+
+ PortableServer::POAManager_var poa_manager = root_poa->the_POAManager ();
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ Hello *hello_impl = 0;
+ ACE_NEW_RETURN (hello_impl,
+ Hello (orb.in ()),
+ 1);
+ PortableServer::ServantBase_var owner_transfer(hello_impl);
+
+ PortableServer::ObjectId_var id =
+ root_poa->activate_object (hello_impl);
+
+ CORBA::Object_var object = root_poa->id_to_reference (id.in ());
+
+ Test::Hello_var hello = Test::Hello::_narrow (object.in ());
+
+ CORBA::String_var ior = orb->object_to_string (hello.in ());
+
+ // Output the IOR to the <ior_output_file>
+ 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\n",
+ ior_output_file),
+ 1);
+ ACE_OS::fprintf (output_file, "%s", ior.in ());
+ ACE_OS::fclose (output_file);
+
+ poa_manager->activate ();
+
+ orb->run ();
+
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n"));
+
+ root_poa->destroy (1, 1);
+
+ orb->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught:");
+ return 1;
+ }
+
+ return 0;
+}