summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1998-04-24 00:12:48 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1998-04-24 00:12:48 +0000
commit5cd45f2059b8a0e95fb66447be3f79a65a1e358f (patch)
tree461fb8bbc1974af3c85b91e37342a113d5301326
parent39e33b5e9f7a85926d61b77f02976bae7dceb80b (diff)
downloadATCD-5cd45f2059b8a0e95fb66447be3f79a65a1e358f.tar.gz
*** empty log message ***
-rw-r--r--TAO/ChangeLog-98c25
-rw-r--r--TAO/tao/Exception.cpp35
-rw-r--r--TAO/tao/Exception.h26
-rw-r--r--TAO/tao/IIOP_Interpreter.cpp2
-rw-r--r--TAO/tao/IIOP_Interpreter.h2
-rw-r--r--TAO/tao/Marshal.cpp2
-rw-r--r--TAO/tao/Marshal.h10
-rw-r--r--TAO/tao/ORB.cpp38
-rw-r--r--TAO/tao/ORB.h11
-rw-r--r--TAO/tao/Typecode_Constants.cpp4
10 files changed, 115 insertions, 40 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c
index 482745ae3f0..19e60b53299 100644
--- a/TAO/ChangeLog-98c
+++ b/TAO/ChangeLog-98c
@@ -1,3 +1,28 @@
+Thu Apr 23 18:50:29 1998 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
+
+ * tao/ORB: Added a new static method called init_orb_globals()
+ that initializes the globals when necessary.
+
+ * tao/ORB: Added a new orb_init_count_ data member that keeps
+ track of the number of times ORBs have been initialized in order
+ to do a better job of managing globa ORB resources.
+
+ * tao/Exception: Added a new method called fini() that deletes the
+ dynamically allocated exceptions list.
+
+ * tao/Exception: Changed init_standard_exceptions() to init() to
+ be consistent.
+
+ * tao/Marshal: Changed initialize() to init() to be consistent.
+
+ * tao/IIOP_Interpreter: Changed init_table() to init() to be
+ consistent.
+
+ * tao/ORB: Added support so that we make sure to only initialize
+ and destroy global ORB resources when the first/last ORB is
+ created/destroyed, rather than using static objects (which are
+ causing problems on shutdown).
+
Thu Apr 23 16:20:58 1998 Douglas C. Schmidt <schmidt@flamenco.cs.wustl.edu>
* TAO/TAO_IDL/Makefile: Change the YY* symbols to ACE_YY* symbols
diff --git a/TAO/tao/Exception.cpp b/TAO/tao/Exception.cpp
index 97b3f549509..227ae173416 100644
--- a/TAO/tao/Exception.cpp
+++ b/TAO/tao/Exception.cpp
@@ -15,10 +15,12 @@
#endif /* __ACE_INLINE__ */
// Static initializers.
+
CORBA::TypeCode_ptr
TAO_Exceptions::sys_exceptions[TAO_Exceptions::NUM_SYS_EXCEPTIONS];
-CORBA::ExceptionList TAO_Exceptions::system_exceptions;
+// @@ Somehow, we need to make sure this is destroyed...
+CORBA::ExceptionList *TAO_Exceptions::system_exceptions;
void
CORBA_Environment::exception (CORBA::Exception *ex)
@@ -251,6 +253,12 @@ TAO_Exceptions::make_standard_typecode (CORBA::TypeCode_ptr tcp,
size_t buflen,
CORBA::Environment &env)
{
+ // This function must only be called ONCE, and with a global lock
+ // held! The <CORBA::ORB_init> method is responsible for ensuring
+ // this.
+ ACE_NEW (TAO_Exceptions::system_exceptions,
+ CORBA::ExceptionList);
+
static const char *minor = "minor";
static const char *completion = "completion";
@@ -323,14 +331,12 @@ TAO_Exceptions::make_standard_typecode (CORBA::TypeCode_ptr tcp,
// a TypeCode, saving it away in the list of ones that the ORB will
// always accept as part of any operation response!
- CORBA::ULong l = TAO_Exceptions::system_exceptions.count ();
- TAO_Exceptions::system_exceptions.add (
- new (tcp) CORBA::TypeCode
- (CORBA::tk_except,
- stream.length (),
- stream.buffer (),
- CORBA::B_FALSE)
- );
+ CORBA::ULong l = TAO_Exceptions::system_exceptions->count ();
+ TAO_Exceptions::system_exceptions->add
+ (new (tcp) CORBA::TypeCode (CORBA::tk_except,
+ stream.length (),
+ stream.buffer (),
+ CORBA::B_FALSE));
assert (tcp->length_ <= TAO_Exceptions::TC_BUFLEN);
return;
@@ -383,10 +389,9 @@ STANDARD_EXCEPTION_LIST
#undef TAO_SYSTEM_EXCEPTION
void
-TAO_Exceptions::init_standard_exceptions (CORBA::Environment &env)
+TAO_Exceptions::init (CORBA::Environment &env)
{
- // Initialize the list of system exceptions, used when
- // unmarshaling.
+ // Initialize the list of system exceptions, used when unmarshaling.
#define TAO_SYSTEM_EXCEPTION(name) \
if (env.exception () == 0) \
@@ -397,6 +402,12 @@ TAO_Exceptions::init_standard_exceptions (CORBA::Environment &env)
#undef TAO_SYSTEM_EXCEPTION
}
+void
+TAO_Exceptions::fini (CORBA::Environment &env)
+{
+ delete TAO_Exceptions::system_exceptions;
+}
+
#define TAO_SYSTEM_EXCEPTION(name) \
int \
CORBA_##name ::_is_a (const char* interface_id) const \
diff --git a/TAO/tao/Exception.h b/TAO/tao/Exception.h
index 0f74b2939f9..43afe7f5c32 100644
--- a/TAO/tao/Exception.h
+++ b/TAO/tao/Exception.h
@@ -260,7 +260,6 @@ class TAO_Export TAO_Exceptions
// This class is a namespace for exception-related static data and
// methods.
public:
-
static void make_standard_typecode (CORBA::TypeCode_ptr tcp,
const char *name,
char *buffer,
@@ -270,9 +269,12 @@ public:
// correctly, initializing system exceptions is only an exercise
// in CPU time; it allocates no new memory.
- static void init_standard_exceptions (CORBA::Environment &env);
+ static void init (CORBA::Environment &env);
// Runtime initialization of all standard exception typecodes.
- // Called from CORBA::ORB::init ().
+ // Called from <CORBA::ORB_init>.
+
+ static void fini (CORBA::Environment &env);
+ // Runtime finalization of all standard exception typecodes.
enum
{
@@ -284,25 +286,27 @@ public:
};
static CORBA::TypeCode_ptr sys_exceptions [NUM_SYS_EXCEPTIONS];
+ // @@ Please document me.
- static CORBA::ExceptionList system_exceptions;
+ static CORBA::ExceptionList *system_exceptions;
+ // @@ Please document me.
};
-// ExceptionList definition taken from CORBA v2.2 Feb 1998
class CORBA_ExceptionList
{
- // =TITLE
- // CORBA_ExceptionList
- // =DESCRIPTION
- // Maintains a list of TypeCodes for Exceptions
+ // = TITLE
+ // ExceptionList definition taken from CORBA v2.2 Feb 1998
+ //
+ // = DESCRIPTION
+ // Maintains a list of TypeCodes for Exceptions.
public:
-
CORBA_ExceptionList (void);
// constructor
CORBA_ExceptionList (CORBA::ULong len,
CORBA::TypeCode_ptr *tc_list);
- // constructor - initialize given a length and an array of TypeCodes
+ // Constructor - initialize given a length and an array of
+ // TypeCodes.
~CORBA_ExceptionList (void);
// destructor
diff --git a/TAO/tao/IIOP_Interpreter.cpp b/TAO/tao/IIOP_Interpreter.cpp
index 1d59312d88d..917e237ba03 100644
--- a/TAO/tao/IIOP_Interpreter.cpp
+++ b/TAO/tao/IIOP_Interpreter.cpp
@@ -174,7 +174,7 @@ declare_entry (CORBA::WChar, tk_wchar);
declare_entry (CORBA::WString, tk_wstring);
void
-TAO_IIOP_Interpreter::init_table (void)
+TAO_IIOP_Interpreter::init (void)
{
setup_entry (CORBA::Short, tk_short);
setup_entry (CORBA::Long, tk_long);
diff --git a/TAO/tao/IIOP_Interpreter.h b/TAO/tao/IIOP_Interpreter.h
index eaefd86f6c1..cde2272a517 100644
--- a/TAO/tao/IIOP_Interpreter.h
+++ b/TAO/tao/IIOP_Interpreter.h
@@ -98,7 +98,7 @@ class TAO_Export TAO_IIOP_Interpreter
// issues; only the data being fed to the interpreter must be
// protected against concurrency.
public:
- static void init_table (void);
+ static void init (void);
// Initialize TAO's TypeCode table.
static size_t calc_nested_size_and_alignment (CORBA::TypeCode_ptr tc,
diff --git a/TAO/tao/Marshal.cpp b/TAO/tao/Marshal.cpp
index 15939e72f16..36e23aa099d 100644
--- a/TAO/tao/Marshal.cpp
+++ b/TAO/tao/Marshal.cpp
@@ -30,7 +30,7 @@
TAO_Marshal_Factory* TAO_Marshal::DEFAULT_MARSHAL_FACTORY = 0;
void
-TAO_Marshal::initialize (void)
+TAO_Marshal::init (void)
{
DEFAULT_MARSHAL_FACTORY = TAO_MARSHAL_FACTORY::instance();
}
diff --git a/TAO/tao/Marshal.h b/TAO/tao/Marshal.h
index e437522b242..e90e4183435 100644
--- a/TAO/tao/Marshal.h
+++ b/TAO/tao/Marshal.h
@@ -77,12 +77,13 @@ private:
};
class TAO_Export TAO_Marshal
-// = TITLE
-// Namespace in which to put otherwise "global" methods like
-// initialize, etc.
{
+ // = TITLE
+ // Namespace in which to put otherwise "global" methods like
+ // initialize, etc.
public:
- static void initialize (void);
+ static void init (void);
+ // @@ Please document me...
static TAO_Marshal_Factory* DEFAULT_MARSHAL_FACTORY;
};
@@ -91,6 +92,7 @@ class TAO_Export TAO_Marshal_Object
{
// = TITLE
// TAO_Marshal_Object
+ //
// = DESCRIPTION
// The Marshaling object that provides a common interface to the
// CDR object for marshaling different IDL data types
diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp
index 81654fa4797..046cd5d11a3 100644
--- a/TAO/tao/ORB.cpp
+++ b/TAO/tao/ORB.cpp
@@ -65,8 +65,15 @@ CORBA_ORB::~CORBA_ORB (void)
{
TAO_ORB_Core_instance ()->fini ();
- // This assertion isn't valid because our ORB is a singleton assert
- // (refcount_ == 0);
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, tao_mon, *ACE_Static_Object_Lock::instance (), 0));
+
+ CORBA_ORB::orb_init_count_--;
+
+ if (CORBA_ORB::orb_init_count_ == 0)
+ {
+ // Other <fini> stuff should go here...
+ TAO_Exceptions::fini (env);
+ }
}
// Set up listening endpoints.
@@ -593,6 +600,23 @@ CORBA::wstring_free (CORBA::WChar *const str)
delete [] str;
}
+void
+CORBA_ORB::init_orb_globals (void)
+{
+ ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, tao_mon, *ACE_Static_Object_Lock::instance (), 0));
+
+ // Put these initializations here so that exceptions are enabled
+ // immediately.
+
+ if (CORBA_ORB::orb_init_count_ == 0)
+ {
+ TAO_Marshal::init ();
+ TAO_Exceptions::init (env);
+ TAO_IIOP_Interpreter::init ();
+ }
+ CORBA_ORB::orb_init_count_++;
+}
+
// ORB initialisation, per OMG document 94-9-46.
//
// XXX in addition to the "built in" Internet ORB, there will be ORBs
@@ -606,8 +630,8 @@ CORBA::ORB_init (int &argc,
const char * /* orb_name */,
CORBA::Environment &env)
{
- // Using ACE_Static_Object_Lock::instance() precludes ORB_init from
- // being called within a static object CTOR.
+ // Using ACE_Static_Object_Lock::instance() precludes <ORB_init>
+ // from being called within a static object CTOR.
ACE_MT (ACE_GUARD_RETURN (ACE_SYNCH_RECURSIVE_MUTEX, guard,
*ACE_Static_Object_Lock::instance (), 0));
@@ -619,11 +643,7 @@ CORBA::ORB_init (int &argc,
// putting them in some type of TAO_Object_Manager, along with the
// Typecode_Constants...
- // Put these initializations here so that exceptions are enabled
- // immediately.
- TAO_Marshal::initialize ();
- TAO_Exceptions::init_standard_exceptions (env);
- TAO_IIOP_Interpreter::init_table ();
+ CORBA_ORB::init_orb_globals ();
if (env.exception () != 0)
return 0;
diff --git a/TAO/tao/ORB.h b/TAO/tao/ORB.h
index 78d2eb130f7..98439a1fb30 100644
--- a/TAO/tao/ORB.h
+++ b/TAO/tao/ORB.h
@@ -718,7 +718,6 @@ public:
typedef CORBA::ULong PolicyType;
typedef CORBA::ULong_out PolicyType_out;
static CORBA::TypeCode_ptr _tc_PolicyType;
-
}; // end of class (namespace) CORBA
#include "tao/Sequence.h"
@@ -895,8 +894,10 @@ private:
u_short port);
// Resolve the refernce of a service of type <name>.
+ // @@ Please document me.
ACE_SYNCH_MUTEX lock_;
u_int refcount_;
+
ACE_Atomic_Op<ACE_SYNCH_MUTEX, u_int> open_called_;
// Flag which denotes that the open method was called.
@@ -920,6 +921,14 @@ private:
// If this is non-_nil(), then this is the object reference to our
// configured Trading.
+ static void init_orb_globals (void);
+ // Initialize the ORB globals correctly, i.e., only when they
+ // haven't been initialized yet.
+
+ static int orb_init_count_;
+ // Count of the number of times that <ORB_init> has been called.
+ // This must be protected by <ACE_Static_Object_Lock>.
+
// = NON-PROVIDED METHODS
CORBA_ORB (const CORBA_ORB &);
CORBA_ORB &operator= (const CORBA_ORB &);
diff --git a/TAO/tao/Typecode_Constants.cpp b/TAO/tao/Typecode_Constants.cpp
index c5393c5f910..3976bf810fa 100644
--- a/TAO/tao/Typecode_Constants.cpp
+++ b/TAO/tao/Typecode_Constants.cpp
@@ -30,6 +30,10 @@
// Null and void
+// @@ All this stuff needs to be initialized/destroyed in one central
+// place via new/delete, i.e., it needs to be moved into the
+// CORBA::ORB_init and ~CORBA_ORB methods. Fortunately, this won't
+// break any client code.
static CORBA::TypeCode tc_null (CORBA::tk_null);
TAO_Export CORBA::TypeCode_ptr CORBA::_tc_null = (CORBA::TypeCode_ptr) &tc_null;