server: Don't force the process affinity to 1, leave it up to the client.

This commit is contained in:
Alexandre Julliard 2008-01-16 21:02:04 +01:00
parent 9261c63ab3
commit 3bf12b9aca
9 changed files with 27 additions and 28 deletions

View File

@ -146,6 +146,7 @@ NTSTATUS WINAPI NtQueryInformationProcess(
case ProcessBasicInformation:
{
PROCESS_BASIC_INFORMATION pbi;
const unsigned int affinity_mask = (1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
if (ProcessInformationLength >= sizeof(PROCESS_BASIC_INFORMATION))
{
@ -162,7 +163,7 @@ NTSTATUS WINAPI NtQueryInformationProcess(
{
pbi.ExitStatus = reply->exit_code;
pbi.PebBaseAddress = reply->peb;
pbi.AffinityMask = reply->affinity;
pbi.AffinityMask = reply->affinity & affinity_mask;
pbi.BasePriority = reply->priority;
pbi.UniqueProcessId = reply->pid;
pbi.InheritedFromUniqueProcessId = reply->ppid;
@ -359,6 +360,8 @@ NTSTATUS WINAPI NtSetInformationProcess(
{
case ProcessAffinityMask:
if (ProcessInformationLength != sizeof(DWORD_PTR)) return STATUS_INVALID_PARAMETER;
if (*(PDWORD_PTR)ProcessInformation & ~((1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1))
return STATUS_INVALID_PARAMETER;
SERVER_START_REQ( set_process_info )
{
req->handle = ProcessHandle;

View File

@ -1177,6 +1177,7 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
case ThreadBasicInformation:
{
THREAD_BASIC_INFORMATION info;
const unsigned int affinity_mask = (1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
SERVER_START_REQ( get_thread_info )
{
@ -1188,7 +1189,7 @@ NTSTATUS WINAPI NtQueryInformationThread( HANDLE handle, THREADINFOCLASS class,
info.TebBaseAddress = reply->teb;
info.ClientId.UniqueProcess = ULongToHandle(reply->pid);
info.ClientId.UniqueThread = ULongToHandle(reply->tid);
info.AffinityMask = reply->affinity;
info.AffinityMask = reply->affinity & affinity_mask;
info.Priority = reply->priority;
info.BasePriority = reply->priority; /* FIXME */
}
@ -1427,8 +1428,10 @@ NTSTATUS WINAPI NtSetInformationThread( HANDLE handle, THREADINFOCLASS class,
return status;
case ThreadAffinityMask:
{
const DWORD affinity_mask = (1 << NtCurrentTeb()->Peb->NumberOfProcessors) - 1;
const DWORD *paff = data;
if (length != sizeof(DWORD)) return STATUS_INVALID_PARAMETER;
if (*paff & ~affinity_mask) return STATUS_INVALID_PARAMETER;
SERVER_START_REQ( set_thread_info )
{
req->handle = handle;

View File

@ -595,7 +595,7 @@ struct get_process_info_reply
process_id_t ppid;
int exit_code;
int priority;
int affinity;
unsigned int affinity;
void* peb;
timeout_t start_time;
timeout_t end_time;
@ -609,7 +609,7 @@ struct set_process_info_request
obj_handle_t handle;
int mask;
int priority;
int affinity;
unsigned int affinity;
};
struct set_process_info_reply
{
@ -634,7 +634,7 @@ struct get_thread_info_reply
void* teb;
int exit_code;
int priority;
int affinity;
unsigned int affinity;
timeout_t creation_time;
timeout_t exit_time;
int last;
@ -648,7 +648,7 @@ struct set_thread_info_request
obj_handle_t handle;
int mask;
int priority;
int affinity;
unsigned int affinity;
obj_handle_t token;
};
struct set_thread_info_reply
@ -4976,6 +4976,6 @@ union generic_reply
struct add_fd_completion_reply add_fd_completion_reply;
};
#define SERVER_PROTOCOL_VERSION 335
#define SERVER_PROTOCOL_VERSION 336
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */

View File

@ -322,7 +322,7 @@ struct thread *create_process( int fd, struct thread *parent_thread, int inherit
process->exit_code = STILL_ACTIVE;
process->running_threads = 0;
process->priority = PROCESS_PRIOCLASS_NORMAL;
process->affinity = 1;
process->affinity = ~0;
process->suspend = 0;
process->is_system = 0;
process->create_flags = 0;
@ -1098,11 +1098,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)
{
if (req->affinity != 1) set_error( STATUS_INVALID_PARAMETER );
else process->affinity = req->affinity;
}
if (req->mask & SET_PROCESS_INFO_AFFINITY) process->affinity = req->affinity;
release_object( process );
}
}

View File

@ -64,7 +64,7 @@ struct process
timeout_t start_time; /* absolute time at process start */
timeout_t end_time; /* absolute time at process end */
int priority; /* priority class */
int affinity; /* process affinity mask */
unsigned int affinity; /* process affinity mask */
int suspend; /* global process suspend count */
int is_system; /* is it a system process? */
unsigned int create_flags; /* process creation flags */

View File

@ -565,7 +565,7 @@ typedef union
process_id_t ppid; /* server process id of parent */
int exit_code; /* process exit code */
int priority; /* priority class */
int affinity; /* process affinity mask */
unsigned int affinity; /* process affinity mask */
void* peb; /* PEB address in process address space */
timeout_t start_time; /* process start time */
timeout_t end_time; /* process end time */
@ -577,7 +577,7 @@ typedef union
obj_handle_t handle; /* process handle */
int mask; /* setting mask (see below) */
int priority; /* priority class */
int affinity; /* affinity mask */
unsigned int affinity; /* affinity mask */
@END
#define SET_PROCESS_INFO_PRIORITY 0x01
#define SET_PROCESS_INFO_AFFINITY 0x02
@ -593,7 +593,7 @@ typedef union
void* teb; /* thread teb pointer */
int exit_code; /* thread exit code */
int priority; /* thread priority level */
int affinity; /* thread affinity mask */
unsigned int affinity; /* thread affinity mask */
timeout_t creation_time; /* thread creation time */
timeout_t exit_time; /* thread exit time */
int last; /* last thread in process */
@ -605,7 +605,7 @@ typedef union
obj_handle_t handle; /* thread handle */
int mask; /* setting mask (see below) */
int priority; /* priority class */
int affinity; /* affinity mask */
unsigned int affinity; /* affinity mask */
obj_handle_t token; /* impersonation token */
@END
#define SET_THREAD_INFO_PRIORITY 0x01

View File

@ -171,7 +171,7 @@ static inline void init_thread_structure( struct thread *thread )
thread->state = RUNNING;
thread->exit_code = 0;
thread->priority = 0;
thread->affinity = 1;
thread->affinity = ~0;
thread->suspend = 0;
thread->desktop_users = 0;
thread->token = NULL;
@ -413,10 +413,7 @@ static void set_thread_info( struct thread *thread,
set_error( STATUS_INVALID_PARAMETER );
}
if (req->mask & SET_THREAD_INFO_AFFINITY)
{
if (req->affinity != 1) set_error( STATUS_INVALID_PARAMETER );
else thread->affinity = req->affinity;
}
thread->affinity = req->affinity;
if (req->mask & SET_THREAD_INFO_TOKEN)
security_set_thread_token( thread, req->token );
}

View File

@ -80,7 +80,7 @@ struct thread
CONTEXT *suspend_context; /* current context if suspended */
void *teb; /* TEB address (in client address space) */
int priority; /* priority level */
int affinity; /* affinity mask */
unsigned int affinity; /* affinity mask */
int suspend; /* suspend count */
obj_handle_t desktop; /* desktop handle */
int desktop_users; /* number of objects using the thread desktop */

View File

@ -957,7 +957,7 @@ static void dump_get_process_info_reply( const struct get_process_info_reply *re
fprintf( stderr, " ppid=%04x,", req->ppid );
fprintf( stderr, " exit_code=%d,", req->exit_code );
fprintf( stderr, " priority=%d,", req->priority );
fprintf( stderr, " affinity=%d,", req->affinity );
fprintf( stderr, " affinity=%08x,", req->affinity );
fprintf( stderr, " peb=%p,", req->peb );
fprintf( stderr, " start_time=" );
dump_timeout( &req->start_time );
@ -971,7 +971,7 @@ static void dump_set_process_info_request( const struct set_process_info_request
fprintf( stderr, " handle=%p,", req->handle );
fprintf( stderr, " mask=%d,", req->mask );
fprintf( stderr, " priority=%d,", req->priority );
fprintf( stderr, " affinity=%d", req->affinity );
fprintf( stderr, " affinity=%08x", req->affinity );
}
static void dump_get_thread_info_request( const struct get_thread_info_request *req )
@ -987,7 +987,7 @@ static void dump_get_thread_info_reply( const struct get_thread_info_reply *req
fprintf( stderr, " teb=%p,", req->teb );
fprintf( stderr, " exit_code=%d,", req->exit_code );
fprintf( stderr, " priority=%d,", req->priority );
fprintf( stderr, " affinity=%d,", req->affinity );
fprintf( stderr, " affinity=%08x,", req->affinity );
fprintf( stderr, " creation_time=" );
dump_timeout( &req->creation_time );
fprintf( stderr, "," );
@ -1002,7 +1002,7 @@ static void dump_set_thread_info_request( const struct set_thread_info_request *
fprintf( stderr, " handle=%p,", req->handle );
fprintf( stderr, " mask=%d,", req->mask );
fprintf( stderr, " priority=%d,", req->priority );
fprintf( stderr, " affinity=%d,", req->affinity );
fprintf( stderr, " affinity=%08x,", req->affinity );
fprintf( stderr, " token=%p", req->token );
}