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

This commit is contained in:
Juan Lang 2009-09-30 13:49:12 -07:00 committed by Alexandre Julliard
parent 6614323807
commit bfb4578356
2 changed files with 10 additions and 0 deletions

View File

@ -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) );

View File

@ -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)
{