summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog-99b17
-rw-r--r--THANKS1
-rw-r--r--ace/Malloc_T.cpp2
-rw-r--r--ace/Synch.cpp4
-rw-r--r--ace/Synch.h4
-rw-r--r--tests/MM_Shared_Memory_Test.cpp41
6 files changed, 46 insertions, 23 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b
index 88413f743a8..1ac9e220410 100644
--- a/ChangeLog-99b
+++ b/ChangeLog-99b
@@ -1,5 +1,22 @@
Mon Oct 4 08:31:58 1999 Douglas C. Schmidt <schmidt@tango.cs.wustl.edu>
+ * tests/MM_Shared_Memory_Test.cpp: Fixed the test so that it should
+ work correctly for platforms that use either processes or
+ threads. Also, make sure to call remove() on the
+ ACE_Process_Semaphore so that stray semaphores aren't left
+ around. Thanks to David Levine for helping to track this down.
+
+ * ace/Synch.h: Updated the documentation for the
+ ACE_Process_Semaphore destructor to indicate that it doesn't
+ remove the semaphore. Instead, you must call remove()
+ explicitly. Thanks to David Levine for helping to track this
+ down.
+
+ * ace/Malloc_T.cpp (print_stats): Added a cast for the ACE_LOCK to
+ work around the fact that the print_stats() method is const.
+ Thanks to Jean-Marc Strauss <jms97@club-internet.fr> for
+ reporting this.
+
* ace/INET_Addr.cpp (set): Added ACE_UNUSED_ARG
so the compiler won't complain about the protocol paraemter in
parts of the code where it's not used.
diff --git a/THANKS b/THANKS
index 3dc48df07b0..74333111f45 100644
--- a/THANKS
+++ b/THANKS
@@ -785,6 +785,7 @@ Chris Hafey <chris@stentorsoft.com>
Rick Hess <rick.hess@lmco.com>
David Dunn <dunn@tripos.com>
Jaymes Galvin <galvinj@agcs.com>
+Marat <c_marat@mypad.com>
I would particularly like to thank Paul Stephenson, who worked with me
at Ericsson. Paul devised the recursive Makefile scheme that
diff --git a/ace/Malloc_T.cpp b/ace/Malloc_T.cpp
index d73eb600c05..e3aaef2cb27 100644
--- a/ace/Malloc_T.cpp
+++ b/ace/Malloc_T.cpp
@@ -96,7 +96,7 @@ template <ACE_MEM_POOL_1, class ACE_LOCK> void
ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::print_stats (void) const
{
ACE_TRACE ("ACE_Malloc<ACE_MEM_POOL_2, ACE_LOCK>::print_stats");
- ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);
+ ACE_GUARD (ACE_LOCK, ace_mon, (ACE_LOCK &) this->lock_);
if (this->cb_ptr_ == 0)
return;
diff --git a/ace/Synch.cpp b/ace/Synch.cpp
index ff4ef5878ae..93915f81cba 100644
--- a/ace/Synch.cpp
+++ b/ace/Synch.cpp
@@ -317,9 +317,7 @@ ACE_Process_Semaphore::ACE_Process_Semaphore (u_int count,
ACE_Process_Semaphore::~ACE_Process_Semaphore (void)
{
-// ACE_TRACE ("ACE_Process_Semaphore::~ACE_Process_Semaphore");
- // if (this->remove () == -1)
- // ACE_ERROR ((LM_ERROR, ASYS_TEXT("%p\n"), ASYS_TEXT("ACE_Process_Mutex::~ACE_Process_Mutex")));
+ // ACE_TRACE ("ACE_Process_Semaphore::~ACE_Process_Semaphore");
}
// Explicitly destroy the semaphore.
diff --git a/ace/Synch.h b/ace/Synch.h
index 807825fc3c9..ca32cc3cdcc 100644
--- a/ace/Synch.h
+++ b/ace/Synch.h
@@ -348,7 +348,9 @@ public:
// maximum value of <max>.
~ACE_Process_Semaphore (void);
- // Implicitly destroy the semaphore.
+ // This method is a no-op, i.e., it doesn't remove the semaphore.
+ // If you want to remove the semaphore, you must call the <remove>
+ // method explicitly.
int remove (void);
// Explicitly destroy the semaphore. Note that only one thread
diff --git a/tests/MM_Shared_Memory_Test.cpp b/tests/MM_Shared_Memory_Test.cpp
index b289a943565..654dd8fde08 100644
--- a/tests/MM_Shared_Memory_Test.cpp
+++ b/tests/MM_Shared_Memory_Test.cpp
@@ -36,18 +36,23 @@ USELIB("..\ace\aced.lib");
const int SHMSZ = 27;
static TCHAR shm_key[] = ACE_TEMP_FILE_NAME ACE_TEXT ("XXXXXX");
+#if defined (ACE_LACKS_FORK)
+static ACE_Thread_Semaphore SYNCHRONIZER;
+#else
+typedef ACE_Process_Semaphore SYNCHRONIZER;
+#endif /* !defined (ACE_LACKS_FORK) */
+
// Synchronize the start of the parent and the child.
-static ACE_Process_Semaphore *process_synchronizer = 0;
+static SYNCHRONIZER *synchronizer = 0;
static void *
child (void * = 0)
{
int result;
-#if !defined (ACE_LACKS_FORK)
- // Wait for the parent process to
- result = process_synchronizer->acquire ();
+
+ // Wait for the parent to be initialized.
+ result = synchronizer->acquire ();
ACE_ASSERT (result != -1);
-#endif /* !defined (ACE_LACKS_FORK) */
char *t = ACE_ALPHABET;
ACE_Shared_Memory_MM shm_child;
@@ -91,11 +96,9 @@ parent (void * = 0)
*s = '\0';
-#if !defined (ACE_LACKS_FORK)
- // Allow the child process to proceed.
- result = process_synchronizer->release ();
+ // Allow the child to proceed.
+ result = synchronizer->release ();
ACE_ASSERT (result != -1);
-#endif /* !defined (ACE_LACKS_FORK) */
// Perform a "busy wait" until the child sets the character to '*'.
while (*shm != '*')
@@ -112,14 +115,14 @@ parent (void * = 0)
static int
spawn (void)
{
-#if !defined (ACE_LACKS_FORK)
- // Create the synchronizer before spawning the child process, to
- // avoid race condition between the creation in the parent and use
- // in the child.
- ACE_NEW_RETURN (process_synchronizer,
- ACE_Process_Semaphore (0), // Locked by default...
+ // Create the synchronizer before spawning the child process/thread,
+ // to avoid race condition between the creation in the parent and
+ // use in the child.
+ ACE_NEW_RETURN (synchronizer,
+ SYNCHRONIZER (0), // Locked by default...
-1);
+#if !defined (ACE_LACKS_FORK)
switch (ACE_OS::fork (ASYS_TEXT ("child")))
{
case -1:
@@ -130,7 +133,9 @@ spawn (void)
/* NOTREACHED */
case 0:
parent ();
- delete process_synchronizer;
+ // Remove the semaphore.
+ synchronizer->remove ();
+ delete synchronizer;
break;
/* NOTREACHED */
default:
@@ -156,9 +161,9 @@ spawn (void)
ASYS_TEXT ("thread create failed")),
1);
ACE_Thread_Manager::instance ()->wait ();
- ACE_UNUSED_ARG (process_synchronizer);
+ delete synchronizer;
#else
- ACE_UNUSED_ARG (process_synchronizer);
+ ACE_UNUSED_ARG (synchronizer);
ACE_ERROR_RETURN ((LM_ERROR,
ASYS_TEXT ("only one thread may be run in a process on this platform\n")),
1);