summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Cleeland <chris.cleeland@gmail.com>1997-10-02 19:03:22 +0000
committerChris Cleeland <chris.cleeland@gmail.com>1997-10-02 19:03:22 +0000
commite82ea4edfd3e5bb7ed3263e9b00060f185f09240 (patch)
tree716fe30a0b455ef239bc6904b1a1bf525d7b9542
parent08d467c0d18e5b54e85c71063e6f3bc996b1d64c (diff)
downloadATCD-e82ea4edfd3e5bb7ed3263e9b00060f185f09240.tar.gz
ORB-per-thread now works as long as object keys are unique throughout
the process
-rw-r--r--TAO/ChangeLog-98c16
-rw-r--r--TAO/tao/orbobj.cpp78
-rw-r--r--TAO/tao/orbobj.i19
-rw-r--r--TAO/tao/tao_internals.cpp43
-rw-r--r--TAO/tao/tao_internals.h69
-rw-r--r--TAO/tao/tao_internals.i36
6 files changed, 183 insertions, 78 deletions
diff --git a/TAO/ChangeLog-98c b/TAO/ChangeLog-98c
index 2c7b6b57131..a1b35316706 100644
--- a/TAO/ChangeLog-98c
+++ b/TAO/ChangeLog-98c
@@ -1,3 +1,19 @@
+Thu Oct 2 13:48:31 1997 Chris Cleeland <cleeland@merengue.cs.wustl.edu>
+
+ * tests/multiCubit/svr.cpp: Modified the key generation scheme to
+ include thread ID. This works around a current shortcoming in the
+ ORB Core in which the object table is shared throughout all object
+ adapters (yes, this is being fixed).
+
+ * tao/tao_internals.*: Added new class to scope static operations
+ and data completely internal to the ORB.
+
+ * tao/orbobj.{i,cpp}: Moved CORBA_ORB DTOR into cpp file. Finally
+ got rid of icky static mutex in ORB_init(). Moved service config
+ initialization into TAO_Internal method.
+
+ * tao/Orb_Core.h: Added comments.
+
Wed Oct 1 12:51:48 1997 Nanbor Wang <nw1@cumbia.cs.wustl.edu>
* tao/corbacom.h: Removed CORBA:: name resolution from the class
diff --git a/TAO/tao/orbobj.cpp b/TAO/tao/orbobj.cpp
index 5a7862b1cb2..4fa8037fe3f 100644
--- a/TAO/tao/orbobj.cpp
+++ b/TAO/tao/orbobj.cpp
@@ -27,6 +27,7 @@
#include "tao/corba.h"
#include "ace/Dynamic_Service.h"
#include "ace/Service_Repository.h"
+#include "tao/tao_internals.h"
extern void __TC_init_table (void);
extern void __TC_init_standard_exceptions (CORBA::Environment &env);
@@ -57,6 +58,20 @@ CORBA_ORB::CORBA_ORB (void)
this->refcount_ = 1;
}
+CORBA_ORB::~CORBA_ORB (void)
+{
+ TAO_Internal::close_services ();
+
+ if (! client_factory_from_service_config_)
+ delete client_factory_;
+
+ if (! server_factory_from_service_config_)
+ delete server_factory_;
+
+ // This assertion isn't valid because our ORB is a singleton
+ // assert (refcount_ == 0);
+}
+
void
CORBA_ORB::set_up_for_listening (void)
{
@@ -172,11 +187,7 @@ CORBA::ORB_init (int &argc,
char *orb_name,
CORBA::Environment &env)
{
-#if defined (ACE_HAS_THREADS)
- // @@ This use of a static is evil. Please fix...
- static ACE_Thread_Mutex lock;
- ACE_GUARD_RETURN (ACE_Thread_Mutex, guard, lock, 0);
-#endif /* ACE_HAS_THREADS */
+ ACE_GUARD_RETURN (ACE_Thread_Mutex, guard, TAO_Internal::orbinit_lock_, 0);
env.clear ();
@@ -359,62 +370,7 @@ CORBA::ORB_init (int &argc,
return 0;
// Initialize the Service Configurator
-#if !defined (VXWORKS)
- ACE_Service_Config::open (svc_config_argc, svc_config_argv);
-#else
- // Statically stick in the appropriate abstract factories for now.
-
- // This is such a hack! Blech!
- const char* service_name[2] = {
- "Client_Strategy_Factory",
- "Server_Strategy_Factory"
- };
-
-#define FAKE_SVC_ENTRY(svcname, svctype, argc, argv) \
- do \
- { \
- ACE_Service_Object *obj = _make_##svctype (); \
- obj->init (argc, argv); \
- ACE_Service_Repository::instance()->insert \
- (new ACE_Service_Type (svcname,\
- new ACE_Service_Object_Type\
- (obj, svcname, ACE_Service_Type::DELETE_OBJ | ACE_Service_Type::DELETE_THIS), 0, 1));\
- }\
- while (0) //;
-
-
- char* client_args[] = { 0 };
- FAKE_SVC_ENTRY ("Client_Strategy_Factory",
- TAO_Default_Client_Strategy_Factory,
- 0, client_args);
-
- char* server_args[] = { "-T", "-L", "dynamic", "-o", "128", 0 };
- FAKE_SVC_ENTRY ("Server_Strategy_Factory",
- TAO_Default_Server_Strategy_Factory,
- sizeof(server_args)/sizeof(server_args[0]), server_args);
-
-#if 0
- u_int flags = ACE_Service_Type::DELETE_OBJ | ACE_Service_Type::DELETE_THIS;
- ACE_Service_Record* service[2];
- ACE_Service_Type* type[2];
- const ACE_SHLIB_HANDLE noShlib = 0;
- ACE_Service_Object* obj;
-
- obj = _make_TAO_Default_Client_Strategy_Factory();
- obj->init(sizeof(client_args)/sizeof(client_args[0]), client_args);
- type[0] = new ACE_Service_Object_Type (obj, service_name[0], flags);
- service[0] = new ACE_Service_Record (service_name[0], type[0], noShlib, 1);
-
- obj = _make_TAO_Default_Server_Strategy_Factory();
- obj->init(sizeof(server_args)/sizeof(server_args[0]), server_args);
- type[1] = new ACE_Service_Object_Type (obj, service_name[1], flags);
- service[1] = new ACE_Service_Record (service_name[1], type[1], noShlib, 1);
-
- ACE_Service_Repository *svc_rep = ACE_Service_Repository::instance();
- svc_rep->insert(service[0]);
- svc_rep->insert(service[1]);
-#endif /* 0 */
-#endif /* VXWORKS */
+ TAO_Internal::open_services (svc_config_argc, svc_config_argv);
// Inititalize the "ORB" pseudo-object now.
IIOP_ORB_ptr the_orb = 0;
diff --git a/TAO/tao/orbobj.i b/TAO/tao/orbobj.i
index 5a11acaab39..aab7aacd478 100644
--- a/TAO/tao/orbobj.i
+++ b/TAO/tao/orbobj.i
@@ -1,22 +1,7 @@
+// -*- c++ -*-
+//
// $Id$
-// Constructor and destructor are accessible to subclasses
-
-ACE_INLINE
-CORBA_ORB::~CORBA_ORB (void)
-{
- ACE_Service_Config::close();
-
- if (! client_factory_from_service_config_)
- delete client_factory_;
-
- if (! server_factory_from_service_config_)
- delete server_factory_;
-
- // This assertion isn't valid because our ORB is a singleton
- // assert (refcount_ == 0);
-}
-
// CORBA dup/release build on top of COM's (why not).
ACE_INLINE void
diff --git a/TAO/tao/tao_internals.cpp b/TAO/tao/tao_internals.cpp
new file mode 100644
index 00000000000..13f00ca4e29
--- /dev/null
+++ b/TAO/tao/tao_internals.cpp
@@ -0,0 +1,43 @@
+#if !defined(__ACE_INLINE__)
+# include "tao_internals.h"
+#endif /* __ACE_INLINE__ */
+
+#include "ace/Service_Config.h"
+#include "ace/Service_Repository.h"
+#include "tao/default_server.h"
+#include "tao/default_client.h"
+
+ACE_Thread_Mutex TAO_Internal::orbinit_lock_;
+ACE_Thread_Mutex TAO_Internal::service_lock_;
+int TAO_Internal::service_open_count_ = 0;
+
+int
+TAO_Internal::fake_service_entries_i (void)
+{
+#define FAKE_SVC_ENTRY(svcname, svctype, argc, argv) \
+ do \
+ { \
+ ACE_Service_Object *obj = _make_##svctype (); \
+ obj->init (argc, argv); \
+ ACE_Service_Repository::instance()->insert \
+ (new ACE_Service_Type (svcname,\
+ new ACE_Service_Object_Type\
+ (obj, svcname, \
+ (ACE_Service_Type::DELETE_OBJ \
+ | ACE_Service_Type::DELETE_THIS)), \
+ 0, 1));\
+ }\
+ while (0) //;
+
+ char* client_args[] = { 0 };
+ FAKE_SVC_ENTRY ("Client_Strategy_Factory",
+ TAO_Default_Client_Strategy_Factory,
+ 0, client_args);
+
+ char* server_args[] = { "-T", "-L", "dynamic", "-o", "128", 0 };
+ FAKE_SVC_ENTRY ("Server_Strategy_Factory",
+ TAO_Default_Server_Strategy_Factory,
+ sizeof(server_args)/sizeof(server_args[0]), server_args);
+
+ return 0;
+}
diff --git a/TAO/tao/tao_internals.h b/TAO/tao/tao_internals.h
new file mode 100644
index 00000000000..6d93901bfb5
--- /dev/null
+++ b/TAO/tao/tao_internals.h
@@ -0,0 +1,69 @@
+// This may look like C, but it's really -*- C++ -*-
+
+// ============================================================================
+//
+// = LIBRARY
+// TAO
+//
+// = FILENAME
+// tao_internals.h
+//
+// = DESCRIPTION
+// Structures and methods completely internal to TAO.
+//
+// = AUTHOR
+// Chris Cleeland
+//
+// ============================================================================
+
+#if !defined (TAO_INTERNALS_H)
+# define TAO_INTERNALS_H
+
+# include "ace/Synch.h"
+
+class TAO_Internal
+// = TITLE
+// This class encapsulates some private behaviors and global data
+// structures used internal to TAO. No application should EVER see
+// this class.
+{
+public:
+ static int open_services (int& argc, char** argv);
+ // Initialize the ACE Service Configurator. This is a one-shot
+ // method, i.e., it can be called multiple times but it will only do
+ // its work once. It does, however, track the number of times it's
+ // called (see <open_services>). It is fully thread-safe. Return 0
+ // if successful, -1 with errno set if failure.
+
+ static int close_services (void);
+ // The complement to <open_services>, this will perform appropriate
+ // ACE Service Configurator closure operations. It should be called
+ // as many times as <open_services>, and will only actually close
+ // things down on the last call. It is fully thread-safe. Return 0
+ // if successful, -1 with errno set if failure.
+
+ static ACE_Thread_Mutex orbinit_lock_;
+ // Mutex used as a monitor in CORBA::ORB_init ()
+
+protected:
+ static int fake_service_entries_i (void);
+ // If your platform can't support the Service Configurator's model
+ // of loading services found in a file, then you should change the
+ // code in here in order to get service entries into the service
+ // repository.
+
+private:
+ TAO_Internal ();
+ // Private CTOR prevents this class from being instantiated.
+
+ static ACE_Thread_Mutex service_lock_;
+ // Monitor for service config
+
+ static int service_open_count_;
+};
+
+#if defined(__ACE_INLINE__)
+# include "tao_internals.i"
+#endif /* __ACE_INLINE__ */
+
+#endif /* TAO_INTERNALS_H */
diff --git a/TAO/tao/tao_internals.i b/TAO/tao/tao_internals.i
new file mode 100644
index 00000000000..3e930007124
--- /dev/null
+++ b/TAO/tao/tao_internals.i
@@ -0,0 +1,36 @@
+// -*- c++ -*-
+//
+// $Id$
+
+#include "ace/Service_Config.h"
+
+ACE_INLINE int
+TAO_Internal::open_services (int& argc, char** argv)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, guard, service_lock_, -1));
+
+ if (TAO_Internal::service_open_count_++ == 0)
+ {
+#if defined(TAO_PLATFORM_SVC_CONF_FILE_NOTSUP)
+ return fake_service_entries_i ();
+#else
+ return ACE_Service_Config::open (argc, argv);
+#endif
+ }
+}
+
+ACE_INLINE int
+TAO_Internal::close_services (void)
+{
+ ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, guard, service_lock_, -1));
+
+ if (service_open_count_ == 0)
+ return -1;
+
+ if (--service_open_count_ == 0)
+ return ACE_Service_Config::close ();
+
+ return 0;
+}
+
+