Commit 24036fe1 authored by Juan Lang's avatar Juan Lang Committed by Alexandre Julliard

server: Setting a process's affinity sets all of its threads' affinities too.

parent ceb8577b
......@@ -946,7 +946,6 @@ static void test_affinity(void)
/* Setting the process affinity changes the thread affinity to match */
status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
todo_wine
ok( tbi.AffinityMask == 2, "Unexpected thread affinity\n" );
proc_affinity = (1 << si.dwNumberOfProcessors) - 1;
......@@ -955,7 +954,6 @@ static void test_affinity(void)
/* Resetting the process affinity also resets the thread affinity */
status = pNtQueryInformationThread( GetCurrentThread(), ThreadBasicInformation, &tbi, sizeof(tbi), NULL );
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
todo_wine
ok( tbi.AffinityMask == (1 << si.dwNumberOfProcessors) - 1,
"Unexpected thread affinity" );
}
......
......@@ -1095,6 +1095,18 @@ DECL_HANDLER(get_process_info)
}
}
static void set_process_affinity( struct process *process, affinity_t affinity )
{
struct thread *thread;
process->affinity = affinity;
LIST_FOR_EACH_ENTRY( thread, &process->thread_list, struct thread, proc_entry )
{
set_thread_affinity( thread, affinity );
}
}
/* set information about a process */
DECL_HANDLER(set_process_info)
{
......@@ -1103,7 +1115,7 @@ DECL_HANDLER(set_process_info)
if ((process = get_process_from_handle( req->handle, PROCESS_SET_INFORMATION )))
{
if (req->mask & SET_PROCESS_INFO_PRIORITY) process->priority = req->priority;
if (req->mask & SET_PROCESS_INFO_AFFINITY) process->affinity = req->affinity;
if (req->mask & SET_PROCESS_INFO_AFFINITY) set_process_affinity( process, req->affinity );
release_object( process );
}
}
......
......@@ -404,6 +404,11 @@ struct thread *get_thread_from_pid( int pid )
return NULL;
}
void set_thread_affinity( struct thread *thread, affinity_t affinity )
{
thread->affinity = affinity;
}
#define THREAD_PRIORITY_REALTIME_HIGHEST 6
#define THREAD_PRIORITY_REALTIME_LOWEST -7
......@@ -428,7 +433,7 @@ static void set_thread_info( struct thread *thread,
set_error( STATUS_INVALID_PARAMETER );
}
if (req->mask & SET_THREAD_INFO_AFFINITY)
thread->affinity = req->affinity;
set_thread_affinity( thread, req->affinity );
if (req->mask & SET_THREAD_INFO_TOKEN)
security_set_thread_token( thread, req->token );
}
......
......@@ -118,6 +118,7 @@ extern int thread_add_inflight_fd( struct thread *thread, int client, int server
extern int thread_get_inflight_fd( struct thread *thread, int client );
extern struct thread_snapshot *thread_snap( int *count );
extern struct token *thread_get_impersonation_token( struct thread *thread );
extern void set_thread_affinity( struct thread *thread, affinity_t affinity );
/* ptrace functions */
......
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