From bfb4578356b33b9c3d43b813fe5fae142783ab05 Mon Sep 17 00:00:00 2001 From: Juan Lang Date: Wed, 30 Sep 2009 13:49:12 -0700 Subject: [PATCH] server: A thread's affinity is restricted to the process affinity. --- dlls/ntdll/tests/info.c | 5 +++++ server/thread.c | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index cc255134339..55b449825c1 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -947,6 +947,11 @@ static void test_affinity(void) status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL ); ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status); ok( tbi.AffinityMask == 2, "Unexpected thread affinity\n" ); + /* The thread affinity is restricted to the process affinity */ + thread_affinity = 1; + status = pNtSetInformationThread( GetCurrentThread(), ThreadAffinityMask, &thread_affinity, sizeof(thread_affinity) ); + ok( status == STATUS_INVALID_PARAMETER, + "Expected STATUS_INVALID_PARAMETER, got %08x\n", status); proc_affinity = (1 << si.dwNumberOfProcessors) - 1; status = pNtSetInformationProcess( GetCurrentProcess(), ProcessAffinityMask, &proc_affinity, sizeof(proc_affinity) ); diff --git a/server/thread.c b/server/thread.c index 211cefecc1c..f45be2436b1 100644 --- a/server/thread.c +++ b/server/thread.c @@ -409,6 +409,11 @@ struct thread *get_thread_from_pid( int pid ) void set_thread_affinity( struct thread *thread, affinity_t affinity ) { + if ((affinity & thread->process->affinity) != affinity) + { + set_error( STATUS_INVALID_PARAMETER ); + return; + } #ifdef HAVE_SCHED_SETAFFINITY if (thread->unix_pid != -1) { -- 2.11.4.GIT