From 52f692fb9b49a0f64a4fcca5820c9af3b4f0ee1d Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Thu, 18 Sep 2003 23:27:19 +0000 Subject: [PATCH] Moved the wine server client-side support to dlls/ntdll. Removed a couple of unnecessary functions. --- dlls/kernel/process.c | 10 +++++-- dlls/kernel/thread.c | 2 +- dlls/ntdll/Makefile.in | 2 +- dlls/ntdll/ntdll.spec | 1 + scheduler/client.c => dlls/ntdll/server.c | 46 ++++++------------------------- include/wine/server.h | 5 +--- misc/registry.c | 14 +++++++--- 7 files changed, 30 insertions(+), 50 deletions(-) rename scheduler/client.c => dlls/ntdll/server.c (95%) diff --git a/dlls/kernel/process.c b/dlls/kernel/process.c index e2c7cd339a7..f01730fc144 100644 --- a/dlls/kernel/process.c +++ b/dlls/kernel/process.c @@ -306,7 +306,7 @@ static BOOL process_init( char *argv[] ) InitializeListHead(&process_ldr.InInitializationOrderModuleList); /* Setup the server connection */ - CLIENT_InitServer(); + wine_server_init_thread(); /* Retrieve startup info from the server */ SERVER_START_REQ( init_process ) @@ -386,7 +386,13 @@ static BOOL process_init( char *argv[] ) SHELL_LoadRegistry(); /* global boot finished, the rest is process-local */ - CLIENT_BootDone( TRACE_ON(server) ); + SERVER_START_REQ( boot_done ) + { + req->debug_level = TRACE_ON(server); + wine_server_call( req ); + } + SERVER_END_REQ; + if (TRACE_ON(relay) || TRACE_ON(snoop)) RELAY_InitDebugLists(); return TRUE; diff --git a/dlls/kernel/thread.c b/dlls/kernel/thread.c index cef1f40a6a3..c1f19a3b442 100644 --- a/dlls/kernel/thread.c +++ b/dlls/kernel/thread.c @@ -189,7 +189,7 @@ static void THREAD_Start( TEB *teb ) SYSDEPS_SetCurThread( teb ); SIGNAL_Init(); - CLIENT_InitThread(); + wine_server_init_thread(); if (TRACE_ON(relay)) DPRINTF("%04lx:Starting thread (entryproc=%p)\n", GetCurrentThreadId(), func ); diff --git a/dlls/ntdll/Makefile.in b/dlls/ntdll/Makefile.in index f114a19200b..a8205342cfc 100644 --- a/dlls/ntdll/Makefile.in +++ b/dlls/ntdll/Makefile.in @@ -31,7 +31,6 @@ C_SRCS = \ $(TOPOBJDIR)/relay32/builtin32.c \ $(TOPOBJDIR)/relay32/relay386.c \ $(TOPOBJDIR)/relay32/snoop.c \ - $(TOPOBJDIR)/scheduler/client.c \ $(TOPOBJDIR)/scheduler/handle.c \ $(TOPOBJDIR)/scheduler/process.c \ $(TOPOBJDIR)/scheduler/pthread.c \ @@ -58,6 +57,7 @@ C_SRCS = \ rtlbitmap.c \ rtlstr.c \ sec.c \ + server.c \ signal_i386.c \ signal_powerpc.c \ signal_sparc.c \ diff --git a/dlls/ntdll/ntdll.spec b/dlls/ntdll/ntdll.spec index f28e2ed71e1..1509fa11f66 100644 --- a/dlls/ntdll/ntdll.spec +++ b/dlls/ntdll/ntdll.spec @@ -1062,6 +1062,7 @@ # Server interface @ cdecl -norelay wine_server_call(ptr) +@ cdecl wine_server_init_thread() @ cdecl wine_server_fd_to_handle(long long long ptr) @ cdecl wine_server_handle_to_fd(long long ptr ptr ptr) diff --git a/scheduler/client.c b/dlls/ntdll/server.c similarity index 95% rename from scheduler/client.c rename to dlls/ntdll/server.c index ec62534a8f8..223182325ab 100644 --- a/scheduler/client.c +++ b/dlls/ntdll/server.c @@ -1,5 +1,5 @@ /* - * Client part of the client/server communication + * Wine server communication * * Copyright (C) 1998 Alexandre Julliard * @@ -76,9 +76,8 @@ struct cmsg_fd }; #endif /* HAVE_STRUCT_MSGHDR_MSG_ACCRIGHTS */ -static HANDLE boot_thread_id; static sigset_t block_set; /* signals to block during server calls */ -static int fd_socket; /* socket to exchange file descriptors with the server */ +static int fd_socket = -1; /* socket to exchange file descriptors with the server */ #ifdef __GNUC__ static void fatal_error( const char *err, ... ) __attribute__((noreturn, format(printf,1,2))); @@ -602,11 +601,11 @@ static int server_connect( const char *oldcwd, const char *serverdir ) /*********************************************************************** - * CLIENT_InitServer + * server_init * * Start the server and create the initial socket pair. */ -void CLIENT_InitServer(void) +static void server_init(void) { int size; char *oldcwd; @@ -658,23 +657,23 @@ void CLIENT_InitServer(void) /* receive the first thread request fd on the main socket */ NtCurrentTeb()->request_fd = receive_fd( &dummy_handle ); - - CLIENT_InitThread(); } /*********************************************************************** - * CLIENT_InitThread + * wine_server_init_thread * * Send an init thread request. Return 0 if OK. */ -void CLIENT_InitThread(void) +void wine_server_init_thread(void) { TEB *teb = NtCurrentTeb(); int version, ret; int reply_pipe[2]; struct sigaction sig_act; + if (fd_socket == -1) server_init(); + sig_act.sa_handler = SIG_IGN; sig_act.sa_flags = 0; sigemptyset( &sig_act.sa_mask ); @@ -712,8 +711,6 @@ void CLIENT_InitThread(void) teb->ClientId.UniqueProcess = (HANDLE)reply->pid; teb->ClientId.UniqueThread = (HANDLE)reply->tid; version = reply->version; - if (reply->boot) boot_thread_id = teb->ClientId.UniqueThread; - else if (boot_thread_id == teb->ClientId.UniqueThread) boot_thread_id = 0; } SERVER_END_REQ; @@ -726,30 +723,3 @@ void CLIENT_InitThread(void) version, SERVER_PROTOCOL_VERSION, (version > SERVER_PROTOCOL_VERSION) ? "wine" : "wineserver" ); } - - -/*********************************************************************** - * CLIENT_BootDone - * - * Signal that we have finished booting, and set debug level. - */ -void CLIENT_BootDone( int debug_level ) -{ - SERVER_START_REQ( boot_done ) - { - req->debug_level = debug_level; - wine_server_call( req ); - } - SERVER_END_REQ; -} - - -/*********************************************************************** - * CLIENT_IsBootThread - * - * Return TRUE if current thread is the boot thread. - */ -int CLIENT_IsBootThread(void) -{ - return (GetCurrentThreadId() == (DWORD)boot_thread_id); -} diff --git a/include/wine/server.h b/include/wine/server.h index d811032184e..54e54596279 100644 --- a/include/wine/server.h +++ b/include/wine/server.h @@ -56,6 +56,7 @@ extern void wine_server_send_fd( int fd ); extern int wine_server_fd_to_handle( int fd, unsigned int access, int inherit, obj_handle_t *handle ); extern int wine_server_handle_to_fd( obj_handle_t handle, unsigned int access, int *unix_fd, enum fd_type *type, int *flags ); +extern void wine_server_init_thread(void); /* do a server call and set the last error code */ inline static unsigned int wine_server_call_err( void *req_ptr ) @@ -113,9 +114,5 @@ inline static void wine_server_set_reply( void *req_ptr, void *ptr, unsigned int /* non-exported functions */ extern void DECLSPEC_NORETURN server_protocol_error( const char *err, ... ); extern void DECLSPEC_NORETURN server_protocol_perror( const char *err ); -extern void CLIENT_InitServer(void); -extern void CLIENT_InitThread(void); -extern void CLIENT_BootDone( int debug_level ); -extern int CLIENT_IsBootThread(void); #endif /* __WINE_WINE_SERVER_H */ diff --git a/misc/registry.c b/misc/registry.c index c37a4d60901..9d2f077dabb 100644 --- a/misc/registry.c +++ b/misc/registry.c @@ -1654,6 +1654,7 @@ void SHELL_LoadRegistry( void ) OBJECT_ATTRIBUTES attr; UNICODE_STRING nameW; DWORD count; + ULONG dispos; BOOL res; int all, period; char tmp[1024]; @@ -1677,8 +1678,6 @@ void SHELL_LoadRegistry( void ) TRACE("(void)\n"); - if (!CLIENT_IsBootThread()) return; /* already loaded */ - attr.Length = sizeof(attr); attr.RootDirectory = 0; attr.ObjectName = &nameW; @@ -1686,10 +1685,17 @@ void SHELL_LoadRegistry( void ) attr.SecurityDescriptor = NULL; attr.SecurityQualityOfService = NULL; + RtlInitUnicodeString( &nameW, UserW ); + NtCreateKey( &hkey_users, KEY_ALL_ACCESS, &attr, 0, NULL, 0, &dispos ); + if (dispos == REG_OPENED_EXISTING_KEY) + { + /* someone else already loaded the registry */ + NtClose( hkey_users ); + return; + } + RtlInitUnicodeString( &nameW, MachineW ); NtCreateKey( &hkey_local_machine, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ); - RtlInitUnicodeString( &nameW, UserW ); - NtCreateKey( &hkey_users, KEY_ALL_ACCESS, &attr, 0, NULL, 0, NULL ); attr.RootDirectory = hkey_users; RtlInitUnicodeString( &nameW, DefaultW ); -- 2.11.4.GIT