summaryrefslogtreecommitdiffstats
path: root/lib/libthr
diff options
context:
space:
mode:
authordavidxu <davidxu@FreeBSD.org>2012-07-20 03:16:52 +0000
committerdavidxu <davidxu@FreeBSD.org>2012-07-20 03:16:52 +0000
commit8673cbd4778dbd00c4a37ca2bd00b67ae369311f (patch)
tree7337d9bf21fc5e1869a51db59d6e2625885721f5 /lib/libthr
parent4bd927cee6b011b243c700ac09bba0bf5bd832db (diff)
downloadFreeBSD-src-8673cbd4778dbd00c4a37ca2bd00b67ae369311f.zip
FreeBSD-src-8673cbd4778dbd00c4a37ca2bd00b67ae369311f.tar.gz
Eliminate duplicated code.
Diffstat (limited to 'lib/libthr')
-rw-r--r--lib/libthr/thread/thr_setprio.c43
1 files changed, 14 insertions, 29 deletions
diff --git a/lib/libthr/thread/thr_setprio.c b/lib/libthr/thread/thr_setprio.c
index b1b2352..b87d536 100644
--- a/lib/libthr/thread/thr_setprio.c
+++ b/lib/libthr/thread/thr_setprio.c
@@ -46,37 +46,22 @@ _pthread_setprio(pthread_t pthread, int prio)
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, &param);
- 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, &param);
+ if (ret == -1)
+ ret = errno;
+ else
pthread->attr.prio = prio;
- ret = 0;
- } else {
- ret = _thr_setscheduler(pthread->tid,
- curthread->attr.sched_policy, &param);
- 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);
}
OpenPOWER on IntegriCloud