summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjohnc <johnc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-07-24 20:03:10 +0000
committerjohnc <johnc@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>2007-07-24 20:03:10 +0000
commit1304e4ac77df2e6ffab047cf2f0664bb1b46a0da (patch)
tree50e1f2ca7e87f20973c963abdb96a488f5df5f94
parent1700f67b3ff19d9d11f64c48863f30dfa541a50e (diff)
downloadATCD-1304e4ac77df2e6ffab047cf2f0664bb1b46a0da.tar.gz
ChangeLogTag: Tue Jul 24 19:58:38 UTC 2007 Ciju John <johnc at ociweb dot com>
-rw-r--r--TAO/ChangeLog18
-rw-r--r--TAO/tests/Bug_3000_Regression/Bug_3000_Regression.mpc37
-rw-r--r--TAO/tests/Bug_3000_Regression/Callback.cpp26
-rw-r--r--TAO/tests/Bug_3000_Regression/Callback.h28
-rw-r--r--TAO/tests/Bug_3000_Regression/Makefile.am121
-rw-r--r--TAO/tests/Bug_3000_Regression/README23
-rw-r--r--TAO/tests/Bug_3000_Regression/Service.cpp25
-rw-r--r--TAO/tests/Bug_3000_Regression/Service.h31
-rw-r--r--TAO/tests/Bug_3000_Regression/Test.idl31
-rw-r--r--TAO/tests/Bug_3000_Regression/client.cpp149
-rwxr-xr-xTAO/tests/Bug_3000_Regression/run_test.pl73
-rw-r--r--TAO/tests/Bug_3000_Regression/rw.conf2
-rw-r--r--TAO/tests/Bug_3000_Regression/server.cpp132
13 files changed, 696 insertions, 0 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index 9ab32584f06..3966e1ba407 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,21 @@
+Tue Jul 24 19:58:38 UTC 2007 Ciju John <johnc at ociweb dot com>
+
+ * tests/Bug_3000_Regression:
+ * tests/Bug_3000_Regression/Bug_3000_Regression.mpc:
+ * tests/Bug_3000_Regression/Callback.h:
+ * tests/Bug_3000_Regression/Callback.cpp:
+ * tests/Bug_3000_Regression/Makefile.am:
+ * tests/Bug_3000_Regression/README:
+ * tests/Bug_3000_Regression/Service.h:
+ * tests/Bug_3000_Regression/Service.cpp:
+ * tests/Bug_3000_Regression/Test.idl:
+ * tests/Bug_3000_Regression/client.cpp:
+ * tests/Bug_3000_Regression/run_test.pl:
+ * tests/Bug_3000_Regression/rw.conf:
+ * tests/Bug_3000_Regression/server.cpp:
+ New regression test for Bug 3000 (Handle leak upon oneway
+ invocation with RW wait startegy).
+
Tue Jul 24 18:13:23 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl>
* orbsvcs/orbsvcs/PortableGroup/UIPMC_Transport.cpp:
diff --git a/TAO/tests/Bug_3000_Regression/Bug_3000_Regression.mpc b/TAO/tests/Bug_3000_Regression/Bug_3000_Regression.mpc
new file mode 100644
index 00000000000..2bd74f5ef3a
--- /dev/null
+++ b/TAO/tests/Bug_3000_Regression/Bug_3000_Regression.mpc
@@ -0,0 +1,37 @@
+// -*- MPC -*-
+// $Id$
+
+project(*idl): taoidldefaults {
+ IDL_Files {
+ Test.idl
+ }
+ custom_only = 1
+}
+
+project(*Server): taoserver, messaging {
+ after += *idl
+ Source_Files {
+ Service.cpp
+ server.cpp
+ }
+ Source_Files {
+ TestC.cpp
+ TestS.cpp
+ }
+ IDL_Files {
+ }
+}
+
+project(*Client): taoclient, portableserver, messaging {
+ after += *idl
+ Source_Files {
+ Callback.cpp
+ client.cpp
+ }
+ Source_Files {
+ TestC.cpp
+ TestS.cpp
+ }
+ IDL_Files {
+ }
+}
diff --git a/TAO/tests/Bug_3000_Regression/Callback.cpp b/TAO/tests/Bug_3000_Regression/Callback.cpp
new file mode 100644
index 00000000000..5e34adf0b2a
--- /dev/null
+++ b/TAO/tests/Bug_3000_Regression/Callback.cpp
@@ -0,0 +1,26 @@
+//
+// $Id$
+//
+#include "Callback.h"
+
+ACE_RCSID(Callback, Callback, "$Id$")
+
+Callback::Callback (void)
+ : received_callback_ (false)
+{
+}
+
+void
+Callback::test_oneway (void)
+{
+ received_callback_ = true;
+
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) Callback - test_oneway!\n"));
+}
+
+bool
+Callback::received_callback (void)
+{
+ return received_callback_;
+}
diff --git a/TAO/tests/Bug_3000_Regression/Callback.h b/TAO/tests/Bug_3000_Regression/Callback.h
new file mode 100644
index 00000000000..7d0e5c44744
--- /dev/null
+++ b/TAO/tests/Bug_3000_Regression/Callback.h
@@ -0,0 +1,28 @@
+//
+// $Id$
+//
+
+#ifndef CALLBACK_CALLBACK_H
+#define CALLBACK_CALLBACK_H
+#include /**/ "ace/pre.h"
+
+#include "TestS.h"
+
+/// Implement the Test::Callback interface
+class Callback
+ : public virtual POA_Test::Callback
+{
+public:
+ /// Constructor
+ Callback (void);
+
+ virtual void test_oneway (void);
+
+ bool received_callback (void);
+
+ private:
+ bool received_callback_;
+};
+
+#include /**/ "ace/post.h"
+#endif /* CALLBACK_CALLBACK_H */
diff --git a/TAO/tests/Bug_3000_Regression/Makefile.am b/TAO/tests/Bug_3000_Regression/Makefile.am
new file mode 100644
index 00000000000..dda16620cfb
--- /dev/null
+++ b/TAO/tests/Bug_3000_Regression/Makefile.am
@@ -0,0 +1,121 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## ../bin/mwc.pl -type automake -noreldefs TAO.mwc
+
+ACE_BUILDDIR = $(top_builddir)/..
+ACE_ROOT = $(top_srcdir)/..
+TAO_BUILDDIR = $(top_builddir)
+TAO_IDL = ACE_ROOT=$(ACE_ROOT) TAO_ROOT=$(TAO_ROOT) $(TAO_BUILDDIR)/TAO_IDL/tao_idl
+TAO_IDL_DEP = $(TAO_BUILDDIR)/TAO_IDL/tao_idl
+TAO_IDLFLAGS = -Wb,pre_include=ace/pre.h -Wb,post_include=ace/post.h -I$(TAO_ROOT) -I$(srcdir) -g $(ACE_BUILDDIR)/apps/gperf/src/gperf
+TAO_ROOT = $(top_srcdir)
+
+noinst_PROGRAMS =
+
+## Makefile.CallbackTest_Idl.am
+
+BUILT_SOURCES = \
+ TestC.cpp \
+ TestC.h \
+ TestC.inl \
+ TestS.cpp \
+ TestS.h \
+ TestS.inl
+
+CLEANFILES = \
+ Test-stamp \
+ TestC.cpp \
+ TestC.h \
+ TestC.inl \
+ TestS.cpp \
+ TestS.h \
+ TestS.inl
+
+TestC.cpp TestC.h TestC.inl TestS.cpp TestS.h TestS.inl: Test-stamp
+
+Test-stamp: $(srcdir)/Test.idl $(TAO_IDL_DEP)
+ $(TAO_IDL) $(TAO_IDLFLAGS) -Sa -St $(srcdir)/Test.idl
+ @touch $@
+
+noinst_HEADERS = \
+ Test.idl
+
+## Makefile.CallbackTest_Client.am
+
+if BUILD_CORBA_MESSAGING
+if BUILD_EXCEPTIONS
+
+noinst_PROGRAMS += client
+
+client_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -I$(TAO_ROOT) \
+ -I$(TAO_BUILDDIR)
+
+client_SOURCES = \
+ Callback.cpp \
+ TestC.cpp \
+ TestS.cpp \
+ client.cpp \
+ Callback.h
+
+client_LDADD = \
+ $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \
+ $(TAO_BUILDDIR)/tao/libTAO_PI.la \
+ $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \
+ $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \
+ $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \
+ $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \
+ $(TAO_BUILDDIR)/tao/libTAO.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+endif BUILD_EXCEPTIONS
+endif BUILD_CORBA_MESSAGING
+
+## Makefile.CallbackTest_Server.am
+
+if BUILD_CORBA_MESSAGING
+if BUILD_EXCEPTIONS
+
+noinst_PROGRAMS += server
+
+server_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -I$(TAO_ROOT) \
+ -I$(TAO_BUILDDIR)
+
+server_SOURCES = \
+ Service.cpp \
+ TestC.cpp \
+ TestS.cpp \
+ server.cpp \
+ Service.h
+
+server_LDADD = \
+ $(TAO_BUILDDIR)/tao/libTAO_Messaging.la \
+ $(TAO_BUILDDIR)/tao/libTAO_PI.la \
+ $(TAO_BUILDDIR)/tao/libTAO_CodecFactory.la \
+ $(TAO_BUILDDIR)/tao/libTAO_Valuetype.la \
+ $(TAO_BUILDDIR)/tao/libTAO_PortableServer.la \
+ $(TAO_BUILDDIR)/tao/libTAO_AnyTypeCode.la \
+ $(TAO_BUILDDIR)/tao/libTAO.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+endif BUILD_EXCEPTIONS
+endif BUILD_CORBA_MESSAGING
+
+## Clean up template repositories, etc.
+clean-local:
+ -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.*
+ -rm -f gcctemp.c gcctemp so_locations *.ics
+ -rm -rf cxx_repository ptrepository ti_files
+ -rm -rf templateregistry ir.out
+ -rm -rf ptrepository SunWS_cache Templates.DB
diff --git a/TAO/tests/Bug_3000_Regression/README b/TAO/tests/Bug_3000_Regression/README
new file mode 100644
index 00000000000..9a6ff172ded
--- /dev/null
+++ b/TAO/tests/Bug_3000_Regression/README
@@ -0,0 +1,23 @@
+/**
+
+@page Callback_oneway_rw Test README File
+
+ This test is a modification of the Callback test.
+
+ When using the RW wait startegy, the Transport_Cache_Manager::find_transport()
+ temporarily removes the selected handler from the reactor read list. This
+ is supposed to be undone in the wait strategy TAO_Wait_On_Read::wait().
+ However since in one-way invocations, the wait isn't done the handle gets lost.
+
+ This is demonstrated in this test (a modification of the $TAO_ROOT/tests/CallbackTest).
+ A server using RW wait makes a oneway callback to the client(). The client starts
+ upon a fixed endpoint. Since the server handle wasn't put back into the reactor
+ read list, the client connection closure goes undetected. When a second client comes
+ online, the server reuses the half-closed connection to send the one-way callback. This
+ deadlocks.
+
+ - run_test.pl // Tests the default wait startegy (LF).
+
+ - run_test.pl default // Tests using the RW wait startegy.
+
+*/
diff --git a/TAO/tests/Bug_3000_Regression/Service.cpp b/TAO/tests/Bug_3000_Regression/Service.cpp
new file mode 100644
index 00000000000..41c538898bb
--- /dev/null
+++ b/TAO/tests/Bug_3000_Regression/Service.cpp
@@ -0,0 +1,25 @@
+//
+// $Id$
+//
+#include "Service.h"
+
+ACE_RCSID(Callback, Service, "$Id$")
+
+Service::Service (CORBA::ORB_ptr orb)
+ : orb_ (CORBA::ORB::_duplicate (orb))
+{
+}
+
+void
+Service::run_test (Test::Callback_ptr callback)
+{
+ callback->test_oneway ();
+}
+
+void
+Service::shutdown (void)
+{
+ ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Shuting down self (server)\n"));
+
+ this->orb_->shutdown (0);
+}
diff --git a/TAO/tests/Bug_3000_Regression/Service.h b/TAO/tests/Bug_3000_Regression/Service.h
new file mode 100644
index 00000000000..afd4645f0e4
--- /dev/null
+++ b/TAO/tests/Bug_3000_Regression/Service.h
@@ -0,0 +1,31 @@
+//
+// $Id$
+//
+
+#ifndef CALLBACK_SERVICE_H
+#define CALLBACK_SERVICE_H
+#include /**/ "ace/pre.h"
+
+#include "TestS.h"
+
+/// Implement the Test::Service interface
+class Service
+ : public virtual POA_Test::Service
+{
+public:
+ /// Constructor
+ Service (CORBA::ORB_ptr orb);
+
+ // = The skeleton methods
+ virtual void run_test (Test::Callback_ptr callback);
+
+ virtual void shutdown (void);
+
+private:
+
+ /// Use an ORB reference to shutdown the application.
+ CORBA::ORB_var orb_;
+};
+
+#include /**/ "ace/post.h"
+#endif /* CALLBACK_SERVICE_H */
diff --git a/TAO/tests/Bug_3000_Regression/Test.idl b/TAO/tests/Bug_3000_Regression/Test.idl
new file mode 100644
index 00000000000..5088a328264
--- /dev/null
+++ b/TAO/tests/Bug_3000_Regression/Test.idl
@@ -0,0 +1,31 @@
+//
+// $Id$
+//
+
+module Test
+{
+ /**
+ * Callback interface.
+ */
+ interface Callback
+ {
+ /// Receive the first callback
+ oneway void test_oneway ();
+ };
+
+ /**
+ * Clients connect to this interface passing in a Callback
+ * object.
+ * The service will then invoke all the methods on the
+ * Callback.
+ *
+ */
+ interface Service
+ {
+ /// Invoke the callback object from the server
+ oneway void run_test (in Callback the_callback);
+
+ void shutdown ();
+ };
+
+};
diff --git a/TAO/tests/Bug_3000_Regression/client.cpp b/TAO/tests/Bug_3000_Regression/client.cpp
new file mode 100644
index 00000000000..11a49b48d1e
--- /dev/null
+++ b/TAO/tests/Bug_3000_Regression/client.cpp
@@ -0,0 +1,149 @@
+// $Id$
+
+#include "Callback.h"
+
+#include "tao/Messaging/Messaging.h"
+#include "tao/AnyTypeCode/Any.h"
+#include "ace/Get_Opt.h"
+
+ACE_RCSID(Crashed_Callback, client, "$Id$")
+
+const char *ior = "file://test.ior";
+bool shutdown_server = false;
+
+int
+parse_args (int argc, char *argv[])
+{
+ ACE_Get_Opt get_opts (argc, argv, "k:s");
+ int c;
+
+ while ((c = get_opts ()) != -1)
+ switch (c)
+ {
+ case 'k':
+ ior = get_opts.opt_arg ();
+ break;
+ case 's':
+ shutdown_server = true;
+ break;
+ case '?':
+ default:
+ ACE_ERROR_RETURN ((LM_ERROR,
+ "usage: %s "
+ "-k <ior>"
+ "-s "
+ "\n",
+ argv [0]),
+ -1);
+ }
+ // Indicates sucessful 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 ();
+
+ // Make all oneways "reliable."
+ {
+ CORBA::Object_var manager_object =
+ orb->resolve_initial_references("ORBPolicyManager");
+ CORBA::PolicyManager_var policy_manager =
+ CORBA::PolicyManager::_narrow(manager_object.in());
+
+ if (CORBA::is_nil (policy_manager.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Panic: nil PolicyManager\n"),
+ 1);
+ CORBA::Any policy_value;
+ policy_value <<= Messaging::SYNC_WITH_SERVER;
+ CORBA::PolicyList policies(1); policies.length(1);
+ policies[0] =
+ orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
+ policy_value);
+
+ policy_manager->set_policy_overrides (policies,
+ CORBA::ADD_OVERRIDE);
+
+ policies[0]->destroy ();
+ }
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ CORBA::Object_var tmp =
+ orb->string_to_object(ior);
+
+ Test::Service_var service =
+ Test::Service::_narrow(tmp.in ());
+
+ if (CORBA::is_nil (service.in ()))
+ {
+ ACE_ERROR_RETURN ((LM_DEBUG,
+ "Nil service reference <%s>\n",
+ ior),
+ 1);
+ }
+
+ Callback *callback_impl;
+ ACE_NEW_RETURN (callback_impl,
+ Callback (),
+ 1);
+ PortableServer::ServantBase_var owner_transfer(callback_impl);
+
+ PortableServer::ObjectId_var id =
+ root_poa->activate_object (callback_impl);
+
+ CORBA::Object_var object = root_poa->id_to_reference (id.in ());
+
+ Test::Callback_var callback =
+ Test::Callback::_narrow (object.in ());
+
+ poa_manager->activate ();
+
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) client - starting test\n"));
+
+ service->run_test (callback.in ());
+
+ ACE_DEBUG ((LM_DEBUG,
+ "(%P|%t) client - running ORB\n"));
+
+ while (!callback_impl->received_callback ())
+ {
+ orb->perform_work ();
+ }
+ if (shutdown_server) {
+ service->shutdown ();
+ }
+
+ root_poa->destroy (1, 1);
+
+ orb->destroy ();
+ }
+ catch (const CORBA::Exception& ex)
+ {
+ ex._tao_print_exception ("Exception caught:");
+ return 1;
+ }
+
+ return 0;
+}
diff --git a/TAO/tests/Bug_3000_Regression/run_test.pl b/TAO/tests/Bug_3000_Regression/run_test.pl
new file mode 100755
index 00000000000..5d61779b6b0
--- /dev/null
+++ b/TAO/tests/Bug_3000_Regression/run_test.pl
@@ -0,0 +1,73 @@
+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;
+
+$iorfile = PerlACE::LocalFile ("server.ior");
+unlink $iorfile;
+$status = 0;
+
+my $cl_port = PerlACE::random_port();
+my $cl_opts = " -k file://$iorfile -ORBDottedDecimalAddresses 1 " .
+ "-ORBEndpoint iiop://:$cl_port";
+
+# By default use RW wait startegy
+my $sr_svc_opt = "-ORBSvcConf rw.conf";
+if ($ARGV[0] eq 'default') {
+ $sr_svc_opt = "";
+}
+
+if (PerlACE::is_vxworks_test()) {
+ $SV = new PerlACE::ProcessVX ("server", "-o server.ior");
+}
+else {
+ $SV = new PerlACE::Process ("server", "-o $iorfile $sr_svc_opt");
+}
+$CL = new PerlACE::Process ("client", $cl_opts);
+$CL2 = new PerlACE::Process ("client", " -s $cl_opts");
+
+print $SV->CommandLine() . "\n";
+$SV->Spawn ();
+
+if (PerlACE::waitforfile_timed ($iorfile,
+ $PerlACE::wait_interval_for_process_creation) == -1) {
+ print STDERR "ERROR: cannot find file <$iorfile>\n";
+ $SV->Kill (); $SV->TimedWait (1);
+ exit 1;
+}
+
+print $CL->CommandLine() . "\n";
+$client = $CL->SpawnWaitKill (60);
+
+# The client crashes, therefore it normally exists with status != 0,
+# but a status of -1 would be a serious error.
+if ($client == -1) {
+ print STDERR "ERROR: client returned $client\n";
+ $status = 1;
+}
+
+print $CL2->CommandLine() . "\n";
+$client2 = $CL2->SpawnWaitKill (60);
+
+# The client crashes, therefore it normally exists with status != 0,
+# but a status of -1 would be a serious error.
+if ($client2 == -1) {
+ print STDERR "ERROR: client2 returned $client2\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_3000_Regression/rw.conf b/TAO/tests/Bug_3000_Regression/rw.conf
new file mode 100644
index 00000000000..0117a350fdd
--- /dev/null
+++ b/TAO/tests/Bug_3000_Regression/rw.conf
@@ -0,0 +1,2 @@
+static Client_Strategy_Factory "-ORBWaitStrategy rw -ORBTransportMuxStrategy exclusive -ORBConnectStrategy blocked"
+static Resource_Factory "-ORBFlushingStrategy blocking"
diff --git a/TAO/tests/Bug_3000_Regression/server.cpp b/TAO/tests/Bug_3000_Regression/server.cpp
new file mode 100644
index 00000000000..cb44c132b95
--- /dev/null
+++ b/TAO/tests/Bug_3000_Regression/server.cpp
@@ -0,0 +1,132 @@
+// $Id$
+
+#include "Service.h"
+
+#include "tao/Messaging/Messaging.h"
+#include "tao/AnyTypeCode/Any.h"
+#include "ace/Get_Opt.h"
+#include "ace/OS_NS_stdio.h"
+
+ACE_RCSID(Crashed_Callback, server, "$Id$")
+
+const char *ior_output_file = "test.ior";
+
+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
+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 ();
+
+ // Make all oneways "reliable."
+ {
+ CORBA::Object_var manager_object =
+ orb->resolve_initial_references("ORBPolicyManager");
+ CORBA::PolicyManager_var policy_manager =
+ CORBA::PolicyManager::_narrow(manager_object.in());
+
+ if (CORBA::is_nil (policy_manager.in ()))
+ ACE_ERROR_RETURN ((LM_ERROR,
+ " (%P|%t) Panic: nil PolicyManager\n"),
+ 1);
+ CORBA::Any policy_value;
+ policy_value <<= Messaging::SYNC_WITH_SERVER;
+ CORBA::PolicyList policies(1); policies.length(1);
+ policies[0] =
+ orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE,
+ policy_value);
+
+ policy_manager->set_policy_overrides (policies,
+ CORBA::ADD_OVERRIDE);
+
+ policies[0]->destroy ();
+ }
+
+ if (parse_args (argc, argv) != 0)
+ return 1;
+
+ Service *service_impl;
+ ACE_NEW_RETURN (service_impl,
+ Service(orb.in ()),
+ 1);
+ PortableServer::ServantBase_var owner_transfer(service_impl);
+
+ PortableServer::ObjectId_var id =
+ root_poa->activate_object (service_impl);
+
+ CORBA::Object_var object = root_poa->id_to_reference (id.in ());
+
+ Test::Service_var service =
+ Test::Service::_narrow (object.in ());
+
+ CORBA::String_var ior =
+ orb->object_to_string (service.in ());
+
+ // If the ior_output_file exists, output the ior to it
+ 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);
+
+ poa_manager->activate ();
+
+ orb->run ();
+
+ ACE_DEBUG ((LM_DEBUG, "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;
+}