Handle suspend/resume_thread requests in phase STARTING correctly.

Set initial suspend count for threads created with CREATE_SUSPENDED.
Set 'inheritable' flag for process/thread handles.
This commit is contained in:
Ulrich Weigand 1999-03-16 16:28:36 +00:00 committed by Alexandre Julliard
parent 3480e4a596
commit 2f2898b571
6 changed files with 31 additions and 12 deletions

View File

@ -44,6 +44,9 @@ struct cmsg_fd
struct new_thread_request
{
void* pid; /* process id for the new thread (or 0 if none yet) */
int suspend; /* new thread should be suspended on creation */
int tinherit; /* inherit flag for thread handle */
int pinherit; /* inherit flag for process handle */
};
struct new_thread_reply
{
@ -656,7 +659,9 @@ extern unsigned int CLIENT_WaitReply( int *len, int *passed_fd,
extern unsigned int CLIENT_WaitSimpleReply( void *reply, int len, int *passed_fd );
struct _THDB;
extern int CLIENT_NewThread( struct _THDB *thdb, int *thandle, int *phandle );
extern int CLIENT_NewThread( struct _THDB *thdb,
LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
int *thandle, int *phandle );
extern int CLIENT_SetDebug( int level );
extern int CLIENT_InitThread(void);
#endif /* __WINE_SERVER__ */

View File

@ -50,8 +50,9 @@ extern struct thread *current;
/* thread functions */
extern struct thread *create_thread( int fd, void *pid, int *thread_handle,
int *process_handle );
extern struct thread *create_thread( int fd, void *pid, int suspend,
int thread_inherit, int process_inherit,
int *thread_handle, int *process_handle );
extern struct thread *get_thread_from_id( void *id );
extern struct thread *get_thread_from_handle( int handle, unsigned int access );
extern void get_thread_info( struct thread *thread,

View File

@ -276,7 +276,9 @@ unsigned int CLIENT_WaitSimpleReply( void *reply, int len, int *passed_fd )
*
* Send a new thread request.
*/
int CLIENT_NewThread( THDB *thdb, int *thandle, int *phandle )
int CLIENT_NewThread( THDB *thdb,
LPSECURITY_ATTRIBUTES psa, LPSECURITY_ATTRIBUTES tsa,
int *thandle, int *phandle )
{
struct new_thread_request request;
struct new_thread_reply reply;
@ -289,6 +291,9 @@ int CLIENT_NewThread( THDB *thdb, int *thandle, int *phandle )
}
request.pid = thdb->process->server_pid;
request.suspend = (thdb->flags & CREATE_SUSPENDED)? TRUE : FALSE;
request.tinherit = (tsa && (tsa->nLength>=sizeof(*tsa)) && tsa->bInheritHandle);
request.pinherit = (psa && (psa->nLength>=sizeof(*psa)) && psa->bInheritHandle);
CLIENT_SendRequest( REQ_NEW_THREAD, fd[1], 1, &request, sizeof(request) );
if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) goto error;
thdb->server_tid = reply.tid;

View File

@ -9,6 +9,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <unistd.h>
@ -113,8 +114,9 @@ DECL_HANDLER(new_thread)
err = ERROR_TOO_MANY_OPEN_FILES;
goto done;
}
if (!(new_thread = create_thread( new_fd, req->pid, &reply.thandle,
&reply.phandle )))
if (!(new_thread = create_thread( new_fd, req->pid, req->suspend,
req->tinherit, req->pinherit,
&reply.thandle, &reply.phandle )))
{
close( new_fd );
err = ERROR_OUTOFMEMORY;
@ -153,6 +155,8 @@ DECL_HANDLER(init_thread)
current->name[len] = '\0';
CLEAR_ERROR();
done:
if (current->suspend > 0 && current->unix_pid)
kill( current->unix_pid, SIGSTOP );
send_reply( current, -1, 0 );
}

View File

@ -75,8 +75,9 @@ static struct thread *first_thread;
/* create a new thread */
struct thread *create_thread( int fd, void *pid, int *thread_handle,
int *process_handle )
struct thread *create_thread( int fd, void *pid, int suspend,
int thread_inherit, int process_inherit,
int *thread_handle, int *process_handle )
{
struct thread *thread;
struct process *process;
@ -107,7 +108,7 @@ struct thread *create_thread( int fd, void *pid, int *thread_handle,
thread->prev = NULL;
thread->priority = THREAD_PRIORITY_NORMAL;
thread->affinity = 1;
thread->suspend = 0;
thread->suspend = suspend? 1 : 0;
if (first_thread) first_thread->prev = thread;
first_thread = thread;
@ -117,13 +118,13 @@ struct thread *create_thread( int fd, void *pid, int *thread_handle,
if (current)
{
if ((*thread_handle = alloc_handle( current->process, thread,
THREAD_ALL_ACCESS, 0 )) == -1)
THREAD_ALL_ACCESS, thread_inherit )) == -1)
goto error;
}
if (current && !pid)
{
if ((*process_handle = alloc_handle( current->process, process,
PROCESS_ALL_ACCESS, 0 )) == -1)
PROCESS_ALL_ACCESS, process_inherit )) == -1)
goto error;
}

View File

@ -8,7 +8,10 @@
static int dump_new_thread_request( struct new_thread_request *req, int len )
{
fprintf( stderr, " pid=%p", req->pid );
fprintf( stderr, " pid=%p,", req->pid );
fprintf( stderr, " suspend=%d,", req->suspend );
fprintf( stderr, " tinherit=%d,", req->tinherit );
fprintf( stderr, " pinherit=%d", req->pinherit );
return (int)sizeof(*req);
}