Moved the wine server client-side support to dlls/ntdll. Removed a
couple of unnecessary functions.
diff --git a/dlls/kernel/process.c b/dlls/kernel/process.c
index e2c7cd3..f01730f 100644
--- a/dlls/kernel/process.c
+++ b/dlls/kernel/process.c
@@ -306,7 +306,7 @@
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 @@
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 cef1f40..c1f19a3 100644
--- a/dlls/kernel/thread.c
+++ b/dlls/kernel/thread.c
@@ -189,7 +189,7 @@
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 f114a19..a820534 100644
--- a/dlls/ntdll/Makefile.in
+++ b/dlls/ntdll/Makefile.in
@@ -31,7 +31,6 @@
$(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 @@
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 f28e2ed..1509fa1 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 94%
rename from scheduler/client.c
rename to dlls/ntdll/server.c
index ec62534..2231823 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 @@
};
#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 @@
/***********************************************************************
- * 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 @@
/* 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 @@
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 @@
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 d811032..54e5459 100644
--- a/include/wine/server.h
+++ b/include/wine/server.h
@@ -56,6 +56,7 @@
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 @@
/* 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 c37a4d6..9d2f077 100644
--- a/misc/registry.c
+++ b/misc/registry.c
@@ -1654,6 +1654,7 @@
OBJECT_ATTRIBUTES attr;
UNICODE_STRING nameW;
DWORD count;
+ ULONG dispos;
BOOL res;
int all, period;
char tmp[1024];
@@ -1677,8 +1678,6 @@
TRACE("(void)\n");
- if (!CLIENT_IsBootThread()) return; /* already loaded */
-
attr.Length = sizeof(attr);
attr.RootDirectory = 0;
attr.ObjectName = &nameW;
@@ -1686,10 +1685,17 @@
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 );