Date: Fri, 20 Jul 2012 03:16:53 +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: r238641 - head/lib/libthr/thread Message-ID: <201207200316.q6K3Grn9050708@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: davidxu Date: Fri Jul 20 03:16:52 2012 New Revision: 238641 URL: http://svn.freebsd.org/changeset/base/238641 Log: Eliminate duplicated code. Modified: head/lib/libthr/thread/thr_setprio.c Modified: head/lib/libthr/thread/thr_setprio.c ============================================================================== --- head/lib/libthr/thread/thr_setprio.c Fri Jul 20 03:00:41 2012 (r238640) +++ head/lib/libthr/thread/thr_setprio.c Fri Jul 20 03:16:52 2012 (r238641) @@ -46,37 +46,22 @@ _pthread_setprio(pthread_t pthread, int param.sched_priority = prio; if (pthread == curthread) { + pthread = curthread; THR_LOCK(curthread); - if (curthread->attr.sched_policy == SCHED_OTHER || - curthread->attr.prio == prio) { - curthread->attr.prio = prio; - ret = 0; - } else { - ret = _thr_setscheduler(curthread->tid, - curthread->attr.sched_policy, ¶m); - if (ret == -1) - ret = errno; - else - curthread->attr.prio = prio; - } - THR_UNLOCK(curthread); - } else if ((ret = _thr_ref_add(curthread, pthread, /*include dead*/0)) - == 0) { - THR_THREAD_LOCK(curthread, pthread); - if (pthread->attr.sched_policy == SCHED_OTHER || - pthread->attr.prio == prio) { + } else if ((ret = _thr_find_thread(curthread, pthread, /*include dead*/0))) + return (ret); + if (pthread->attr.sched_policy == SCHED_OTHER || + pthread->attr.prio == prio) { + pthread->attr.prio = prio; + ret = 0; + } else { + ret = _thr_setscheduler(pthread->tid, + pthread->attr.sched_policy, ¶m); + if (ret == -1) + ret = errno; + else pthread->attr.prio = prio; - ret = 0; - } else { - ret = _thr_setscheduler(pthread->tid, - curthread->attr.sched_policy, ¶m); - if (ret == -1) - ret = errno; - else - pthread->attr.prio = prio; - } - THR_THREAD_UNLOCK(curthread, pthread); - _thr_ref_delete(curthread, pthread); } + THR_THREAD_UNLOCK(curthread, pthread); return (ret); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207200316.q6K3Grn9050708>