Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 20 Jul 2012 03:00:41 +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: r238640 - head/lib/libthr/thread
Message-ID:  <201207200300.q6K30f7c049028@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: davidxu
Date: Fri Jul 20 03:00:41 2012
New Revision: 238640
URL: http://svn.freebsd.org/changeset/base/238640

Log:
  Eliminate duplicated code.

Modified:
  head/lib/libthr/thread/thr_setschedparam.c

Modified: head/lib/libthr/thread/thr_setschedparam.c
==============================================================================
--- head/lib/libthr/thread/thr_setschedparam.c	Fri Jul 20 02:18:47 2012	(r238639)
+++ head/lib/libthr/thread/thr_setschedparam.c	Fri Jul 20 03:00:41 2012	(r238640)
@@ -54,39 +54,25 @@ _pthread_setschedparam(pthread_t pthread
 	int	ret;
 
 	if (pthread == curthread) {
+		pthread = curthread;
 		THR_LOCK(curthread);
-		if (curthread->attr.sched_policy == policy &&
-		    (policy == SCHED_OTHER ||
-		     curthread->attr.prio == param->sched_priority)) {
-			pthread->attr.prio = param->sched_priority;
-			THR_UNLOCK(curthread);
-			return (0);
-		}
-		ret = _thr_setscheduler(curthread->tid, policy, param);
-		if (ret == -1)
-			ret = errno;
-		else {
-			curthread->attr.sched_policy = policy;
-			curthread->attr.prio = param->sched_priority;
-		}
-		THR_UNLOCK(curthread);
 	} else if ((ret = _thr_find_thread(curthread, pthread,
-		 /*include dead*/0)) == 0) {
-		if (pthread->attr.sched_policy == policy &&
-		    (policy == SCHED_OTHER ||
-		     pthread->attr.prio == param->sched_priority)) {
-			pthread->attr.prio = param->sched_priority;
-			THR_THREAD_UNLOCK(curthread, pthread);
-			return (0);
-		}
-		ret = _thr_setscheduler(pthread->tid, policy, param);
-		if (ret == -1)
-			ret = errno;
-		else {
-			pthread->attr.sched_policy = policy;
-			pthread->attr.prio = param->sched_priority;
-		}
+		 /*include dead*/0)) != 0)
+		return (ret);
+	if (pthread->attr.sched_policy == policy &&
+	    (policy == SCHED_OTHER ||
+	     pthread->attr.prio == param->sched_priority)) {
+		pthread->attr.prio = param->sched_priority;
 		THR_THREAD_UNLOCK(curthread, pthread);
+		return (0);
 	}
+	ret = _thr_setscheduler(pthread->tid, policy, param);
+	if (ret == -1)
+		ret = errno;
+	else {
+		pthread->attr.sched_policy = policy;
+		pthread->attr.prio = param->sched_priority;
+	}
+	THR_THREAD_UNLOCK(curthread, pthread);
 	return (ret);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201207200300.q6K30f7c049028>