Matt Jones : server:
Only commit SetThreadPriority if new priority is correct.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed Jul 25 07:44:23 CDT 2007
Module: wine
Branch: master
Commit: 6763742090f10d953f12d2e4a866f653f89ba529
URL: http://source.winehq.org/git/wine.git/?a=commit;h=6763742090f10d953f12d2e4a866f653f89ba529
Author: Matt Jones <mattj at google.com>
Date: Tue Jul 24 13:23:56 2007 -0700
server: Only commit SetThreadPriority if new priority is correct.
---
dlls/kernel32/tests/thread.c | 24 ++++++++++--------------
server/thread.c | 19 ++++++++++++++++++-
2 files changed, 28 insertions(+), 15 deletions(-)
diff --git a/dlls/kernel32/tests/thread.c b/dlls/kernel32/tests/thread.c
index 9ba9242..38692d4 100644
--- a/dlls/kernel32/tests/thread.c
+++ b/dlls/kernel32/tests/thread.c
@@ -594,25 +594,21 @@ static VOID test_thread_priority(void)
SetLastError(0xdeadbeef);
rc = SetThreadPriority(curthread,min_priority-1);
- todo_wine {
- ok(rc == FALSE, "SetThreadPriority passed with a bad argument\n");
- ok(GetLastError() == ERROR_INVALID_PARAMETER,
- "SetThreadPriority error %d, expected ERROR_INVALID_PARAMETER (87)\n", GetLastError());
- ok(GetThreadPriority(curthread)==min_priority,
- "GetThreadPriority didn't return min_priority\n");
- }
+ ok(rc == FALSE, "SetThreadPriority passed with a bad argument\n");
+ ok(GetLastError() == ERROR_INVALID_PARAMETER,
+ "SetThreadPriority error %d, expected ERROR_INVALID_PARAMETER (87)\n", GetLastError());
+ ok(GetThreadPriority(curthread)==min_priority,
+ "GetThreadPriority didn't return min_priority\n");
SetThreadPriority(curthread,max_priority);
SetLastError(0xdeadbeef);
rc = SetThreadPriority(curthread,max_priority+1);
- todo_wine {
- ok(rc == FALSE, "SetThreadPriority passed with a bad argument\n");
- ok(GetLastError() == ERROR_INVALID_PARAMETER,
- "SetThreadPriority error %d, expected ERROR_INVALID_PARAMETER (87)\n", GetLastError());
- ok(GetThreadPriority(curthread)==max_priority,
- "GetThreadPriority didn't return max_priority\n");
- }
+ ok(rc == FALSE, "SetThreadPriority passed with a bad argument\n");
+ ok(GetLastError() == ERROR_INVALID_PARAMETER,
+ "SetThreadPriority error %d, expected ERROR_INVALID_PARAMETER (87)\n", GetLastError());
+ ok(GetThreadPriority(curthread)==max_priority,
+ "GetThreadPriority didn't return max_priority\n");
/* Check thread priority boost */
if (!pGetThreadPriorityBoost || !pSetThreadPriorityBoost)
diff --git a/server/thread.c b/server/thread.c
index 62d50b5..2ae78c9 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -383,12 +383,29 @@ struct thread *get_thread_from_pid( int pid )
return NULL;
}
+#define THREAD_PRIORITY_REALTIME_HIGHEST 6
+#define THREAD_PRIORITY_REALTIME_LOWEST -7
+
/* set all information about a thread */
static void set_thread_info( struct thread *thread,
const struct set_thread_info_request *req )
{
if (req->mask & SET_THREAD_INFO_PRIORITY)
- thread->priority = req->priority;
+ {
+ int max = THREAD_PRIORITY_HIGHEST;
+ int min = THREAD_PRIORITY_LOWEST;
+ if (thread->process->priority == PROCESS_PRIOCLASS_REALTIME)
+ {
+ max = THREAD_PRIORITY_REALTIME_HIGHEST;
+ min = THREAD_PRIORITY_REALTIME_LOWEST;
+ }
+ if ((req->priority >= min && req->priority <= max) ||
+ req->priority == THREAD_PRIORITY_IDLE ||
+ req->priority == THREAD_PRIORITY_TIME_CRITICAL)
+ thread->priority = req->priority;
+ else
+ set_error( STATUS_INVALID_PARAMETER );
+ }
if (req->mask & SET_THREAD_INFO_AFFINITY)
{
if (req->affinity != 1) set_error( STATUS_INVALID_PARAMETER );
More information about the wine-cvs
mailing list