Date: Fri, 20 Jul 2012 03:27:07 +0000 (UTC) From: David Xu <davidxu@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r238643 - head/lib/libthr/thread Message-ID: <201207200327.q6K3R70e051491@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: davidxu Date: Fri Jul 20 03:27:07 2012 New Revision: 238643 URL: http://svn.freebsd.org/changeset/base/238643 Log: Eliminate duplicated code. Modified: head/lib/libthr/thread/thr_getschedparam.c Modified: head/lib/libthr/thread/thr_getschedparam.c ============================================================================== --- head/lib/libthr/thread/thr_getschedparam.c Fri Jul 20 03:22:17 2012 (r238642) +++ head/lib/libthr/thread/thr_getschedparam.c Fri Jul 20 03:27:07 2012 (r238643) @@ -53,25 +53,16 @@ _pthread_getschedparam(pthread_t pthread if (policy == NULL || param == NULL) return (EINVAL); - if (pthread == curthread) { - /* - * Avoid searching the thread list when it is the current - * thread. - */ + /* + * Avoid searching the thread list when it is the current + * thread. + */ + if (pthread == curthread) THR_LOCK(curthread); - *policy = curthread->attr.sched_policy; - param->sched_priority = curthread->attr.prio; - THR_UNLOCK(curthread); - ret = 0; - } - /* Find the thread in the list of active threads. */ - else if ((ret = _thr_ref_add(curthread, pthread, /*include dead*/0)) - == 0) { - THR_THREAD_LOCK(curthread, pthread); - *policy = pthread->attr.sched_policy; - param->sched_priority = pthread->attr.prio; - THR_THREAD_UNLOCK(curthread, pthread); - _thr_ref_delete(curthread, pthread); - } + else if ((ret = _thr_find_thread(curthread, pthread, /*include dead*/0))) + return (ret); + *policy = pthread->attr.sched_policy; + param->sched_priority = pthread->attr.prio; + THR_THREAD_UNLOCK(curthread, pthread); return (ret); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207200327.q6K3R70e051491>