Author: kib
Date: Wed Feb 25 16:18:26 2015
New Revision: 279284
URL: https://svnweb.freebsd.org/changeset/base/279284

Log:
  Propagate errors from _thr_umutex_unlock2 through mutex_unlock_common.
  
  Errors from _thr_umutex_unlock2 should "never happen" in normal
  circumstances.  If they do, however, return them to the application
  so it can fail early and loudly.  Hiding the errors will only delay
  the inevitable failure, making it harder to find and diagnose.
  
  Submitted by: Eric van Gyzen <[email protected]>
  Obtained from:        Dell Inc.
  PR:   198914
  MFC after:    1 week

Modified:
  head/lib/libthr/thread/thr_mutex.c

Modified: head/lib/libthr/thread/thr_mutex.c
==============================================================================
--- head/lib/libthr/thread/thr_mutex.c  Wed Feb 25 16:17:16 2015        
(r279283)
+++ head/lib/libthr/thread/thr_mutex.c  Wed Feb 25 16:18:26 2015        
(r279284)
@@ -633,7 +633,7 @@ mutex_unlock_common(struct pthread_mutex
 {
        struct pthread *curthread = _get_curthread();
        uint32_t id;
-       int defered;
+       int defered, error;
 
        if (__predict_false(m <= THR_MUTEX_DESTROYED)) {
                if (m == THR_MUTEX_DESTROYED)
@@ -647,6 +647,7 @@ mutex_unlock_common(struct pthread_mutex
        if (__predict_false(m->m_owner != curthread))
                return (EPERM);
 
+       error = 0;
        id = TID(curthread);
        if (__predict_false(
                PMUTEX_TYPE(m->m_flags) == PTHREAD_MUTEX_RECURSIVE &&
@@ -660,7 +661,7 @@ mutex_unlock_common(struct pthread_mutex
                        defered = 0;
 
                DEQUEUE_MUTEX(curthread, m);
-               _thr_umutex_unlock2(&m->m_lock, id, mtx_defer);
+               error = _thr_umutex_unlock2(&m->m_lock, id, mtx_defer);
 
                if (mtx_defer == NULL && defered)  {
                        _thr_wake_all(curthread->defer_waiters,
@@ -670,7 +671,7 @@ mutex_unlock_common(struct pthread_mutex
        }
        if (!cv && m->m_flags & PMUTEX_FLAG_PRIVATE)
                THR_CRITICAL_LEAVE(curthread);
-       return (0);
+       return (error);
 }
 
 int
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to