From owner-svn-src-user@FreeBSD.ORG Wed Nov 10 01:52:10 2010 Return-Path: Delivered-To: svn-src-user@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C38C2106566C; Wed, 10 Nov 2010 01:52:10 +0000 (UTC) (envelope-from davidxu@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id A7FC68FC0A; Wed, 10 Nov 2010 01:52:10 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id oAA1qA4P071195; Wed, 10 Nov 2010 01:52:10 GMT (envelope-from davidxu@svn.freebsd.org) Received: (from davidxu@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id oAA1qAKa071192; Wed, 10 Nov 2010 01:52:10 GMT (envelope-from davidxu@svn.freebsd.org) Message-Id: <201011100152.oAA1qAKa071192@svn.freebsd.org> From: David Xu Date: Wed, 10 Nov 2010 01:52:10 +0000 (UTC) To: src-committers@freebsd.org, svn-src-user@freebsd.org X-SVN-Group: user MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r215073 - user/davidxu/libthr/lib/libthr/thread X-BeenThere: svn-src-user@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the experimental " user" src tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Nov 2010 01:52:10 -0000 Author: davidxu Date: Wed Nov 10 01:52:10 2010 New Revision: 215073 URL: http://svn.freebsd.org/changeset/base/215073 Log: Remove debug code. Use same condition variable destroying code for FBSD_1.1 interface. Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Modified: user/davidxu/libthr/lib/libthr/thread/thr_cond.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_cond.c Wed Nov 10 01:29:56 2010 (r215072) +++ user/davidxu/libthr/lib/libthr/thread/thr_cond.c Wed Nov 10 01:52:10 2010 (r215073) @@ -97,23 +97,20 @@ _pthread_cond_init(pthread_cond_t *cond, return (cond_init(cond, cond_attr)); } -int -_pthread_cond_destroy(pthread_cond_t *cvp) +static int +cond_destroy_common(pthread_cond_t *cvp) { int error = 0; if (cvp->__refcount == 0) goto next; _thr_umtx_lock_spin(&cvp->__lock); + if (cvp->__waiters > 0) { + _thr_umtx_unlock(&cvp->__lock); + return (EBUSY); + } while (cvp->__refcount != 0) { cvp->__destroying = 1; - if (cvp->__waiters > 0) { - cvp->__seq++; - cvp->__broadcast_seq++; - cvp->__waiters = 0; - cvp->__signals = 0; - _thr_umtx_wake(&cvp->__seq, INT_MAX, CV_PSHARED(cvp)); - } _thr_umtx_unlock(&cvp->__lock); _thr_umtx_wait_uint((u_int *)&cvp->__destroying, 1, NULL, CV_PSHARED(cvp)); @@ -125,6 +122,12 @@ next: return (error); } +int +_pthread_cond_destroy(pthread_cond_t *cvp) +{ + return cond_destroy_common(cvp); +} + /* * Cancellation behaivor: * Thread may be canceled at start, if thread is canceled, it means it @@ -282,7 +285,7 @@ cond_wait_common(struct pthread_cond *cv * Note that if it is robust type of mutex, we should not use * the internal lock too, because it is not robust. */ - if (1 || curthread->attr.sched_policy != SCHED_OTHER || + if (curthread->attr.sched_policy != SCHED_OTHER || curthread->priority_mutex_count != 0 || (mp->__lockflags & (UMUTEX_PRIO_PROTECT|UMUTEX_PRIO_INHERIT| UMUTEX_ROBUST)) != 0) @@ -451,13 +454,10 @@ _pthread_cond_destroy_1_0(pthread_cond_o error = EINVAL; else { cvp = *cond; - /* XXX */ + error = cond_destroy_common(cvp); + if (error) + return (error); *cond = THR_COND_DESTROYED; - - /* - * Free the memory allocated for the condition - * variable structure: - */ free(cvp); } return (error); Modified: user/davidxu/libthr/lib/libthr/thread/thr_mutex.c ============================================================================== --- user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Wed Nov 10 01:29:56 2010 (r215072) +++ user/davidxu/libthr/lib/libthr/thread/thr_mutex.c Wed Nov 10 01:52:10 2010 (r215073) @@ -1101,12 +1101,9 @@ _pthread_mutex_init_calloc_cb(pthread_mu .m_robust = PTHREAD_MUTEX_STALLED }; int error; - _thread_printf(2, "%s mp=%p\n", __func__, mp); error = mutex_init(mp, &attr); - if (error == 0) { + if (error == 0) mp->__flags |= PMUTEX_FLAG_PRIVATE; - } - _thread_printf(2, "%s init erro=%dr\n", __func__, error); return (error); }