Commit 9d802152 authored by Alexandre Julliard's avatar Alexandre Julliard

A few optimizations in the process startup requests now that Winelib

apps are started differently from Unix ones.
parent 32886f6b
......@@ -214,7 +214,7 @@ struct get_new_process_info_reply
handle_t phandle;
void* tid;
handle_t thandle;
handle_t event;
int success;
};
......@@ -258,7 +258,6 @@ struct init_process_reply
struct reply_header __header;
int create_flags;
unsigned int server_start;
handle_t info;
size_t info_size;
handle_t exe_file;
handle_t hstdin;
......@@ -271,8 +270,6 @@ struct init_process_reply
struct get_startup_info_request
{
struct request_header __header;
handle_t info;
int close;
};
struct get_startup_info_reply
{
......@@ -3198,6 +3195,6 @@ union generic_reply
struct get_window_properties_reply get_window_properties_reply;
};
#define SERVER_PROTOCOL_VERSION 79
#define SERVER_PROTOCOL_VERSION 80
#endif /* __WINE_WINE_SERVER_PROTOCOL_H */
......@@ -201,8 +201,7 @@ inline static char *copy_str( char **dst, const char **src, size_t len )
*
* Fill the startup info structure from the server.
*/
ENVDB *ENV_InitStartupInfo( handle_t info_handle, size_t info_size,
char *main_exe_name, size_t main_exe_size )
ENVDB *ENV_InitStartupInfo( size_t info_size, char *main_exe_name, size_t main_exe_size )
{
startup_info_t info;
void *data;
......@@ -217,8 +216,6 @@ ENVDB *ENV_InitStartupInfo( handle_t info_handle, size_t info_size,
SERVER_START_REQ( get_startup_info )
{
req->info = info_handle;
req->close = TRUE;
wine_server_set_reply( req, data, info_size );
wine_server_call( req );
info_size = wine_server_reply_size( reply );
......
......@@ -118,8 +118,8 @@ static int main_create_flags;
static unsigned int server_startticks;
/* memory/environ.c */
extern struct _ENVDB *ENV_InitStartupInfo( handle_t info_handle, size_t info_size,
char *main_exe_name, size_t main_exe_size );
extern struct _ENVDB *ENV_InitStartupInfo( size_t info_size, char *main_exe_name,
size_t main_exe_size );
extern BOOL ENV_BuildCommandLine( char **argv );
extern STARTUPINFOA current_startupinfo;
......@@ -358,7 +358,6 @@ static BOOL process_init( char *argv[] )
{
BOOL ret;
size_t info_size = 0;
handle_t info = 0;
/* store the program name */
argv0 = argv[0];
......@@ -384,7 +383,6 @@ static BOOL process_init( char *argv[] )
main_exe_file = reply->exe_file;
main_create_flags = reply->create_flags;
info_size = reply->info_size;
info = reply->info;
server_startticks = reply->server_start;
current_startupinfo.hStdInput = reply->hstdin;
current_startupinfo.hStdOutput = reply->hstdout;
......@@ -420,12 +418,12 @@ static BOOL process_init( char *argv[] )
PTHREAD_init_done();
/* Copy the parent environment */
if (!(current_process.env_db = ENV_InitStartupInfo( info, info_size,
main_exe_name, sizeof(main_exe_name) )))
if (!(current_process.env_db = ENV_InitStartupInfo( info_size, main_exe_name,
sizeof(main_exe_name) )))
return FALSE;
/* Parse command line arguments */
OPTIONS_ParseOptions( !info ? argv : NULL );
OPTIONS_ParseOptions( !info_size ? argv : NULL );
ret = MAIN_MainInit();
......@@ -891,8 +889,7 @@ static BOOL create_process( HANDLE hFile, LPCSTR filename, LPSTR cmd_line, LPCST
BOOL inherit, DWORD flags, LPSTARTUPINFOA startup,
LPPROCESS_INFORMATION info, LPCSTR unixdir )
{
BOOL ret;
HANDLE load_done_evt = 0;
BOOL ret, success = FALSE;
HANDLE process_info;
startup_info_t startup_info;
......@@ -965,48 +962,33 @@ static BOOL create_process( HANDLE hFile, LPCSTR filename, LPSTR cmd_line, LPCST
/* wait for the new process info to be ready */
ret = TRUE; /* pretend success even if we don't get the new process info */
if (WaitForSingleObject( process_info, 2000 ) == STATUS_WAIT_0)
WaitForSingleObject( process_info, INFINITE );
SERVER_START_REQ( get_new_process_info )
{
SERVER_START_REQ( get_new_process_info )
req->info = process_info;
req->pinherit = (psa && (psa->nLength >= sizeof(*psa)) && psa->bInheritHandle);
req->tinherit = (tsa && (tsa->nLength >= sizeof(*tsa)) && tsa->bInheritHandle);
if ((ret = !wine_server_call_err( req )))
{
req->info = process_info;
req->pinherit = (psa && (psa->nLength >= sizeof(*psa)) && psa->bInheritHandle);
req->tinherit = (tsa && (tsa->nLength >= sizeof(*tsa)) && tsa->bInheritHandle);
if ((ret = !wine_server_call_err( req )))
{
info->dwProcessId = (DWORD)reply->pid;
info->dwThreadId = (DWORD)reply->tid;
info->hProcess = reply->phandle;
info->hThread = reply->thandle;
load_done_evt = reply->event;
}
info->dwProcessId = (DWORD)reply->pid;
info->dwThreadId = (DWORD)reply->tid;
info->hProcess = reply->phandle;
info->hThread = reply->thandle;
success = reply->success;
}
SERVER_END_REQ;
}
CloseHandle( process_info );
if (!ret) return FALSE;
SERVER_END_REQ;
/* Wait until process is initialized (or initialization failed) */
if (load_done_evt)
if (ret && !success) /* new process failed to start */
{
DWORD res;
HANDLE handles[2];
handles[0] = info->hProcess;
handles[1] = load_done_evt;
res = WaitForMultipleObjects( 2, handles, FALSE, INFINITE );
CloseHandle( load_done_evt );
if (res == STATUS_WAIT_0) /* the process died */
{
DWORD exitcode;
if (GetExitCodeProcess( info->hProcess, &exitcode )) SetLastError( exitcode );
CloseHandle( info->hThread );
CloseHandle( info->hProcess );
return FALSE;
}
DWORD exitcode;
if (GetExitCodeProcess( info->hProcess, &exitcode )) SetLastError( exitcode );
CloseHandle( info->hThread );
CloseHandle( info->hProcess );
ret = FALSE;
}
return TRUE;
CloseHandle( process_info );
return ret;
}
......
......@@ -427,7 +427,7 @@ static int debugger_attach( struct process *process, struct thread *debugger )
struct thread *thread;
if (process->debugger) goto error; /* already being debugged */
if (process->init_event) goto error; /* still starting up */
if (!is_process_init_done( process )) goto error; /* still starting up */
if (!process->thread_list) goto error; /* no thread running in the process */
/* make sure we don't create a debugging loop */
......@@ -470,7 +470,7 @@ int debugger_detach( struct process *process, struct thread *debugger )
goto error; /* not currently debugged, or debugged by another debugger */
if (!debugger->debug_ctx ) goto error; /* should be a debugger */
/* init should be done, otherwise wouldn't be attached */
assert(!process->init_event);
assert(is_process_init_done(process));
suspend_process( process );
/* send continue indication for all events */
......
......@@ -25,6 +25,7 @@
struct msg_queue;
struct atom_table;
struct startup_info;
/* process structures */
......@@ -60,7 +61,7 @@ struct process
int suspend; /* global process suspend count */
int create_flags; /* process creation flags */
struct console_input*console; /* console input */
struct event *init_event; /* event for init done */
struct startup_info *startup_info; /* startup info while init is in progress */
struct event *idle_event; /* event for input idle */
struct msg_queue *queue; /* main message queue */
struct atom_table *atom_table; /* pointer to local atom table */
......@@ -106,6 +107,7 @@ extern void detach_debugged_processes( struct thread *debugger );
extern struct process_snapshot *process_snap( int *count );
extern struct module_snapshot *module_snap( struct process *process, int *count );
static inline void *get_process_id( struct process *process ) { return process; }
inline static void *get_process_id( struct process *process ) { return process; }
inline static int is_process_init_done( struct process *process ) { return process->exe.base != 0; }
#endif /* __WINE_SERVER_PROCESS_H */
......@@ -220,7 +220,7 @@ typedef struct
handle_t phandle; /* process handle (in the current process) */
void* tid; /* thread id */
handle_t thandle; /* thread handle (in the current process) */
handle_t event; /* event handle to signal startup */
int success; /* did the process start successfully? */
@END
......@@ -248,7 +248,6 @@ typedef struct
@REPLY
int create_flags; /* creation flags */
unsigned int server_start; /* server start time (GetTickCount) */
handle_t info; /* handle to startup info */
size_t info_size; /* total size of startup info */
handle_t exe_file; /* file handle for main exe */
handle_t hstdin; /* handle for stdin */
......@@ -259,8 +258,6 @@ typedef struct
/* Retrieve the new process startup info */
@REQ(get_startup_info)
handle_t info; /* handle to startup info */
int close; /* should we close the handle at the same time? */
@REPLY
VARARG(info,startup_info); /* startup information */
@END
......
......@@ -177,7 +177,7 @@ void detach_thread( struct thread *thread, int sig )
void stop_thread( struct thread *thread )
{
/* can't stop a thread while initialisation is in progress */
if (!thread->unix_pid || thread->process->init_event) return;
if (!thread->unix_pid || !is_process_init_done(thread->process)) return;
/* first try to attach to it */
if (!thread->attached)
if (attach_thread( thread )) return; /* this will have stopped it */
......@@ -206,7 +206,7 @@ int suspend_for_ptrace( struct thread *thread )
return 1;
}
/* can't stop a thread while initialisation is in progress */
if (!thread->unix_pid || thread->process->init_event) goto error;
if (!thread->unix_pid || !is_process_init_done(thread->process)) goto error;
thread->suspend++;
if (attach_thread( thread )) return 1;
thread->suspend--;
......
......@@ -376,7 +376,7 @@ static void dump_get_new_process_info_reply( const struct get_new_process_info_r
fprintf( stderr, " phandle=%d,", req->phandle );
fprintf( stderr, " tid=%p,", req->tid );
fprintf( stderr, " thandle=%d,", req->thandle );
fprintf( stderr, " event=%d", req->event );
fprintf( stderr, " success=%d", req->success );
}
static void dump_new_thread_request( const struct new_thread_request *req )
......@@ -407,7 +407,6 @@ static void dump_init_process_reply( const struct init_process_reply *req )
{
fprintf( stderr, " create_flags=%d,", req->create_flags );
fprintf( stderr, " server_start=%08x,", req->server_start );
fprintf( stderr, " info=%d,", req->info );
fprintf( stderr, " info_size=%d,", req->info_size );
fprintf( stderr, " exe_file=%d,", req->exe_file );
fprintf( stderr, " hstdin=%d,", req->hstdin );
......@@ -417,8 +416,6 @@ static void dump_init_process_reply( const struct init_process_reply *req )
static void dump_get_startup_info_request( const struct get_startup_info_request *req )
{
fprintf( stderr, " info=%d,", req->info );
fprintf( stderr, " close=%d", req->close );
}
static void dump_get_startup_info_reply( const struct get_startup_info_reply *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