Mail Archives: cygwin-developers/2001/06/04/06:43:01
This is a multi-part message in MIME format.
------=_NextPart_000_0123_01C0ED36.E0A6F970
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
----- Original Message -----
From: "Robert Collins" <robert DOT collins AT itdomain DOT com DOT au>
> this may be an artifact of a particularly horrendous patch I had to
> generate at one point. That does look buggy to me. Patch coming
shortly.
Patch attached at the end of the email. Thanks for catching that.
pthread_cond_wait was also bust.
> We could ignore it and return.. I'll try and get time to
> check the spec and see if that's the expected behaviour. If it is,
> consider that error a useful diagnostic for your code :].
pthread_cond_broadcast is meant to never have an error, except when the
condvariable is invalid. The attached patch fixs that little bit of
bitrot as well. It snuck in from my test _verbose_ test code, and should
have been trimmed back a little :]. You probably have code calling
pthread_cond_broadcast to ensure that no threads are waiting when you
exit the program.
Changelog
Mon Jun 4 20:39:00 2001 Robert Collins <rbtcollins AT hotmail DOT 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.
Rob
------=_NextPart_000_0123_01C0ED36.E0A6F970
Content-Type: application/octet-stream;
name="pthread_cond_broadcast_fix.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="pthread_cond_broadcast_fix.patch"
Index: thread.cc=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvs/src/src/winsup/cygwin/thread.cc,v=0A=
retrieving revision 1.32=0A=
diff -u -p -r1.32 thread.cc=0A=
--- thread.cc 2001/05/06 22:23:43 1.32=0A=
+++ thread.cc 2001/06/04 10:34:58=0A=
@@ -424,7 +424,10 @@ pthread_cond::BroadCast ()=0A=
{=0A=
if (pthread_mutex_unlock (&cond_access))=0A=
system_printf ("Failed to unlock condition variable access =
mutex, this %0p\n", this);=0A=
- system_printf ("Broadcast called with invalid mutex\n");=0A=
+ /* This isn't and API error - users are allowed to call this when =
no threads =0A=
+ are waiting =0A=
+ system_printf ("Broadcast called with invalid mutex\n");=0A=
+ */=0A=
return;=0A=
}=0A=
while (count--)=0A=
@@ -1639,6 +1642,8 @@ __pthread_cond_timedwait (pthread_cond_t=0A=
if ((((pshared_mutex *)(mutex))->flags & SYS_BASE =3D=3D SYS_BASE))=0A=
// a pshared mutex=0A=
themutex =3D __pthread_mutex_getpshared (mutex);=0A=
+ else=0A=
+ themutex =3D mutex;=0A=
=0A=
if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))=0A=
return EINVAL;=0A=
@@ -1685,6 +1690,8 @@ __pthread_cond_wait (pthread_cond_t * co=0A=
if ((((pshared_mutex *)(mutex))->flags & SYS_BASE =3D=3D SYS_BASE))=0A=
// a pshared mutex=0A=
themutex =3D __pthread_mutex_getpshared (mutex);=0A=
+ else=0A=
+ themutex =3D mutex;=0A=
if (!verifyable_object_isvalid (*themutex, PTHREAD_MUTEX_MAGIC))=0A=
return EINVAL;=0A=
if (!verifyable_object_isvalid (*cond, PTHREAD_COND_MAGIC))=0A=
------=_NextPart_000_0123_01C0ED36.E0A6F970--
- Raw text -