svn commit: r238641 - head/lib/libthr/thread
David Xu
davidxu at FreeBSD.org
Fri Jul 20 03:16:53 UTC 2012
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);
}
More information about the svn-src-head
mailing list