Alexandre Julliard : ntdll: Move the LDT section to ntdll and make it an uninterruptible section.

Alexandre Julliard julliard at wine.codeweavers.com
Fri Jan 19 06:29:17 CST 2007


Module: wine
Branch: master
Commit: 21d631e2708649fabca672ed450cc15f1eca6dc7
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=21d631e2708649fabca672ed450cc15f1eca6dc7

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Thu Jan 18 15:01:45 2007 +0100

ntdll: Move the LDT section to ntdll and make it an uninterruptible section.

---

 dlls/kernel32/kernel_main.c |   26 --------------------------
 dlls/ntdll/thread.c         |   39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 39 insertions(+), 26 deletions(-)

diff --git a/dlls/kernel32/kernel_main.c b/dlls/kernel32/kernel_main.c
index f6eeba9..9f6b311 100644
--- a/dlls/kernel32/kernel_main.c
+++ b/dlls/kernel32/kernel_main.c
@@ -43,29 +43,6 @@
 
 extern  int __wine_set_signal_handler(unsigned, int (*)(unsigned));
 
-static CRITICAL_SECTION ldt_section;
-static CRITICAL_SECTION_DEBUG critsect_debug =
-{
-    0, 0, &ldt_section,
-    { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
-      0, 0, { (DWORD_PTR)(__FILE__ ": ldt_section") }
-};
-static CRITICAL_SECTION ldt_section = { &critsect_debug, -1, 0, 0, 0, 0 };
-
-/***********************************************************************
- *           locking for LDT routines
- */
-static void ldt_lock(void)
-{
-    RtlEnterCriticalSection( &ldt_section );
-}
-
-static void ldt_unlock(void)
-{
-    RtlLeaveCriticalSection( &ldt_section );
-}
-
-
 /***********************************************************************
  *           KERNEL thread initialisation routine
  */
@@ -141,9 +118,6 @@ static BOOL process_attach(void)
     }
 #endif
 
-    /* initialize LDT locking */
-    wine_ldt_init_locking( ldt_lock, ldt_unlock );
-
     /* finish the process initialisation for console bits, if needed */
     __wine_set_signal_handler(SIGINT, CONSOLE_HandleCtrlC);
 
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 356ba11..4d99195 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -63,6 +63,41 @@ static ULONG sigstack_zero_bits;
 
 struct wine_pthread_functions pthread_functions = { NULL };
 
+
+static RTL_CRITICAL_SECTION ldt_section;
+static RTL_CRITICAL_SECTION_DEBUG critsect_debug =
+{
+    0, 0, &ldt_section,
+    { &critsect_debug.ProcessLocksList, &critsect_debug.ProcessLocksList },
+      0, 0, { (DWORD_PTR)(__FILE__ ": ldt_section") }
+};
+static RTL_CRITICAL_SECTION ldt_section = { &critsect_debug, -1, 0, 0, 0, 0 };
+static sigset_t ldt_sigset;
+
+/***********************************************************************
+ *           locking for LDT routines
+ */
+static void ldt_lock(void)
+{
+    sigset_t sigset;
+
+    pthread_functions.sigprocmask( SIG_BLOCK, &server_block_set, &sigset );
+    RtlEnterCriticalSection( &ldt_section );
+    if (ldt_section.RecursionCount == 1) ldt_sigset = sigset;
+}
+
+static void ldt_unlock(void)
+{
+    if (ldt_section.RecursionCount == 1)
+    {
+        sigset_t sigset = ldt_sigset;
+        RtlLeaveCriticalSection( &ldt_section );
+        pthread_functions.sigprocmask( SIG_SETMASK, &sigset, NULL );
+    }
+    else RtlLeaveCriticalSection( &ldt_section );
+}
+
+
 /***********************************************************************
  *           init_teb
  */
@@ -285,6 +320,10 @@ HANDLE thread_init(void)
         wine_server_fd_to_handle( 1, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, &params.hStdOutput );
         wine_server_fd_to_handle( 2, GENERIC_WRITE|SYNCHRONIZE, OBJ_INHERIT, &params.hStdError );
     }
+
+    /* initialize LDT locking */
+    wine_ldt_init_locking( ldt_lock, ldt_unlock );
+
     return exe_file;
 }
 




More information about the wine-cvs mailing list