FreeBSD Bugzilla – Attachment 12598 Details for
Bug 24261
pthread_mutex_lock/pthread_mutex_unlock does not honor PTHREAD_MUTEX_ERRORCHECK
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 2.04 KB, created by
nuspl
on 2001-01-12 00:20:00 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
nuspl
Created:
2001-01-12 00:20:00 UTC
Size:
2.04 KB
patch
obsolete
>--- uthread_mutex.c.orig Thu Jan 11 16:44:56 2001 >+++ uthread_mutex.c Thu Jan 11 17:02:19 2001 >@@ -420,6 +420,22 @@ > _thread_run->interrupted = 0; > > /* >+ * According to: >+ * http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_mutex_lock.html >+ * If the mutex type is PTHREAD_MUTEX_ERRORCHECK, then error >+ * checking is provided. If a thread attempts to relock a mutex >+ * that it has already locked, an error will be returned. >+ * >+ * The pthread_mutex_lock() function may fail if: >+ * [EDEADLK] >+ * The current thread already owns the mutex. >+ */ >+ if (((*mutex)->m_owner == _thread_run) && >+ ((*mutex)->m_type == PTHREAD_MUTEX_ERRORCHECK)) { >+ return (EDEADLK); >+ } >+ >+ /* > * Enter a loop waiting to become the mutex owner. We need a > * loop in case the waiting thread is interrupted by a signal > * to execute a signal handler. It is not (currently) possible >@@ -739,6 +755,7 @@ > mutex_unlock_common(pthread_mutex_t * mutex, int add_reference) > { > int ret = 0; >+ int proto; > > if (mutex == NULL || *mutex == NULL) { > ret = EINVAL; >@@ -752,8 +769,33 @@ > /* Lock the mutex structure: */ > _SPINLOCK(&(*mutex)->lock); > >+ proto = (*mutex)->m_protocol; >+ >+ /* >+ * According to: >+ * http://www.opengroup.org/onlinepubs/007908799/xsh/pthread_mutex_lock.html >+ * >+ * If the mutex type is PTHREAD_MUTEX_ERRORCHECK, then >+ * error checking is provided. If a thread attempts to >+ * unlock a mutex that it has not locked or a mutex which >+ * is unlocked, an error will be returned. >+ * >+ * The pthread_mutex_unlock() function may fail if: >+ * [EPERM] >+ * The current thread does not own the mutex. >+ */ >+ if (((*mutex)->m_owner != _thread_run) && >+ ((*mutex)->m_type == PTHREAD_MUTEX_ERRORCHECK)) { >+ proto = -1; >+ ret = EPERM; >+ } >+ > /* Process according to mutex type: */ >- switch ((*mutex)->m_protocol) { >+ switch (proto) { >+ case -1: >+ /* we've already caught an error, do nothing */ >+ break; >+ > /* Default POSIX mutex: */ > case PTHREAD_PRIO_NONE: > /*
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 24261
: 12598