This is the mail archive of the libc-hacker@sources.redhat.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[PATCH] Fix __pthread_mutex_destroy


Hi!

After reading a few times spinlock.[ch] and mutex.c, I believe dtc's patch
is correct. Can you apply it?
Thanks.

2000-10-05  Jakub Jelinek  <jakub@redhat.com>

	* mutex.c (__pthread_mutex_destroy): Correct test of
	busy mutex for mutexes using alternate fastlocks.
	Patch by dtc@cmucl.cons.org.

--- libc/linuxthreads/mutex.c.jj	Fri Sep 29 12:56:56 2000
+++ libc/linuxthreads/mutex.c	Thu Oct  5 18:30:08 2000
@@ -38,8 +38,20 @@ strong_alias (__pthread_mutex_init, pthr
 
 int __pthread_mutex_destroy(pthread_mutex_t * mutex)
 {
-  if ((mutex->__m_lock.__status & 1) != 0) return EBUSY;
-  return 0;
+  switch (mutex->__m_kind) {
+  case PTHREAD_MUTEX_ADAPTIVE_NP:
+  case PTHREAD_MUTEX_RECURSIVE_NP:
+    if ((mutex->__m_lock.__status & 1) != 0)
+      return EBUSY;
+    return 0;
+  case PTHREAD_MUTEX_ERRORCHECK_NP:
+  case PTHREAD_MUTEX_TIMED_NP:
+    if (mutex->__m_lock.__status != 0)
+      return EBUSY;
+    return 0;
+  default:
+    return EINVAL;
+  }
 }
 strong_alias (__pthread_mutex_destroy, pthread_mutex_destroy)
 

	Jakub

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]