summaryrefslogtreecommitdiff
path: root/ace
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>1997-11-07 03:02:26 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>1997-11-07 03:02:26 +0000
commit891adbd6fce978d3313459712e28b41185e8368c (patch)
tree2f35006954c08f38cb8d11c95a73904901297103 /ace
parent8d0fb9f8f164734703f9d939a21596cf7c6f7552 (diff)
downloadATCD-891adbd6fce978d3313459712e28b41185e8368c.tar.gz
*** empty log message ***
Diffstat (limited to 'ace')
-rw-r--r--ace/ACE.cpp2
-rw-r--r--ace/Connector.cpp15
-rw-r--r--ace/Object_Manager.cpp107
-rw-r--r--ace/Object_Manager.h20
-rw-r--r--ace/config-sco-5.0.0.h1
5 files changed, 112 insertions, 33 deletions
diff --git a/ace/ACE.cpp b/ace/ACE.cpp
index e8d79e571d1..644a428741e 100644
--- a/ace/ACE.cpp
+++ b/ace/ACE.cpp
@@ -1494,7 +1494,7 @@ int
ACE::set_handle_limit (int new_limit)
{
ACE_TRACE ("ACE::set_handle_limit");
-#if defined (RLIMIT_NOFILE)
+#if defined (RLIMIT_NOFILE)
struct rlimit rl;
if (ACE_OS::getrlimit (RLIMIT_NOFILE, &rl) != -1)
diff --git a/ace/Connector.cpp b/ace/Connector.cpp
index 18da7ff955e..57cef845384 100644
--- a/ace/Connector.cpp
+++ b/ace/Connector.cpp
@@ -401,26 +401,25 @@ ACE_Connector<SH, PR_CO_2>::connect_n (size_t n,
char failed_svc_handlers[],
const ACE_Synch_Options &synch_options)
{
- int status = 0; // Set to -1 if an error occurs
- size_t i;
+ int result = 0;
- for (i = 0; i < n; i++)
+ for (size_t i = 0; i < n; i++)
{
if (this->connect (sh[i], remote_addrs[i], synch_options) == -1
&& !(synch_options[ACE_Synch_Options::USE_REACTOR]
&& errno == EWOULDBLOCK))
{
- status = -1;
+ result = -1;
if (failed_svc_handlers != 0)
// Mark this entry as having failed.
failed_svc_handlers[i] = 1;
}
- else if (failed_svc_handlers != 0)
- // Mark this entry as having succeeded.
- failed_svc_handlers[i] = 0;
+ else if (failed_svc_handlers != 0)
+ // Mark this entry as having succeeded.
+ failed_svc_handlers[i] = 0;
}
- return status;
+ return result;
}
// Cancel a <svc_handler> that was started asynchronously.
diff --git a/ace/Object_Manager.cpp b/ace/Object_Manager.cpp
index b4b281d35f4..1a36077f268 100644
--- a/ace/Object_Manager.cpp
+++ b/ace/Object_Manager.cpp
@@ -316,22 +316,101 @@ ACE_Object_Manager::get_singleton_lock (ACE_Null_Mutex *&lock)
}
if (ACE_Object_Manager_singleton_null_lock != 0)
- {
- lock = &ACE_Object_Manager_singleton_null_lock->object ();
- }
+ lock = &ACE_Object_Manager_singleton_null_lock->object ();
}
else
+ // Use the Object_Manager's preallocated lock.
+ lock = ACE_Managed_Object<ACE_Null_Mutex>::get_preallocated_object
+ (ACE_Object_Manager::ACE_SINGLETON_NULL_LOCK);
+
+ return 0;
+}
+
+int
+ACE_Object_Manager::get_singleton_lock (ACE_Thread_Mutex *&lock)
+{
+ if (lock == 0)
{
- // Use the Object_Manager's preallocated lock.
- lock = ACE_Managed_Object<ACE_Null_Mutex>::get_preallocated_object
- (ACE_Object_Manager::ACE_SINGLETON_NULL_LOCK);
+ if (ACE_Object_Manager::starting_up () ||
+ ACE_Object_Manager::shutting_down ())
+ {
+ // The Object_Manager and its internal lock have not been
+ // constructed yet. Therefore, the program is single-
+ // threaded at this point. Or, the ACE_Object_Manager
+ // instance has been destroyed, so the internal lock is not
+ // available. Either way, we can not use double-checked
+ // locking.
+
+ ACE_NEW_RETURN (lock, ACE_Thread_Mutex, -1);
+
+ // Add the new lock to the array of locks to be deleted
+ // at program termination.
+ if (ACE_Object_Manager_singleton_thread_locks == 0)
+ {
+ // Create the array, then insert the new lock.
+ ACE_NEW_RETURN (ACE_Object_Manager_singleton_thread_locks,
+ ACE_Array<ACE_Thread_Mutex *> (
+ (size_t) 1,
+ (ACE_Thread_Mutex *) 0),
+ -1);
+ (*ACE_Object_Manager_singleton_thread_locks)[0] = lock;
+ }
+ else
+ {
+ // Grow the array, then insert the new lock.
+
+ // Copy the array pointer.
+ ACE_Array<ACE_Thread_Mutex *> *tmp =
+ ACE_Object_Manager_singleton_thread_locks;
+
+ // Create a new array with one more slot than the current one.
+ ACE_NEW_RETURN (ACE_Object_Manager_singleton_thread_locks,
+ ACE_Array<ACE_Thread_Mutex *> (
+ tmp->size () + (size_t) 1,
+ (ACE_Thread_Mutex *) 0),
+ -1);
+
+ // Copy the old array to the new array.
+ for (u_int i = 0; i < tmp->size (); ++i)
+ (*ACE_Object_Manager_singleton_thread_locks)[i] = (*tmp) [i];
+
+ // Insert the new lock at the end of the array.
+ (*ACE_Object_Manager_singleton_thread_locks)[tmp->size ()] =
+ lock;
+
+ delete tmp;
+ }
+ }
+ else
+ {
+ // Allocate a new lock, but use double-checked locking to
+ // ensure that only one thread allocates it.
+ ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex,
+ ace_mon,
+ *ACE_Object_Manager::instance ()->lock_,
+ -1));
+
+ if (lock == 0)
+ {
+ ACE_Cleanup_Adapter<ACE_Thread_Mutex> *lock_adapter;
+ ACE_NEW_RETURN (lock_adapter,
+ ACE_Cleanup_Adapter<ACE_Thread_Mutex>,
+ -1);
+ lock = &lock_adapter->object ();
+
+ // Register the lock for destruction at program termination.
+ // This call will cause us to grab the ACE_Object_Manager lock_
+ // again; that's why it is a recursive lock.
+ ACE_Object_Manager::at_exit (lock_adapter);
+ }
+ }
}
return 0;
}
int
-ACE_Object_Manager::get_singleton_lock (ACE_Thread_Mutex *&lock)
+ACE_Object_Manager::get_singleton_lock (ACE_Mutex *&lock)
{
if (lock == 0)
{
@@ -437,17 +516,13 @@ ACE_Object_Manager::get_singleton_lock (ACE_Recursive_Thread_Mutex *&lock)
}
if (ACE_Object_Manager_singleton_recursive_lock != 0)
- {
- lock = &ACE_Object_Manager_singleton_recursive_lock->object ();
- }
+ lock = &ACE_Object_Manager_singleton_recursive_lock->object ();
}
else
- {
- // Use the Object_Manager's preallocated lock.
- lock = ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::
- get_preallocated_object (ACE_Object_Manager::
- ACE_SINGLETON_RECURSIVE_THREAD_LOCK);
- }
+ // Use the Object_Manager's preallocated lock.
+ lock = ACE_Managed_Object<ACE_Recursive_Thread_Mutex>::
+ get_preallocated_object (ACE_Object_Manager::
+ ACE_SINGLETON_RECURSIVE_THREAD_LOCK);
return 0;
}
diff --git a/ace/Object_Manager.h b/ace/Object_Manager.h
index b4ffb05dd6c..b42cbcfcd1b 100644
--- a/ace/Object_Manager.h
+++ b/ace/Object_Manager.h
@@ -248,21 +248,27 @@ public:
// = The <get_singleton_lock> accessors are for internal use by ACE_Singleton _only_.
static int get_singleton_lock (ACE_Null_Mutex *&);
- // Accesses a null lock to be used for construction of
- // ACE_Singletons. Returns 0, and the lock in the argument, on
+ // Accesses an <ACE_Null_Mutex> to be used for construction of
+ // <ACE_Singletons>. Returns 0, and the lock in the argument, on
// success; returns -1 on failure. The argument is ignored -- it is
// only used for overload resolution.
static int get_singleton_lock (ACE_Thread_Mutex *&);
- // Accesses a non-recursive lock to be used for construction of
- // ACE_Singletons. Returns 0, and the lock in the argument, on
+ // Accesses a non-recursive <ACE_Thread_Mutex> to be used for
+ // construction of <ACE_Singletons>. Returns 0, and the lock in the
+ // argument, on success; returns -1 on failure. The argument is
+ // ignored -- it is only used for overload resolution.
+
+ static int get_singleton_lock (ACE_Mutex *&);
+ // Accesses a non-recursive <ACE_Mutex> to be used for construction
+ // of <ACE_Singletons>. Returns 0, and the lock in the argument, on
// success; returns -1 on failure. The argument is ignored -- it is
// only used for overload resolution.
static int get_singleton_lock (ACE_Recursive_Thread_Mutex *&);
- // Accesses a recursive lock to be used for construction of
- // ACE_Singletons. Returns 0, and the lock in the argument, on
- // success; returns -1 on failure.
+ // Accesses a recursive <ACE_Recursive_Thread_Mutex> to be used for
+ // construction of <ACE_Singletons>. Returns 0, and the lock in the
+ // argument, on success; returns -1 on failure.
static int get_singleton_lock (ACE_RW_Thread_Mutex *&);
// Accesses a readers/writers lock to be used for construction of
diff --git a/ace/config-sco-5.0.0.h b/ace/config-sco-5.0.0.h
index 91f2ceeb564..db12d38ee91 100644
--- a/ace/config-sco-5.0.0.h
+++ b/ace/config-sco-5.0.0.h
@@ -15,7 +15,6 @@
#define ACE_LACKS_SYSCALL
#define ACE_LACKS_STRRECVFD
#define ACE_NEEDS_FTRUNCATE
-#define ACE_LACKS_RLIMIT
#define ACE_LACKS_MADVISE
#define ACE_LACKS_NETDB_REENTRANT_FUNCTIONS