Added server pid and tid in init_thread request, and use them in

CLIENT_InitThread.
This commit is contained in:
Alexandre Julliard 1999-03-23 14:09:41 +00:00
parent ed494ec539
commit 875c4b3c61
7 changed files with 31 additions and 14 deletions

View File

@ -97,6 +97,11 @@ struct init_thread_request
{
int unix_pid; /* Unix pid of new thread */
};
struct init_thread_reply
{
void* pid; /* process id of the new thread's process */
void* tid; /* thread id of the new thread */
};
/* Terminate a process */

View File

@ -318,10 +318,16 @@ int CLIENT_InitServer(void)
*/
int CLIENT_InitThread(void)
{
struct init_thread_request init;
init.unix_pid = getpid();
CLIENT_SendRequest( REQ_INIT_THREAD, -1, 1, &init, sizeof(init) );
return CLIENT_WaitReply( NULL, NULL, 0 );
THDB *thdb = THREAD_Current();
struct init_thread_request req;
struct init_thread_reply reply;
req.unix_pid = getpid();
CLIENT_SendRequest( REQ_INIT_THREAD, -1, 1, &req, sizeof(req) );
if (CLIENT_WaitSimpleReply( &reply, sizeof(reply), NULL )) return -1;
thdb->process->server_pid = reply.pid;
thdb->server_tid = reply.tid;
return 0;
}

View File

@ -306,9 +306,6 @@ BOOL PROCESS_Init(void)
/* Create the environment DB of the first process */
if (!PROCESS_BuildEnvDB( &initial_pdb )) return FALSE;
/* Initialize the first thread */
if (CLIENT_InitThread()) return FALSE;
/* Create the SEGPTR heap */
if (!(SegptrHeap = HeapCreate( HEAP_WINE_SEGPTR, 0, 0 ))) return FALSE;

View File

@ -80,12 +80,8 @@ int *__h_errno_location()
*/
static void SYSDEPS_StartThread( THDB *thdb )
{
struct init_thread_request init;
SET_CUR_THREAD( thdb );
init.unix_pid = getpid();
CLIENT_SendRequest( REQ_INIT_THREAD, -1, 1, &init, sizeof(init) );
CLIENT_WaitReply( NULL, NULL, 0 );
CLIENT_InitThread();
thdb->startup();
_exit(0); /* should never get here */
}

View File

@ -201,6 +201,7 @@ THDB *THREAD_CreateInitialThread( PDB *pdb, int server_fd )
/* Now proceed with normal initialization */
if (CLIENT_InitThread()) return NULL;
if (!THREAD_InitTHDB( &initial_thdb, 0, TRUE, NULL )) return NULL;
return &initial_thdb;
}
@ -344,6 +345,7 @@ DWORD WINAPI GetCurrentThreadId(void)
{
THDB *thdb = THREAD_Current();
assert( thdb );
assert( thdb->server_tid );
return (DWORD)thdb->server_tid;
}

View File

@ -160,6 +160,8 @@ DECL_HANDLER(init_process)
/* initialize a new thread */
DECL_HANDLER(init_thread)
{
struct init_thread_reply reply;
if (current->state != STARTING)
{
fatal_protocol_error( "init_thread: already running\n" );
@ -169,7 +171,9 @@ DECL_HANDLER(init_thread)
current->unix_pid = req->unix_pid;
if (current->suspend > 0)
kill( current->unix_pid, SIGSTOP );
send_reply( current, -1, 0 );
reply.pid = current->process;
reply.tid = current;
send_reply( current, -1, 1, &reply, sizeof(reply) );
}
/* set the debug level */

View File

@ -66,6 +66,13 @@ static int dump_init_thread_request( struct init_thread_request *req, int len )
return (int)sizeof(*req);
}
static int dump_init_thread_reply( struct init_thread_reply *req, int len )
{
fprintf( stderr, " pid=%p,", req->pid );
fprintf( stderr, " tid=%p", req->tid );
return (int)sizeof(*req);
}
static int dump_terminate_process_request( struct terminate_process_request *req, int len )
{
fprintf( stderr, " handle=%d,", req->handle );
@ -638,7 +645,7 @@ static const struct dumper dumpers[REQ_NB_REQUESTS] =
{ (int(*)(void *,int))dump_init_process_request,
(void(*)())dump_init_process_reply },
{ (int(*)(void *,int))dump_init_thread_request,
(void(*)())0 },
(void(*)())dump_init_thread_reply },
{ (int(*)(void *,int))dump_terminate_process_request,
(void(*)())0 },
{ (int(*)(void *,int))dump_terminate_thread_request,