summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Mitz <mitza@objectcomputing.com>2018-03-09 18:28:50 -0600
committerGitHub <noreply@github.com>2018-03-09 18:28:50 -0600
commitc98fc602a862b2462140e298defcbc7c799e1328 (patch)
treea07678727dae88ba33f5f3ddf69658d57766828e
parent4cbfbc87e403652de1493685778392309524a095 (diff)
parent66e84f43246a74b1efadf60ff7aef1146a853c98 (diff)
downloadATCD-c98fc602a862b2462140e298defcbc7c799e1328.tar.gz
Merge pull request #588 from mitza-oci/shmiop
Bug 1220 fix applied to SHMIOP (fixed for IIOP long ago).
-rw-r--r--TAO/bin/tao_orb_tests.lst3
-rw-r--r--TAO/tao/Strategies/SHMIOP_Acceptor.cpp15
-rw-r--r--TAO/tao/Strategies/SHMIOP_Connector.cpp9
-rw-r--r--TAO/tao/Synch_Invocation.cpp20
-rw-r--r--TAO/tests/SHMIOP/SHMIOP_Test.mpc11
-rw-r--r--TAO/tests/SHMIOP/Test.idl9
-rw-r--r--TAO/tests/SHMIOP/run_test.pl84
-rw-r--r--TAO/tests/SHMIOP/run_test_collocated.pl40
-rw-r--r--TAO/tests/SHMIOP/shmiop_test.cpp126
-rw-r--r--TAO/tests/SHMIOP/static_shmiop.conf1
10 files changed, 294 insertions, 24 deletions
diff --git a/TAO/bin/tao_orb_tests.lst b/TAO/bin/tao_orb_tests.lst
index fc10728010b..3d5431de636 100644
--- a/TAO/bin/tao_orb_tests.lst
+++ b/TAO/bin/tao_orb_tests.lst
@@ -267,6 +267,9 @@ TAO/tests/No_Server_MT_Connect_Test/run_test.pl: !ST !MINIMUM !CORBA_E_COMPACT !
TAO/tests/Connect_Strategy_Test/run_test.pl:
# DISABLED TAO/tests/Client_Leaks/run_test.pl: !VxWorks !ST !Tru64
TAO/tests/Server_Leaks/run_test.pl: !ANDROID
+TAO/tests/SHMIOP/run_test_collocated.pl: !ACE_FOR_TAO
+TAO/tests/SHMIOP/run_test.pl: !ACE_FOR_TAO
+TAO/tests/SHMIOP/run_test.pl with_collocated: !ACE_FOR_TAO
TAO/tests/Smart_Proxies/Policy/run_test.pl:
TAO/tests/Smart_Proxies/run_test.pl:
TAO/tests/Smart_Proxies/dtor/run_test.pl:
diff --git a/TAO/tao/Strategies/SHMIOP_Acceptor.cpp b/TAO/tao/Strategies/SHMIOP_Acceptor.cpp
index 2a582f8e2a5..83443fd6430 100644
--- a/TAO/tao/Strategies/SHMIOP_Acceptor.cpp
+++ b/TAO/tao/Strategies/SHMIOP_Acceptor.cpp
@@ -153,18 +153,9 @@ TAO_SHMIOP_Acceptor::is_collocated (const TAO_Endpoint *endpoint)
if (endp == 0)
return 0;
- // @@ TODO The following code looks funky, why only the host
- // name is compared? What if there are multiple SHMIOP
- // servers in the same address? Why do SHMIOP_Endpoints keep
- // a INET_Addr but not a MEM_Addr? And why is there no lazy
- // evaluation of IP-addresses for SHMIOP endpoints? Is it
- // because it is always 'localhost'? We need answers to
- // these questions to solve:
- //
- // http://deuce.doc.wustl.edu/bugzilla/show_bug.cgi?id=1220
- //
- // The following code is suspec
- // compare the port and sin_addr (numeric host address)
+ if (endp->port () != this->address_.get_port_number ())
+ return 0;
+
return this->address_.same_host (endp->object_addr ());
}
diff --git a/TAO/tao/Strategies/SHMIOP_Connector.cpp b/TAO/tao/Strategies/SHMIOP_Connector.cpp
index bcf909b54ee..3f0532eb050 100644
--- a/TAO/tao/Strategies/SHMIOP_Connector.cpp
+++ b/TAO/tao/Strategies/SHMIOP_Connector.cpp
@@ -96,8 +96,14 @@ TAO_SHMIOP_Connector::set_validate_endpoint (TAO_Endpoint *endpoint)
// Verify that the remote ACE_INET_Addr was initialized properly.
// Failure can occur if hostname lookup failed when initializing the
// remote ACE_INET_Addr.
- if (remote_address.get_type () != AF_INET)
+ switch (remote_address.get_type ())
{
+ case AF_INET:
+#ifdef ACE_HAS_IPV6
+ case AF_INET6:
+#endif
+ break;
+ default:
if (TAO_debug_level > 0)
{
TAOLIB_ERROR ((LM_ERROR,
@@ -111,7 +117,6 @@ TAO_SHMIOP_Connector::set_validate_endpoint (TAO_Endpoint *endpoint)
}
return 0;
-
}
TAO_Transport *
diff --git a/TAO/tao/Synch_Invocation.cpp b/TAO/tao/Synch_Invocation.cpp
index c2159dc9049..5cc60f9ad17 100644
--- a/TAO/tao/Synch_Invocation.cpp
+++ b/TAO/tao/Synch_Invocation.cpp
@@ -126,18 +126,18 @@ namespace TAO
{
if (this->retry_state_ &&
this->retry_state_->forward_on_exception_increment(FOE_TRANSIENT))
- {
- if (TAO_debug_level > 0)
- TAOLIB_DEBUG ((LM_INFO,
- ACE_TEXT ("TAO (%P|%t) - Synch_Twoway_Invocation::")
- ACE_TEXT ("remote_twoway retrying on TRANSIENT ")
- ACE_TEXT ("exception\n")));
- this->retry_state_->next_profile_retry (*this->stub ());
+ {
+ if (TAO_debug_level > 0)
+ TAOLIB_DEBUG ((LM_INFO,
+ ACE_TEXT ("TAO (%P|%t) - Synch_Twoway_Invocation::")
+ ACE_TEXT ("remote_twoway retrying on TRANSIENT ")
+ ACE_TEXT ("exception\n")));
+ this->retry_state_->next_profile_retry (*this->stub ());
#if TAO_HAS_INTERCEPTORS == 1
- s = this->receive_other_interception ();
+ s = this->receive_other_interception ();
#endif /* TAO_HAS_INTERCEPTORS */
- return TAO_INVOKE_RESTART;
- }
+ return TAO_INVOKE_RESTART;
+ }
else
{
// Way back, we failed to find a profile we could connect to.
diff --git a/TAO/tests/SHMIOP/SHMIOP_Test.mpc b/TAO/tests/SHMIOP/SHMIOP_Test.mpc
new file mode 100644
index 00000000000..8ccc71387cc
--- /dev/null
+++ b/TAO/tests/SHMIOP/SHMIOP_Test.mpc
@@ -0,0 +1,11 @@
+project: taoidldefaults, taoserver, strategies {
+ exename = shmiop_test
+
+ IDL_Files {
+ Test.idl
+ }
+
+ Source_Files {
+ shmiop_test.cpp
+ }
+}
diff --git a/TAO/tests/SHMIOP/Test.idl b/TAO/tests/SHMIOP/Test.idl
new file mode 100644
index 00000000000..1f8ff5e7970
--- /dev/null
+++ b/TAO/tests/SHMIOP/Test.idl
@@ -0,0 +1,9 @@
+module Test
+{
+ interface Hello
+ {
+ string get_string ();
+
+ oneway void shutdown ();
+ };
+};
diff --git a/TAO/tests/SHMIOP/run_test.pl b/TAO/tests/SHMIOP/run_test.pl
new file mode 100644
index 00000000000..a4b44408ed5
--- /dev/null
+++ b/TAO/tests/SHMIOP/run_test.pl
@@ -0,0 +1,84 @@
+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;
+use strict;
+
+my $status = 0;
+my $debug_level = 0;
+my $cdebug_level = 0;
+my $extra;
+foreach my $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = 10;
+ }
+ elsif ($i eq '-cdebug') {
+ $cdebug_level = 10;
+ }
+ elsif ($i eq 'with_collocated') {
+ $extra = "-s temp.ior";
+ }
+}
+
+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 $shm = '-ORBSvcConf static_shmiop.conf -ORBListenEndpoints shmiop://';
+
+my $SV = $server->CreateProcess ("shmiop_test", "-ORBDebugLevel $debug_level $shm -s $server_iorfile");
+my $CL = $client->CreateProcess ("shmiop_test", "-ORBDebugLevel $cdebug_level $shm -c $client_iorfile $extra");
+my $server_status = $SV->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;
+}
+
+my $client_status = $CL->SpawnWaitKill ($client->ProcessStartWaitInterval ());
+
+if ($client_status != 0) {
+ print STDERR "ERROR: client returned $client_status\n";
+ $status = 1;
+}
+
+$server_status = $SV->WaitKill ($server->ProcessStopWaitInterval ());
+
+if ($server_status != 0) {
+ print STDERR "ERROR: server returned $server_status\n";
+ $status = 1;
+}
+
+$server->DeleteFile ($iorbase);
+$client->DeleteFile ($iorbase);
+
+if ($extra ne '') {
+ unlink 'temp.ior';
+}
+
+exit $status;
diff --git a/TAO/tests/SHMIOP/run_test_collocated.pl b/TAO/tests/SHMIOP/run_test_collocated.pl
new file mode 100644
index 00000000000..2a6f251b73a
--- /dev/null
+++ b/TAO/tests/SHMIOP/run_test_collocated.pl
@@ -0,0 +1,40 @@
+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;
+use strict;
+
+my $debug_level = 0;
+foreach my $i (@ARGV) {
+ if ($i eq '-debug') {
+ $debug_level = 10;
+ }
+}
+
+my $target = PerlACE::TestTarget::create_target(1) || die "Create target 1 failed\n";
+
+my $iorbase = "server.ior";
+my $server_iorfile = $target->LocalFile ($iorbase);
+$target->DeleteFile ($iorbase);
+
+my $status = 0;
+
+print "Collocated\n\n";
+
+my $shm = '-ORBSvcConf static_shmiop.conf -ORBListenEndpoints shmiop://';
+
+my $SV = $target->CreateProcess ("shmiop_test", "-ORBDebugLevel $debug_level $shm " .
+ "-s $server_iorfile -c $server_iorfile");
+
+my $server = $SV->SpawnWaitKill ($target->ProcessStartWaitInterval ());
+
+if ($server != 0) {
+ print STDERR "ERROR: Collocated test returned $server\n";
+ $status = 1;
+}
+
+$target->DeleteFile ($iorbase);
+
+exit $status;
diff --git a/TAO/tests/SHMIOP/shmiop_test.cpp b/TAO/tests/SHMIOP/shmiop_test.cpp
new file mode 100644
index 00000000000..dfbd3699508
--- /dev/null
+++ b/TAO/tests/SHMIOP/shmiop_test.cpp
@@ -0,0 +1,126 @@
+#include "TestS.h"
+
+#include "tao/Strategies/advanced_resource.h"
+
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_stdio.h"
+#include "ace/SString.h"
+#include "ace/Task.h"
+
+struct Servant : virtual POA_Test::Hello
+{
+ explicit Servant (const CORBA::ORB_var &orb)
+ : orb_ (orb)
+ {}
+
+ char *get_string ()
+ {
+ CORBA::String_var str ("hello");
+ return str._retn ();
+ }
+
+ void shutdown ()
+ {
+ this->orb_->shutdown (0);
+ }
+
+ CORBA::ORB_var orb_;
+};
+
+struct ORBTask : ACE_Task_Base
+{
+ explicit ORBTask (const CORBA::ORB_var &orb)
+ : orb_ (orb)
+ {}
+
+ int svc ()
+ {
+ try
+ {
+ this->orb_->run ();
+ return 0;
+ }
+ catch (const CORBA::Exception &e)
+ {
+ e._tao_print_exception ("Exception caught from ORB::run:");
+ }
+ catch (...)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR unknown exception caught ")
+ ACE_TEXT ("from ORB::run\n")));
+ }
+ return 1;
+ }
+
+ CORBA::ORB_var orb_;
+};
+
+int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
+{
+ try
+ {
+ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
+
+ ACE_Get_Opt opts (argc, argv, ACE_TEXT ("s:c:"));
+ const ACE_TCHAR *server = 0, *client = 0;
+ for (int o; (o = opts ()) != -1;)
+ {
+ switch (o)
+ {
+ case 's':
+ server = opts.opt_arg ();
+ break;
+ case 'c':
+ client = opts.opt_arg ();
+ break;
+ }
+ }
+
+ Servant srv (orb);
+ ORBTask task (orb);
+
+ if (server)
+ {
+ CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA");
+ PortableServer::POA_var poa = PortableServer::POA::_narrow (obj);
+ PortableServer::POAManager_var pm = poa->the_POAManager ();
+ pm->activate ();
+ Test::Hello_var srv_obj = srv._this ();
+ CORBA::String_var srv_str = orb->object_to_string (srv_obj);
+ FILE *f = ACE_OS::fopen (server, "w");
+ ACE_OS::fputs (srv_str, f);
+ ACE_OS::fclose (f);
+ if (!client)
+ task.activate();
+ }
+
+ if (client)
+ {
+ ACE_CString ior ("file://");
+ ior += ACE_TEXT_ALWAYS_CHAR (client);
+ CORBA::Object_var obj = orb->string_to_object (ior.c_str ());
+ Test::Hello_var hello = Test::Hello::_narrow (obj);
+ CORBA::String_var str = hello->get_string ();
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) - returned <%C>\n"),
+ str.in ()));
+ hello->shutdown ();
+ }
+ else if (server)
+ {
+ task.wait ();
+ }
+
+ orb->destroy ();
+ return 0;
+ }
+ catch (const CORBA::Exception &e)
+ {
+ e._tao_print_exception ("Exception caught:");
+ }
+ catch (...)
+ {
+ ACE_ERROR ((LM_ERROR, ACE_TEXT ("ERROR unknown exception ")
+ ACE_TEXT ("caught in main\n")));
+ }
+ return 1;
+}
diff --git a/TAO/tests/SHMIOP/static_shmiop.conf b/TAO/tests/SHMIOP/static_shmiop.conf
new file mode 100644
index 00000000000..7fac80fcca5
--- /dev/null
+++ b/TAO/tests/SHMIOP/static_shmiop.conf
@@ -0,0 +1 @@
+static Advanced_Resource_Factory "-ORBProtocolFactory SHMIOP_Factory"