Commit bfb45783 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

server: A thread's affinity is restricted to the process affinity.

parent 66143238
......@@ -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) );
......
......@@ -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)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment