Module: wine Branch: master Commit: bfb4578356b33b9c3d43b813fe5fae142783ab05 URL: http://source.winehq.org/git/wine.git/?a=commit;h=bfb4578356b33b9c3d43b813fe...
Author: Juan Lang juan.lang@gmail.com Date: Wed Sep 30 13:49:12 2009 -0700
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(+), 0 deletions(-)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index cc25513..55b4498 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 211cefe..f45be24 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) {