From: Rémi Bernon rbernon@codeweavers.com
--- dlls/ntdll/unix/virtual.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-)
diff --git a/dlls/ntdll/unix/virtual.c b/dlls/ntdll/unix/virtual.c index 278800021af..bf09559d755 100644 --- a/dlls/ntdll/unix/virtual.c +++ b/dlls/ntdll/unix/virtual.c @@ -167,7 +167,7 @@ static const BYTE VIRTUAL_Win32Flags[16] = };
static struct wine_rb_tree views_tree; -static pthread_mutex_t virtual_mutex; +static pthread_mutex_t virtual_mutex = PTHREAD_MUTEX_INITIALIZER;
static const UINT page_shift = 12; static const UINT_PTR page_mask = 0xfff; @@ -3646,12 +3646,6 @@ void virtual_init(void) const char *preload; size_t size; int i; - pthread_mutexattr_t attr; - - pthread_mutexattr_init( &attr ); - pthread_mutexattr_settype( &attr, PTHREAD_MUTEX_RECURSIVE ); - pthread_mutex_init( &virtual_mutex, &attr ); - pthread_mutexattr_destroy( &attr );
#ifdef __aarch64__ host_page_size = sysconf( _SC_PAGESIZE ); @@ -4879,7 +4873,6 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ unsigned int vprot; BOOL is_dos_memory = FALSE; struct file_view *view; - sigset_t sigset; SIZE_T size = *size_ptr; NTSTATUS status = STATUS_SUCCESS;
@@ -4925,8 +4918,6 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
/* Reserve the memory */
- server_enter_uninterrupted_section( &virtual_mutex, &sigset ); - if ((type & MEM_RESERVE) || !base) { if (!(status = get_vprot_flags( protect, &vprot, FALSE ))) @@ -4975,8 +4966,6 @@ static NTSTATUS allocate_virtual_memory( void **ret, SIZE_T *size_ptr, ULONG typ
if (!status) VIRTUAL_DEBUG_DUMP_VIEW( view );
- server_leave_uninterrupted_section( &virtual_mutex, &sigset ); - if (status == STATUS_SUCCESS) { *ret = base; @@ -4998,6 +4987,8 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR z { static const ULONG type_mask = MEM_COMMIT | MEM_RESERVE | MEM_TOP_DOWN | MEM_WRITE_WATCH | MEM_RESET; ULONG_PTR limit; + NTSTATUS status; + sigset_t sigset;
TRACE("%p %p %08lx %x %08x\n", process, *ret, *size_ptr, type, protect );
@@ -5013,7 +5004,6 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR z { union apc_call call; union apc_result result; - unsigned int status;
memset( &call, 0, sizeof(call) );
@@ -5044,7 +5034,10 @@ NTSTATUS WINAPI NtAllocateVirtualMemory( HANDLE process, PVOID *ret, ULONG_PTR z else limit = 0;
- return allocate_virtual_memory( ret, size_ptr, type, protect, 0, limit, 0, 0 ); + server_enter_uninterrupted_section( &virtual_mutex, &sigset ); + status = allocate_virtual_memory( ret, size_ptr, type, protect, 0, limit, 0, 0 ); + server_leave_uninterrupted_section( &virtual_mutex, &sigset ); + return status; }
@@ -5193,6 +5186,7 @@ NTSTATUS WINAPI NtAllocateVirtualMemoryEx( HANDLE process, PVOID *ret, SIZE_T *s ULONG attributes = 0; USHORT machine = 0; unsigned int status; + sigset_t sigset;
TRACE( "%p %p %08lx %x %08x %p %u\n", process, *ret, *size_ptr, type, protect, parameters, count ); @@ -5232,8 +5226,10 @@ NTSTATUS WINAPI NtAllocateVirtualMemoryEx( HANDLE process, PVOID *ret, SIZE_T *s return result.virtual_alloc_ex.status; }
- return allocate_virtual_memory( ret, size_ptr, type, protect, - limit_low, limit_high, align, attributes ); + server_enter_uninterrupted_section( &virtual_mutex, &sigset ); + status = allocate_virtual_memory( ret, size_ptr, type, protect, limit_low, limit_high, align, attributes ); + server_leave_uninterrupted_section( &virtual_mutex, &sigset ); + return status; }