server: Only commit SetThreadPriority if new priority is correct

Matt Jones mattj at google.com
Tue Jul 17 15:54:37 CDT 2007


Fixes compliance with the test I just sent in.
-------------- next part --------------
From dc87864c16c41506685741223e0efdada756ae84 Mon Sep 17 00:00:00 2001
From: Matt Jones <mattj at nuance.corp.google.com>
Date: Tue, 17 Jul 2007 13:41:24 -0700
Subject: [PATCH] Server: Conform to SetThreadPriority check (only set priority if the new priority is valid)
---
 server/thread.c |   16 +++++++++++++++-
 1 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/server/thread.c b/server/thread.c
index 62d50b5..9f7bf67 100644
--- a/server/thread.c
+++ b/server/thread.c
@@ -388,7 +388,21 @@ static void set_thread_info( struct thre
                              const struct set_thread_info_request *req )
 {
     if (req->mask & SET_THREAD_INFO_PRIORITY)
-        thread->priority = req->priority;
+    {
+        DWORD max = THREAD_PRIORITY_HIGHEST;
+        DWORD min = THREAD_PRIORITY_LOWEST;
+        if (thread->process->priority == PROCESS_PRIOCLASS_REALTIME)
+        {
+            max = 6;
+            min = -7;
+        }
+
+        if ((req->priority >= min ||
+             req->priority == THREAD_PRIORITY_IDLE) ||
+            (req->priority <= max ||
+             req->priority == THREAD_PRIORITY_TIME_CRITICAL))
+            thread->priority = req->priority;
+    }
     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