From owner-svn-src-head@FreeBSD.ORG Wed Feb 25 16:18:27 2015 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 0C70E4E9; Wed, 25 Feb 2015 16:18:27 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id EC09ED28; Wed, 25 Feb 2015 16:18:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id t1PGIQme087288; Wed, 25 Feb 2015 16:18:26 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id t1PGIQYO087287; Wed, 25 Feb 2015 16:18:26 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201502251618.t1PGIQYO087287@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 25 Feb 2015 16:18:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r279284 - head/lib/libthr/thread X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 25 Feb 2015 16:18:27 -0000 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 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