From 5691881058b52c0fdec0caea781752203f9b2214 Mon Sep 17 00:00:00 2001
From: Christopher Faylor <me@cgf.cx>
Date: Thu, 7 Jun 2001 19:55:06 +0000
Subject: [PATCH] * thread.cc (pthread_cond::Broadcast): Don't print error
 messages on invalid mutexs - user programs are allowed to call
 pthread_cond_broadcast like that. (__pthread_cond_timedwait): Initialise
 themutex properly. (__pthread_cond_wait): Initialise themutex properly.

---
 winsup/cygwin/ChangeLog | 8 ++++++++
 winsup/cygwin/thread.cc | 9 ++++++++-
 2 files changed, 16 insertions(+), 1 deletion(-)

diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 9d89460ea..bfee67960 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,11 @@
+Thu Jun  7 15:54:32 2001  Robert Collins <rbtcollins@hotmail.com>
+
+	* thread.cc (pthread_cond::Broadcast): Don't print error messages on
+	invalid mutexs - user programs are allowed to call
+	pthread_cond_broadcast like that.
+	(__pthread_cond_timedwait): Initialise themutex properly.
+	(__pthread_cond_wait): Initialise themutex properly.
+
 Tue Jun  5 19:56:00 2001  Corinna Vinschen <corinna@vinschen.de>
 
 	* fhandler_console.cc (fhandler_console::dup): Allocate space for
diff --git a/winsup/cygwin/thread.cc b/winsup/cygwin/thread.cc
index ad2ad00c4..894038855 100644
--- a/winsup/cygwin/thread.cc
+++ b/winsup/cygwin/thread.cc
@@ -424,7 +424,10 @@ pthread_cond::BroadCast ()
     {
       if (pthread_mutex_unlock (&cond_access))
         system_printf ("Failed to unlock condition variable access mutex, this %0p\n", this);
-      system_printf ("Broadcast called with invalid mutex\n");
+      /* This isn't and API error - users are allowed to call this when no threads 
+	 are waiting 
+	 system_printf ("Broadcast called with invalid mutex\n");
+      */
       return;
     }
   while (count--)
@@ -1639,6 +1642,8 @@ __pthread_cond_timedwait (pthread_cond_t * cond, pthread_mutex_t * mutex,
   if ((((pshared_mutex *)(mutex))->flags & SYS_BASE == SYS_BASE))
     // a pshared mutex
     themutex = __pthread_mutex_getpshared (mutex);
+  else
+    themutex = mutex;
 
   if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))
     return EINVAL;
@@ -1685,6 +1690,8 @@ __pthread_cond_wait (pthread_cond_t * cond, pthread_mutex_t * mutex)
   if ((((pshared_mutex *)(mutex))->flags & SYS_BASE == SYS_BASE))
     // a pshared mutex
     themutex = __pthread_mutex_getpshared (mutex);
+  else
+    themutex = mutex;
   if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))
     return EINVAL;
   if (!verifyable_object_isvalid (*cond, PTHREAD_COND_MAGIC))