typo in my last post

Alexander Nedotsukov bland at FreeBSD.org
Mon Dec 8 17:45:46 PST 2003


Please read thr_mutex.c:mutex_lock_common() as
thr_mutex.c:mutex_unlock_common().
I also think it will be good to add this:
http://www.opengroup.org/onlinepubs/007904975/functions/pthread_mutex_lock.html
Here is a quote:
ERRORS
...
[EPERM]
    The current thread does not own the mutex.
...
Wich is similar to our:
...
[EPERM]
    The current thread does not hold a lock on mutex.
...
And this is what actually happen when mutex just intialized or unlocked.
It's vaild but simply owned by no one therefore not by current thread.
What I trying to say that current behaviour looks like:
...
[EPERM]
    Mutex hold by another thread.
...
See also proposed patch attached.

Thanks,
Alexander.


-------------- next part --------------
cvs server: Diffing .
Index: thr_mutex.c
===================================================================
RCS file: /home/ncvs/src/lib/libpthread/thread/thr_mutex.c,v
retrieving revision 1.44
diff -u -r1.44 thr_mutex.c
--- thr_mutex.c	9 Dec 2003 00:52:28 -0000	1.44
+++ thr_mutex.c	9 Dec 2003 01:40:21 -0000
@@ -1001,11 +1001,8 @@
 			 * mutex:
 			 */
 			if ((*m)->m_owner != curthread)
-				/*
-				 * Return an invalid argument error for no
-				 * owner and a permission error otherwise:
-				 */
-				ret = (*m)->m_owner == NULL ? EINVAL : EPERM;
+				/* We're not own this one */
+				ret = EPERM;
 
 			else if (((*m)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
 			    ((*m)->m_count > 0))
@@ -1039,11 +1036,8 @@
 			 * mutex:
 			 */
 			if ((*m)->m_owner != curthread)
-				/*
-				 * Return an invalid argument error for no
-				 * owner and a permission error otherwise:
-				 */
-				ret = (*m)->m_owner == NULL ? EINVAL : EPERM;
+				/* We're not own this one */
+				ret = EPERM;
 
 			else if (((*m)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
 			    ((*m)->m_count > 0))
@@ -1096,11 +1090,8 @@
 			 * mutex:
 			 */
 			if ((*m)->m_owner != curthread)
-				/*
-				 * Return an invalid argument error for no
-				 * owner and a permission error otherwise:
-				 */
-				ret = (*m)->m_owner == NULL ? EINVAL : EPERM;
+				/* We're not own this one */
+				ret = EPERM;
 
 			else if (((*m)->m_type == PTHREAD_MUTEX_RECURSIVE) &&
 			    ((*m)->m_count > 0))


More information about the freebsd-threads mailing list