Commit 6a72dc52 authored by Alexandre Julliard's avatar Alexandre Julliard

Load done event now created by the server.

parent e5efa0ce
......@@ -113,13 +113,13 @@ struct new_process_request
IN int hstdin; /* handle for stdin */
IN int hstdout; /* handle for stdout */
IN int hstderr; /* handle for stderr */
IN int event; /* event to signal startup */
IN int cmd_show; /* main window show mode */
IN void* env_ptr; /* pointer to environment (FIXME: hack) */
OUT void* pid; /* process id */
OUT int phandle; /* process handle (in the current process) */
OUT void* tid; /* thread id */
OUT int thandle; /* thread handle (in the current process) */
OUT int event; /* event handle to signal startup */
IN char cmdline[1]; /* command line */
};
......@@ -1209,7 +1209,7 @@ enum request
REQ_NB_REQUESTS
};
#define SERVER_PROTOCOL_VERSION 6
#define SERVER_PROTOCOL_VERSION 7
/* ### make_requests end ### */
/* Everything above this line is generated automatically by tools/make_requests */
......
......@@ -490,7 +490,7 @@ PDB *PROCESS_Create( NE_MODULE *pModule, HFILE hFile, LPCSTR cmd_line, LPCSTR en
BOOL inherit, DWORD flags, STARTUPINFOA *startup,
PROCESS_INFORMATION *info )
{
HANDLE handles[2], load_done_evt = 0;
HANDLE handles[2], load_done_evt = -1;
DWORD exitcode, size;
BOOL alloc_stack16;
int fd = -1;
......@@ -501,7 +501,6 @@ PDB *PROCESS_Create( NE_MODULE *pModule, HFILE hFile, LPCSTR cmd_line, LPCSTR en
if (!pdb) return NULL;
info->hThread = info->hProcess = INVALID_HANDLE_VALUE;
if (!(load_done_evt = CreateEventA( NULL, TRUE, FALSE, NULL ))) goto error;
/* Create the process on the server side */
......@@ -511,7 +510,6 @@ PDB *PROCESS_Create( NE_MODULE *pModule, HFILE hFile, LPCSTR cmd_line, LPCSTR en
req->create_flags = flags;
req->start_flags = startup->dwFlags;
req->exe_file = hFile;
req->event = load_done_evt;
if (startup->dwFlags & STARTF_USESTDHANDLES)
{
req->hstdin = startup->hStdInput;
......@@ -533,6 +531,7 @@ PDB *PROCESS_Create( NE_MODULE *pModule, HFILE hFile, LPCSTR cmd_line, LPCSTR en
info->dwProcessId = (DWORD)req->pid;
info->hThread = req->thandle;
info->dwThreadId = (DWORD)req->tid;
load_done_evt = req->event;
if (pModule->module32) /* Win32 process */
{
......@@ -596,12 +595,10 @@ PDB *PROCESS_Create( NE_MODULE *pModule, HFILE hFile, LPCSTR cmd_line, LPCSTR en
}
CloseHandle( load_done_evt );
load_done_evt = 0;
return pdb;
error:
if (load_done_evt) CloseHandle( load_done_evt );
if (load_done_evt != -1) CloseHandle( load_done_evt );
if (info->hThread != INVALID_HANDLE_VALUE) CloseHandle( info->hThread );
if (info->hProcess != INVALID_HANDLE_VALUE) CloseHandle( info->hProcess );
PROCESS_FreePDB( pdb );
......
......@@ -43,7 +43,7 @@ static const struct object_ops event_ops =
};
static struct event *create_event( const WCHAR *name, size_t len,
struct event *create_event( const WCHAR *name, size_t len,
int manual_reset, int initial_state )
{
struct event *event;
......
......@@ -127,6 +127,8 @@ static inline int time_before( struct timeval *t1, struct timeval *t2 )
struct event;
extern struct event *create_event( const WCHAR *name, size_t len,
int manual_reset, int initial_state );
extern struct event *get_event_obj( struct process *process, int handle, unsigned int access );
extern void pulse_event( struct event *event );
extern void set_event( struct event *event );
......
......@@ -77,7 +77,6 @@ static int set_creation_info( struct process *process, struct new_process_reques
req->hstdin = -1;
req->hstdout = -1;
req->hstderr = -1;
req->event = -1;
req->cmd_show = 0;
req->env_ptr = NULL;
}
......@@ -185,26 +184,23 @@ struct thread *create_process( int fd, struct process *parent,
process->info->exe_file = -1;
}
/* get the init done event */
if (process->info->event != -1)
{
if (!(process->init_event = get_event_obj( parent, process->info->event,
EVENT_MODIFY_STATE ))) goto error;
}
/* set the process console */
if (!set_process_console( process, parent )) goto error;
/* create the main thread */
if (!(thread = create_thread( fd, process, (process->create_flags & CREATE_SUSPENDED) != 0)))
goto error;
/* create the init done event */
if (!(process->init_event = create_event( NULL, 0, 1, 0 ))) goto error;
/* set the process console */
if (!set_process_console( process, parent )) goto error;
/* attach to the debugger if requested */
if (process->create_flags & (DEBUG_PROCESS | DEBUG_ONLY_THIS_PROCESS))
set_process_debugger( process, current );
else if (parent && parent->debugger && !(parent->create_flags & DEBUG_ONLY_THIS_PROCESS))
set_process_debugger( process, parent->debugger );
add_process_thread( process, thread );
release_object( process );
return thread;
......@@ -212,6 +208,7 @@ struct thread *create_process( int fd, struct process *parent,
close( fd );
free_console( process );
if (process->handles) release_object( process->handles );
if (thread) release_object( thread );
release_object( process );
return NULL;
}
......@@ -580,9 +577,11 @@ DECL_HANDLER(new_process)
size_t len = get_req_strlen( req, req->cmdline );
struct thread *thread;
int sock[2];
int event = -1, phandle = -1;
req->phandle = -1;
req->thandle = -1;
req->event = -1;
req->pid = NULL;
req->tid = NULL;
......@@ -592,25 +591,33 @@ DECL_HANDLER(new_process)
return;
}
if ((thread = create_process( sock[0], current->process, req, req->cmdline, len )))
{
int phandle = alloc_handle( current->process, thread->process,
PROCESS_ALL_ACCESS, req->pinherit );
if ((req->phandle = phandle) != -1)
{
if (!(thread = create_process( sock[0], current->process, req, req->cmdline, len )))
goto error;
if ((event = alloc_handle( current->process, thread->process->init_event,
EVENT_ALL_ACCESS, 0 )) == -1)
goto error;
if ((phandle = alloc_handle( current->process, thread->process,
PROCESS_ALL_ACCESS, req->pinherit )) == -1)
goto error;
if ((req->thandle = alloc_handle( current->process, thread,
THREAD_ALL_ACCESS, req->tinherit )) != -1)
{
THREAD_ALL_ACCESS, req->tinherit )) == -1)
goto error;
/* thread object will be released when the thread gets killed */
set_reply_fd( current, sock[1] );
req->pid = thread->process;
req->tid = thread;
req->pid = get_process_id( thread->process );
req->tid = get_thread_id( thread );
req->phandle = phandle;
req->event = event;
return;
}
close_handle( current->process, phandle );
}
release_object( thread );
}
error:
if (phandle != -1) close_handle( current->process, phandle );
if (event != -1) close_handle( current->process, event );
if (thread) release_object( thread );
close( sock[1] );
}
......
......@@ -158,14 +158,12 @@ struct thread *create_thread( int fd, struct process *process, int suspend )
if ((thread->next = first_thread) != NULL) thread->next->prev = thread;
first_thread = thread;
add_process_thread( process, thread );
set_select_events( &thread->obj, POLLIN ); /* start listening to events */
if (!alloc_client_buffer( thread )) goto error;
return thread;
error:
remove_process_thread( process, thread );
release_object( thread );
return NULL;
}
......@@ -611,6 +609,7 @@ DECL_HANDLER(new_thread)
{
set_reply_fd( current, sock[1] );
/* thread object will be released when the thread gets killed */
add_process_thread( current->process, thread );
return;
}
release_object( thread );
......
......@@ -224,7 +224,6 @@ static void dump_new_process_request( const struct new_process_request *req )
fprintf( stderr, " hstdin=%d,", req->hstdin );
fprintf( stderr, " hstdout=%d,", req->hstdout );
fprintf( stderr, " hstderr=%d,", req->hstderr );
fprintf( stderr, " event=%d,", req->event );
fprintf( stderr, " cmd_show=%d,", req->cmd_show );
fprintf( stderr, " env_ptr=%p,", req->env_ptr );
fprintf( stderr, " cmdline=" );
......@@ -236,7 +235,8 @@ static void dump_new_process_reply( const struct new_process_request *req )
fprintf( stderr, " pid=%p,", req->pid );
fprintf( stderr, " phandle=%d,", req->phandle );
fprintf( stderr, " tid=%p,", req->tid );
fprintf( stderr, " thandle=%d", req->thandle );
fprintf( stderr, " thandle=%d,", req->thandle );
fprintf( stderr, " event=%d", req->event );
}
static void dump_new_thread_request( const struct new_thread_request *req )
......
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