summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Mesnier <mesnier_p@ociweb.com>2007-08-16 16:34:50 +0000
committerPhil Mesnier <mesnier_p@ociweb.com>2007-08-16 16:34:50 +0000
commit032ab395520ec79f0d472841d7a67755e5837a31 (patch)
tree1de593dff3abc11f0aabd89befbf81c42fcf7a9b
parentde1f456bd881476ce75d29fddfdd65150e1057ac (diff)
downloadATCD-032ab395520ec79f0d472841d7a67755e5837a31.tar.gz
Thu Aug 16 16:29:46 UTC 2007 Phil Mesnier <mesnier_p@ociweb.com>
-rw-r--r--TAO/ChangeLog23
-rw-r--r--TAO/tao/ORB.cpp206
-rw-r--r--TAO/tao/ORB_Core.cpp21
-rw-r--r--TAO/tao/ORB_Core.h2
-rw-r--r--TAO/tests/ORB_Local_Config/Bug_1459/Test.cpp6
-rw-r--r--TAO/tests/ORB_Local_Config/Bug_2612/Test.cpp6
-rw-r--r--TAO/tests/ORB_Local_Config/Two_DLL_ORB/primary-csd.conf4
-rw-r--r--TAO/tests/ORB_Local_Config/Two_DLL_ORB/primary-ssl.conf4
-rwxr-xr-xTAO/tests/ORB_Local_Config/Two_DLL_ORB/run_test.pl3
9 files changed, 184 insertions, 91 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index c0fc701d3be..65f4400cd9f 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,26 @@
+Thu Aug 16 16:29:46 UTC 2007 Phil Mesnier <mesnier_p@ociweb.com>
+
+ * tao/ORB.cpp:
+ * tao/ORB_Core.h:
+ * tao/ORB_Core.cpp:
+
+ Add explicit configuration of configuration contexts to resolve
+ the multiple ORBInitializer issue documented in bug 2995. By
+ default ORBs will use the global configuration context
+ exclusively. If -ORBGestalt Local is supplied on the command
+ line the ORB will create a local configuration context into
+ which separately loaded service objects will override any of
+ those installed in the global context.
+
+ * tests/ORB_Local_Config/Bug_1459/Test.cpp:
+ * tests/ORB_Local_Config/Bug_2612/Test.cpp:
+ * tests/ORB_Local_Config/Two_DLL_ORB/primary-csd.conf:
+ * tests/ORB_Local_Config/Two_DLL_ORB/primary-ssl.conf:
+ * tests/ORB_Local_Config/Two_DLL_ORB/run_test.pl:
+
+ Add the new -ORBGestalt Local option to ensure these tests still
+ perform as intended.
+
Thu Aug 16 12:13:12 UTC 2007 Johnny Willemsen <jwillemsen@remedy.nl>
* orbsvcs/orbsvcs/IFR_Service_Utils_T.cpp:
diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp
index 637019026dc..370ae906eef 100644
--- a/TAO/tao/ORB.cpp
+++ b/TAO/tao/ORB.cpp
@@ -1086,8 +1086,59 @@ CORBA::ORB::_tao_make_ORB (TAO_ORB_Core * orb_core)
// ****************************************************************
-// ORB initialization, per OMG document 98-12-01.
+namespace TAO
+{
+ bool
+ parse_orb_opt (ACE_Argv_Type_Converter& command_line,
+ const ACE_TCHAR* orb_opt,
+ ACE_CString& opt_arg)
+ {
+
+ if (opt_arg.length () > 0)
+ return false;
+
+ ACE_Arg_Shifter arg_shifter (command_line.get_argc (),
+ command_line.get_TCHAR_argv ());
+
+ size_t opt_len = ACE_OS::strlen (orb_opt);
+ bool found = false;
+ while (arg_shifter.is_anything_left ())
+ {
+ const ACE_TCHAR *current_arg = arg_shifter.get_current ();
+
+ if (ACE_OS::strcasecmp (current_arg,
+ orb_opt) == 0)
+ {
+ found = true;
+ arg_shifter.consume_arg ();
+ if (arg_shifter.is_parameter_next ())
+ {
+ opt_arg =
+ ACE_TEXT_ALWAYS_CHAR (arg_shifter.get_current ());
+ arg_shifter.consume_arg ();
+ }
+ }
+ else if (ACE_OS::strncasecmp (current_arg, orb_opt,
+ opt_len) == 0)
+ {
+ arg_shifter.consume_arg ();
+ // The rest of the argument is the ORB id...
+ // but we should skip an optional space...
+ if (current_arg[opt_len] == ' ')
+ opt_arg =
+ ACE_TEXT_ALWAYS_CHAR (current_arg + opt_len + 1);
+ else
+ opt_arg = ACE_TEXT_ALWAYS_CHAR (current_arg + opt_len);
+ }
+ else
+ arg_shifter.ignore_arg ();
+ }
+ return found;
+ }
+}
+
+// ORB initialization, per OMG document 98-12-01.
CORBA::ORB_ptr
CORBA::ORB_init (int &argc, char *argv[], const char *orbid)
{
@@ -1141,73 +1192,108 @@ CORBA::ORB_init (int &argc, char *argv[], const char *orbid)
CORBA::COMPLETED_NO);
}
- if (orbid_string.length () == 0)
- {
- ACE_Arg_Shifter arg_shifter (command_line.get_argc (),
- command_line.get_TCHAR_argv ());
-
- while (arg_shifter.is_anything_left ())
- {
- const ACE_TCHAR *current_arg = arg_shifter.get_current ();
-
- static const ACE_TCHAR orbid_opt[] = ACE_TEXT ("-ORBid");
- size_t orbid_len = ACE_OS::strlen (orbid_opt);
- if (ACE_OS::strcasecmp (current_arg,
- orbid_opt) == 0)
- {
- arg_shifter.consume_arg ();
- if (arg_shifter.is_parameter_next ())
- {
- orbid_string =
- ACE_TEXT_ALWAYS_CHAR (arg_shifter.get_current ());
- arg_shifter.consume_arg ();
- }
- }
- else if (ACE_OS::strncasecmp (current_arg, orbid_opt,
- orbid_len) == 0)
- {
- arg_shifter.consume_arg ();
- // The rest of the argument is the ORB id...
- // but we should skip an optional space...
- if (current_arg[orbid_len] == ' ')
- orbid_string =
- ACE_TEXT_ALWAYS_CHAR (current_arg + orbid_len + 1);
- else
- orbid_string = ACE_TEXT_ALWAYS_CHAR (current_arg + orbid_len);
- }
- else
- arg_shifter.ignore_arg ();
- }
- }
+ TAO::parse_orb_opt (command_line, ACE_TEXT("-ORBid"), orbid_string);
// Get ORB Core
TAO_ORB_Core_Auto_Ptr oc (
TAO::ORB_Table::instance ()->find (orbid_string.c_str ()));
- // The ORB was already initialized. Just return that one.
+ // The ORB was already initialized. Just return that one.
if (oc.get () != 0)
{
return CORBA::ORB::_duplicate (oc->orb ());
}
- else
+
+
+ // Determine the service object registry this ORB will use. The choises
+ // are: (a) the legacy (global); (b) its own, local, or (c) share somebody
+ // else's configuration
+
+ // By default use the process (application?) global configuration context
+ ACE_Service_Gestalt* gestalt = ACE_Service_Config::current ();
+
+ // Use this string variable to hold the config identity
+ ACE_CString orbconfig_string;
+ ACE_Auto_Ptr<ACE_Service_Gestalt> guard_gestalt(0);
+
+ if (TAO::parse_orb_opt (command_line,
+ ACE_TEXT("-ORBGestalt"),
+ orbconfig_string))
{
- // An ORB corresponding to the desired ORBid doesn't exist so create
- // a new one.
- TAO_ORB_Core * tmp = 0;
- ACE_NEW_THROW_EX (tmp,
- TAO_ORB_Core (orbid_string.c_str ()),
- CORBA::NO_MEMORY (
- CORBA::SystemException::_tao_minor_code (0,
- ENOMEM),
- CORBA::COMPLETED_NO));
+ // Need a local repo? Make one which typically should not be as
+ // big as the default repository
+ if (ACE_OS::strcasecmp (orbconfig_string.c_str (),
+ ACE_TEXT("LOCAL")) == 0)
+ {
+ ACE_NEW_THROW_EX (gestalt,
+ ACE_Service_Gestalt
+ (ACE_Service_Gestalt::MAX_SERVICES / 4, true),
+ CORBA::NO_MEMORY
+ (CORBA::SystemException::_tao_minor_code (0,
+ ENOMEM),
+ CORBA::COMPLETED_NO));
+ guard_gestalt.reset(gestalt);
+ }
+ else if (ACE_OS::strncmp (orbconfig_string.c_str (),
+ ACE_TEXT ("ORB:"), 4) == 0)
+ {
+ // @TODO: At some point, we need to implement a lookup of an
+ // existing configuration context based on the orbid
+ // following the "ORB:" It may be the case that contexts may
+ // be initialized separate from the ORB of the same ID, in
+ // which case we would need some sort of table of contexts
+ // at which point we would either find this one or make a
+ // new one. And making a new one would require assigning it
+ // to the guard_gestalt just like the local.
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ERROR: Sharing ORB configuration ")
+ ACE_TEXT ("contexts is not yet supported\n")));
+ }
- // The ORB table increases the reference count on the ORB Core
- // so do not release it here. Allow the TAO_ORB_Core_Auto_Ptr
- // to decrease the reference count on the ORB Core when it goes
- // out of scope.
- oc.reset (tmp);
+ throw ::CORBA::BAD_PARAM
+ (CORBA::SystemException::_tao_minor_code
+ ( TAO_ORB_CORE_INIT_LOCATION_CODE,
+ ENOTSUP),
+ CORBA::COMPLETED_NO);
+ }
+ else
+ {
+ if (TAO_debug_level > 0)
+ {
+ ACE_ERROR ((LM_ERROR,
+ ACE_TEXT ("ERROR: -ORBGestalt unknown value <%s>\n"),
+ orbconfig_string.c_str()));
+ }
+
+ throw ::CORBA::BAD_PARAM
+ (CORBA::SystemException::_tao_minor_code
+ ( TAO_ORB_CORE_INIT_LOCATION_CODE,
+ EINVAL),
+ CORBA::COMPLETED_NO);
+ }
}
+ // An ORB corresponding to the desired ORBid doesn't exist so create
+ // a new one.
+ TAO_ORB_Core * tmp = 0;
+ ACE_NEW_THROW_EX (tmp,
+ TAO_ORB_Core (orbid_string.c_str (), gestalt),
+ CORBA::NO_MEMORY (
+ CORBA::SystemException::_tao_minor_code (0,
+ ENOMEM),
+ CORBA::COMPLETED_NO));
+
+ // The ORB table increases the reference count on the ORB Core
+ // so do not release it here. Allow the TAO_ORB_Core_Auto_Ptr
+ // to decrease the reference count on the ORB Core when it goes
+ // out of scope.
+ oc.reset (tmp);
+
+ // The ORB now owns its configuration and the auto pointer is not
+ // necessary anymore.
+ guard_gestalt.release ();
// Having the ORB's default static services be shared among all ORBs
// is tempting from the point of view of reducing the dynamic
@@ -1218,18 +1304,10 @@ CORBA::ORB_init (int &argc, char *argv[], const char *orbid)
// which will have disastrous consequences at the process
// shutdown. Hence, the ACE_Service_Config_Guard ensures that for
// the current thread, any references to the global
- // ACE_Service_Config will be forwarded to the ORB's.
+ // ACE_Service_Config will be re-routed to this ORB's service gestalt.
- // Making sure the initialization process in the current thread uses
- // the correct service repository (ours), instead of the global one.
ACE_Service_Config_Guard scg (oc->configuration ());
- /*
- * Currently I choose to make the ORB an owner of its configuration,
- * which in general is not quite correct because it is very common ORBs to
- * need to share the same configuration.
- */
-
// Initialize the Service Configurator. This must occur before the
// ORBInitializer::pre_init() method is invoked on each registered
// ORB initializer.
diff --git a/TAO/tao/ORB_Core.cpp b/TAO/tao/ORB_Core.cpp
index afe84a58311..14ba75aa527 100644
--- a/TAO/tao/ORB_Core.cpp
+++ b/TAO/tao/ORB_Core.cpp
@@ -180,7 +180,8 @@ TAO_ORB_Core_Static_Resources::operator=(const TAO_ORB_Core_Static_Resources& ot
// ****************************************************************
-TAO_ORB_Core::TAO_ORB_Core (const char *orbid)
+TAO_ORB_Core::TAO_ORB_Core (const char *orbid,
+ ACE_Service_Gestalt* gestalt)
: protocols_hooks_ (0),
network_priority_protocols_hooks_ (0),
#if TAO_USE_LOCAL_MEMORY_POOL == 1
@@ -258,6 +259,7 @@ TAO_ORB_Core::TAO_ORB_Core (const char *orbid)
bidir_giop_policy_ (0),
flushing_strategy_ (0),
codeset_manager_ (0),
+ config_ (gestalt),
sync_scope_hook_ (0),
timeout_hook_ (0)
{
@@ -285,19 +287,6 @@ TAO_ORB_Core::TAO_ORB_Core (const char *orbid)
ACE_NEW (this->request_dispatcher_,
TAO_Request_Dispatcher);
- // @TODO: Can this be dynamic container instead?
- if (ACE_OS::strnlen (this->orbid_, 1) == 0)
- {
- ACE_NEW (this->config_,
- ACE_Service_Gestalt (ACE_Service_Gestalt::MAX_SERVICES,
- false)); // (Re)use the process-global repository
- }
- else
- {
- ACE_NEW (this->config_,
- ACE_Service_Gestalt (ACE_Service_Gestalt::MAX_SERVICES / 4,
- true)); // Use our own service repository
- }
}
TAO_ORB_Core::~TAO_ORB_Core (void)
@@ -339,7 +328,9 @@ TAO_ORB_Core::~TAO_ORB_Core (void)
// This will destroy the service repository for this core
(void) TAO::ORB::close_services (this->config_);
- delete this->config_;
+ if (this->config_ != ACE_Service_Config::global())
+ delete this->config_;
+
this->config_ = 0;
}
diff --git a/TAO/tao/ORB_Core.h b/TAO/tao/ORB_Core.h
index f4c232a1f91..90a317ec1b6 100644
--- a/TAO/tao/ORB_Core.h
+++ b/TAO/tao/ORB_Core.h
@@ -164,7 +164,7 @@ class TAO_Export TAO_ORB_Core
public:
/// Constructor.
- TAO_ORB_Core (const char* id);
+ TAO_ORB_Core (const char* id, ACE_Service_Gestalt* g);
/// Accessor for the ORB parameters.
TAO_ORB_Parameters *orb_params (void);
diff --git a/TAO/tests/ORB_Local_Config/Bug_1459/Test.cpp b/TAO/tests/ORB_Local_Config/Bug_1459/Test.cpp
index f02243113b2..67e2daea54a 100644
--- a/TAO/tests/ORB_Local_Config/Bug_1459/Test.cpp
+++ b/TAO/tests/ORB_Local_Config/Bug_1459/Test.cpp
@@ -23,17 +23,17 @@ ACE_RCSID (tests, server, "$Id$")
#include "Service_Configuration_Per_ORB.h"
-const char argA[] = "AAA -ORBId ORB-A -ORBSvcConf a.conf";
+const char argA[] = "AAA -ORBGestalt LOCAL -ORBId ORB-A -ORBSvcConf a.conf";
// dynamic SSLIOP_Factory Service_Object * TAO_SSLIOP:_make_TAO_SSLIOP_Protocol_Factory() "-SSLAuthenticate SERVER_AND_CLIENT -SSLPrivateKey PEM:server_key.pem -SSLCertificate PEM:server_cert.pem";
// static Resource_Factory "-ORBProtocolFactory SSLIOP_Factory"
-const char argB[] = "BBB -ORBSvcConf b.conf";
+const char argB[] = "BBB -ORBGestalt LOCAL -ORBSvcConf b.conf";
// dynamic SSLIOP_Factory Service_Object * TAO_SSLIOP:_make_TAO_SSLIOP_Protocol_Factory() "-SSLAuthenticate SERVER_AND_CLIENT -SSLPrivateKey PEM:client_key.pem -SSLCertificate PEM:client_cert.pem"
// static Resource_Factory "-ORBProtocolFactory SSLIOP_Factory"
-const char argM[] = "MMM -ORBId ORB-M -ORBSvcConf m.conf";
+const char argM[] = "MMM -ORBGestalt LOCAL -ORBId ORB-M -ORBSvcConf m.conf";
// dynamic UIPMC_Factory Service_Object * TAO_PortableGroup:_make_TAO_UIPMC_Protocol_Factory() ""
// static Resource_Factory "-ORBProtocolFactory IIOP_Factory -ORBProtocolFactory UIPMC_Factory"
diff --git a/TAO/tests/ORB_Local_Config/Bug_2612/Test.cpp b/TAO/tests/ORB_Local_Config/Bug_2612/Test.cpp
index f0bf0a340eb..8862e489d9b 100644
--- a/TAO/tests/ORB_Local_Config/Bug_2612/Test.cpp
+++ b/TAO/tests/ORB_Local_Config/Bug_2612/Test.cpp
@@ -13,7 +13,7 @@ char const * const scpc_loadOrb =
ACE_DYNAMIC_SERVICE_DIRECTIVE ("testDllOrb",
"DllOrb",
"_make_DllOrb",
- "DllOrb -t 1 -ORBDebugLevel 3 -ORBId testORB -ORBInitRef "
+ "DllOrb -t 1 -ORBGestalt Local -ORBDebugLevel 3 -ORBId testORB -ORBInitRef "
"NameService=file:///tmp/test-ns.ior -ORBDottedDecimalAddresses 1"
);
@@ -21,16 +21,18 @@ char const * const scpc_unloadOrb = ACE_REMOVE_SERVICE_DIRECTIVE ("testDllOrb");
int ACE_TMAIN(int, char **)
{
+ ACE_DEBUG ((LM_DEBUG,"\nbefore first load process directive\n"));
if (0 > ACE_Service_Config::process_directive(scpc_loadOrb))
return -1;
ACE_OS::sleep(2);
+ ACE_DEBUG ((LM_DEBUG,"\nbefore first unload process directive\n"));
if (0 > ACE_Service_Config::process_directive(scpc_unloadOrb))
return -1;
ACE_OS::sleep(2);
- ACE_DEBUG ((LM_DEBUG, "MAIN (%P|%t) Lather, Rince, Repeat ...\n"));
+ ACE_DEBUG ((LM_DEBUG, "\nMAIN (%P|%t) Lather, Rince, Repeat ...\n"));
if (0 > ACE_Service_Config::process_directive(scpc_loadOrb))
return -1;
diff --git a/TAO/tests/ORB_Local_Config/Two_DLL_ORB/primary-csd.conf b/TAO/tests/ORB_Local_Config/Two_DLL_ORB/primary-csd.conf
index 1c1df417c5f..5de36bc6f60 100644
--- a/TAO/tests/ORB_Local_Config/Two_DLL_ORB/primary-csd.conf
+++ b/TAO/tests/ORB_Local_Config/Two_DLL_ORB/primary-csd.conf
@@ -1,2 +1,2 @@
-dynamic ORB_DLL_Server Service_Object * ORB_DLL_Server:_make_Service_Config_ORB_DLL() "-s -ORBDebugLevel 1 -ORBId SERVER -ORBSvcConf secondary-empty.conf"
-dynamic ORB_DLL_Client Service_Object * ORB_DLL_Client:_make_Service_Config_ORB_DLL() "-c -ORBDebugLevel 1 -ORBId CLIENT -ORBSvcConf secondary-csd.conf"
+dynamic ORB_DLL_Server Service_Object * ORB_DLL_Server:_make_Service_Config_ORB_DLL() "-s -ORBDebugLevel 1 -ORBGestalt LOCAL -ORBId SERVER -ORBSvcConf secondary-empty.conf"
+dynamic ORB_DLL_Client Service_Object * ORB_DLL_Client:_make_Service_Config_ORB_DLL() "-c -ORBDebugLevel 1 -ORBGestalt LOCAL -ORBId CLIENT -ORBSvcConf secondary-csd.conf"
diff --git a/TAO/tests/ORB_Local_Config/Two_DLL_ORB/primary-ssl.conf b/TAO/tests/ORB_Local_Config/Two_DLL_ORB/primary-ssl.conf
index 8f89db1b08d..205cf07dc9b 100644
--- a/TAO/tests/ORB_Local_Config/Two_DLL_ORB/primary-ssl.conf
+++ b/TAO/tests/ORB_Local_Config/Two_DLL_ORB/primary-ssl.conf
@@ -1,3 +1,3 @@
dynamic SSLIOP_Factory Service_Object * TAO_SSLIOP:_make_TAO_SSLIOP_Protocol_Factory() "-SSLNOProtection"
-dynamic ORB_DLL_Server Service_Object * ORB_DLL_Server:_make_Service_Config_ORB_DLL() "-s -ORBDebugLevel 1 -ORBId SERVER -ORBSvcConf secondary-empty.conf"
-dynamic ORB_DLL_Client Service_Object * ORB_DLL_Client:_make_Service_Config_ORB_DLL() "-c -ORBDebugLevel 1 -ORBId CLIENT -ORBSvcConf secondary-ssl.conf"
+dynamic ORB_DLL_Server Service_Object * ORB_DLL_Server:_make_Service_Config_ORB_DLL() "-s -ORBDebugLevel 1 -ORBGestalt LOCAL -ORBId SERVER -ORBSvcConf secondary-empty.conf"
+dynamic ORB_DLL_Client Service_Object * ORB_DLL_Client:_make_Service_Config_ORB_DLL() "-c -ORBDebugLevel 1 -ORBGestalt LOCAL -ORBId CLIENT -ORBSvcConf secondary-ssl.conf"
diff --git a/TAO/tests/ORB_Local_Config/Two_DLL_ORB/run_test.pl b/TAO/tests/ORB_Local_Config/Two_DLL_ORB/run_test.pl
index 13a64419ed2..023ad4225e1 100755
--- a/TAO/tests/ORB_Local_Config/Two_DLL_ORB/run_test.pl
+++ b/TAO/tests/ORB_Local_Config/Two_DLL_ORB/run_test.pl
@@ -34,7 +34,7 @@ sub test($)
print STDERR "ERROR: test failed, status=$status\n";
}
return $status;
-}
+}
my $status = test("Test");
@@ -45,4 +45,3 @@ else {
print STDERR "ERROR: Some test failed, status=$status\n";
}
exit $status;
-