server: Only commit SetThreadPriority if new priority is correct
(try 5)
Matt Jones
mattj at google.com
Tue Jul 24 14:50:59 CDT 2007
Updated to reflect changed kernel32 patch
-------------- next part --------------
From 662bff8af94b8a509b9f154f0d2945715f84db7b Mon Sep 17 00:00:00 2001
From: Matt Jones <mattj at google.com>
Date: Tue, 24 Jul 2007 12:43:30 -0700
Subject: [PATCH] server: Only set the thread priority if the new priority is valid
Set the correct error if the new priority is invalid
Remove todo_wine from test cases this fixes
---
dlls/kernel32/tests/thread.c | 20 ++++++++------------
server/thread.c | 21 ++++++++++++++++++++-
2 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/dlls/kernel32/tests/thread.c b/dlls/kernel32/tests/thread.c
index b49c9bb..fee396d 100644
--- a/dlls/kernel32/tests/thread.c
+++ b/dlls/kernel32/tests/thread.c
@@ -596,12 +596,10 @@ #endif
if (!result) exitCode = GetLastError();
else exitCode = ERROR_SUCCESS;
- todo_wine {
- ok(exitCode == ERROR_INVALID_PARAMETER,
- "SetThreadPriority error %d, expected ERROR_INVALID_PARAMETER (87)\n", exitCode);
- ok(GetThreadPriority(curthread)==min_priority,
- "GetThreadPriority didn't return min_priority\n");
- }
+ ok(exitCode == ERROR_INVALID_PARAMETER,
+ "SetThreadPriority error %d, expected ERROR_INVALID_PARAMETER (87)\n", exitCode);
+ ok(GetThreadPriority(curthread)==min_priority,
+ "GetThreadPriority didn't return min_priority\n");
SetThreadPriority(curthread,max_priority);
result = SetThreadPriority(curthread,max_priority+1);
@@ -609,12 +607,10 @@ #endif
if (!result) exitCode = GetLastError();
else exitCode = ERROR_SUCCESS;
- todo_wine {
- ok(exitCode == ERROR_INVALID_PARAMETER,
- "SetThreadPriority error %d, expected ERROR_INVALID_PARAMETER (87)\n", exitCode);
- ok(GetThreadPriority(curthread)==max_priority,
- "GetThreadPriority didn't return max_priority\n");
- }
+ ok(exitCode == ERROR_INVALID_PARAMETER,
+ "SetThreadPriority error %d, expected ERROR_INVALID_PARAMETER (87)\n", exitCode);
+ ok(GetThreadPriority(curthread)==max_priority,
+ "GetThreadPriority didn't return max_priority\n");
/* Check thread priority boost */
diff --git a/server/thread.c b/server/thread.c
index 62d50b5..b798ec5 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -383,12 +383,31 @@ struct thread *get_thread_from_pid( int
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 == THREAD_PRIORITY_IDLE) &&
+ (req->priority <= max ||
+ 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 );
--
1.4.1
More information about the wine-patches
mailing list