summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--TAO/ChangeLog10
-rw-r--r--TAO/tao/ORB.cpp35
-rw-r--r--TAO/tao/TAO_Singleton_Manager.cpp36
-rw-r--r--TAO/tao/TAO_Singleton_Manager.h26
4 files changed, 99 insertions, 8 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index a26256a0f12..a52afa9395b 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,13 @@
+Thu Sep 9 16:16:48 2004 Ossama Othman <ossama@dre.vanderbilt.edu>
+
+ * tao/ORB.cpp:
+ * tao/TAO_Singleton_Manager.h:
+ * tao/TAO_Singleton_Manager.cpp:
+
+ Reintroduced TAO's unexpected exception handler. It will be
+ removed once again once the skeleton refactoring work is
+ committed.
+
Thu Sep 9 15:57:30 2004 Ossama Othman <ossama@dre.vanderbilt.edu>
* tao/DLL_ORB.h:
diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp
index c3b3131d9d1..a49d6a35bd1 100644
--- a/TAO/tao/ORB.cpp
+++ b/TAO/tao/ORB.cpp
@@ -47,6 +47,14 @@ ACE_RCSID (tao,
#include "ace/OS_NS_string.h"
#include "ace/os_include/os_ctype.h"
+#if defined (ACE_HAS_EXCEPTIONS)
+void TAO_unexpected_exception_handler (void)
+{
+ throw CORBA::UNKNOWN ();
+}
+#endif /* ACE_HAS_EXCEPTIONS */
+
+
static const char ior_prefix[] = "IOR:";
// = Static initialization.
@@ -1298,20 +1306,31 @@ CORBA::ORB::init_orb_globals (ACE_ENV_SINGLE_ARG_DECL)
TAO_Exceptions::init (ACE_ENV_SINGLE_ARG_PARAMETER);
ACE_CHECK;
+#if defined (ACE_HAS_EXCEPTIONS)
+ // This must be done after the system TypeCodes and Exceptions have
+ // been initialized. An unexpected exception will cause TAO's
+ // unexpected exception handler to be called. That handler
+ // transforms all unexpected exceptions to CORBA::UNKNOWN, which of
+ // course requires the TypeCode constants and system exceptions to
+ // have been initialized.
+ TAO_Singleton_Manager::instance ()->_set_unexpected (
+ ::TAO_unexpected_exception_handler);
+#endif /* ACE_HAS_EXCEPTIONS */
+
// Verify some of the basic implementation requirements. This test
// gets optimized away by a decent compiler (or else the rest of the
// routine does).
//
// NOTE: we still "just" assume that native floating point is IEEE.
- if (sizeof (CORBA::Boolean) != 1
- || sizeof (CORBA::Short) != 2
- || sizeof (CORBA::Long) != 4
- || sizeof (CORBA::LongLong) != 8
- || sizeof (CORBA::Float) != 4
- || sizeof (CORBA::Double) != 8
+ if ( sizeof (CORBA::Boolean) != 1
+ || sizeof (CORBA::Short) != 2
+ || sizeof (CORBA::Long) != 4
+ || sizeof (CORBA::LongLong) != 8
+ || sizeof (CORBA::Float) != 4
+ || sizeof (CORBA::Double) != 8
|| sizeof (CORBA::LongDouble) != 16
- || sizeof (CORBA::WChar) < 2
- || sizeof (void *) != ACE_SIZEOF_VOID_P)
+ || sizeof (CORBA::WChar) < 2
+ || sizeof (void *) != ACE_SIZEOF_VOID_P)
{
ACE_ERROR ((LM_ERROR,
"%N; ERROR: unexpected basic type size; "
diff --git a/TAO/tao/TAO_Singleton_Manager.cpp b/TAO/tao/TAO_Singleton_Manager.cpp
index 7c1621cf566..872dea0e5fc 100644
--- a/TAO/tao/TAO_Singleton_Manager.cpp
+++ b/TAO/tao/TAO_Singleton_Manager.cpp
@@ -51,6 +51,9 @@ TAO_Singleton_Manager::TAO_Singleton_Manager (void)
#if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
, internal_lock_ (new TAO_SYNCH_RECURSIVE_MUTEX)
# endif /* ACE_MT_SAFE */
+#if defined (ACE_HAS_EXCEPTIONS)
+ , old_unexpected_ (0)
+#endif /* ACE_HAS_EXCEPTIONS */
{
// Be sure that no further instances are created via instance ().
if (instance_ == 0)
@@ -248,6 +251,19 @@ TAO_Singleton_Manager::fini (void)
this->internal_lock_ = 0;
#endif /* ACE_MT_SAFE */
+#if defined (ACE_HAS_EXCEPTIONS)
+ // Restore the old unexpected exception handler since TAO will no
+ // longer be handling exceptions. Allow the application to once
+ // again handle unexpected exceptions.
+# if (!defined (_MSC_VER) \
+ && defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) \
+ && (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB != 0)) || defined (ghs)
+ (void) std::set_unexpected (this->old_unexpected_);
+# else
+ (void) set_unexpected (this->old_unexpected_);
+# endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */
+#endif /* ACE_HAS_EXCEPTIONS */
+
// Indicate that this TAO_Singleton_Manager instance has been shut down.
this->object_manager_state_ = OBJ_MAN_SHUT_DOWN;
@@ -284,6 +300,26 @@ TAO_Singleton_Manager::shutting_down (void)
: 1;
}
+#if defined (ACE_HAS_EXCEPTIONS)
+void
+TAO_Singleton_Manager::_set_unexpected (TAO_unexpected_handler u)
+{
+ // This must be done after the system TypeCodes and Exceptions have
+ // been initialized. An unexpected exception will cause TAO's
+ // unexpected exception handler to be called. That handler
+ // transforms all unexpected exceptions to CORBA::UNKNOWN, which of
+ // course requires the TypeCode constants and system exceptions to
+ // have been initialized.
+# if (!defined (_MSC_VER) \
+ && defined (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB) \
+ && (ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB != 0)) || defined (ghs)
+ this->old_unexpected_ = std::set_unexpected (u);
+# else
+ this->old_unexpected_ = set_unexpected (u);
+# endif /* ACE_USES_STD_NAMESPACE_FOR_STDCPP_LIB */
+}
+#endif /* ACE_HAS_EXCEPTIONS */
+
int
TAO_Singleton_Manager::at_exit_i (void *object,
ACE_CLEANUP_FUNC cleanup_hook,
diff --git a/TAO/tao/TAO_Singleton_Manager.h b/TAO/tao/TAO_Singleton_Manager.h
index 079f27eaebf..891a31ebf0e 100644
--- a/TAO/tao/TAO_Singleton_Manager.h
+++ b/TAO/tao/TAO_Singleton_Manager.h
@@ -28,6 +28,10 @@
#include "tao/orbconf.h"
#include "ace/Object_Manager_Base.h"
+#if defined (ACE_HAS_EXCEPTIONS)
+typedef void (*TAO_unexpected_handler)(void);
+#endif /* ACE_HAS_EXCEPTIONS */
+
/// Adapter for cleanup, used to register cleanup function with the
/// ACE_Object_Manager.
@@ -145,6 +149,17 @@ public:
ACE_CLEANUP_FUNC cleanup_hook,
void *param);
+#if defined (ACE_HAS_EXCEPTIONS)
+ /// Set a new unexpected exception handler.
+ /**
+ * The old one will be stored for restoration later on.
+ *
+ * @note Calling this method multiple times will cause the stored
+ * old unexpected exception handler pointer to be lost.
+ */
+ void _set_unexpected (TAO_unexpected_handler u);
+#endif /* ACE_HAS_EXCEPTIONS */
+
private:
/// Force allocation on the heap.
//@{
@@ -187,6 +202,17 @@ private:
TAO_SYNCH_RECURSIVE_MUTEX *internal_lock_;
#endif /* ACE_MT_SAFE */
+#if defined (ACE_HAS_EXCEPTIONS)
+ /// The old unexpected exception handler.
+ /**
+ * A pointer to the old unexpected exception handler is stored so
+ * that it can be restored when TAO is unloaded, for example.
+ * Otherwise, any unexpected exceptions will result in a call to
+ * TAO's unexpected exception handler which may no longer exist if
+ * TAO was unloaded.
+ */
+ TAO_unexpected_handler old_unexpected_;
+#endif /* ACE_HAS_EXCEPTIONS */
};
#if defined (__ACE_INLINE__)