diff --git a/dlls/ntdll/unix/server.c b/dlls/ntdll/unix/server.c index 9a593f77250..faca7da5c93 100644 --- a/dlls/ntdll/unix/server.c +++ b/dlls/ntdll/unix/server.c @@ -590,7 +590,7 @@ static void invoke_system_apc( const apc_call_t *call, apc_result_t *result ) * server_select */ unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT flags, - timeout_t abs_timeout, CONTEXT *context, RTL_CRITICAL_SECTION *cs, + timeout_t abs_timeout, CONTEXT *context, pthread_mutex_t *mutex, user_apc_t *user_apc ) { unsigned int ret; @@ -649,10 +649,10 @@ unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT size = offsetof( select_op_t, signal_and_wait.signal ); } pthread_sigmask( SIG_SETMASK, &old_set, NULL ); - if (cs) + if (mutex) { - RtlLeaveCriticalSection( cs ); - cs = NULL; + pthread_mutex_unlock( mutex ); + mutex = NULL; } if (ret != STATUS_PENDING) break; diff --git a/dlls/ntdll/unix/sync.c b/dlls/ntdll/unix/sync.c index 5080caef526..69263efa0ef 100644 --- a/dlls/ntdll/unix/sync.c +++ b/dlls/ntdll/unix/sync.c @@ -78,15 +78,7 @@ HANDLE keyed_event = 0; static const LARGE_INTEGER zero_timeout; -static RTL_CRITICAL_SECTION addr_section; -static RTL_CRITICAL_SECTION_DEBUG addr_section_debug = -{ - 0, 0, &addr_section, - { &addr_section_debug.ProcessLocksList, &addr_section_debug.ProcessLocksList }, - 0, 0, { (DWORD_PTR)(__FILE__ ": addr_section") } -}; -static RTL_CRITICAL_SECTION addr_section = { &addr_section_debug, -1, 0, 0, 0, 0 }; - +static pthread_mutex_t addr_mutex = PTHREAD_MUTEX_INITIALIZER; /* return a monotonic time counter, in Win32 ticks */ static inline ULONGLONG monotonic_counter(void) @@ -2253,10 +2245,10 @@ NTSTATUS WINAPI RtlWaitOnAddress( const void *addr, const void *cmp, SIZE_T size if ((ret = fast_wait_addr( addr, cmp, size, timeout )) != STATUS_NOT_IMPLEMENTED) return ret; - RtlEnterCriticalSection( &addr_section ); + pthread_mutex_lock( &addr_mutex ); if (!compare_addr( addr, cmp, size )) { - RtlLeaveCriticalSection( &addr_section ); + pthread_mutex_unlock( &addr_mutex ); return STATUS_SUCCESS; } @@ -2272,7 +2264,8 @@ NTSTATUS WINAPI RtlWaitOnAddress( const void *addr, const void *cmp, SIZE_T size select_op.keyed_event.handle = wine_server_obj_handle( keyed_event ); select_op.keyed_event.key = wine_server_client_ptr( addr ); - return server_select( &select_op, sizeof(select_op.keyed_event), SELECT_INTERRUPTIBLE, abs_timeout, NULL, &addr_section, NULL ); + return server_select( &select_op, sizeof(select_op.keyed_event), SELECT_INTERRUPTIBLE, + abs_timeout, NULL, &addr_mutex, NULL ); } /*********************************************************************** @@ -2282,9 +2275,9 @@ void WINAPI RtlWakeAddressAll( const void *addr ) { if (fast_wake_addr( addr ) != STATUS_NOT_IMPLEMENTED) return; - RtlEnterCriticalSection( &addr_section ); + pthread_mutex_lock( &addr_mutex ); while (NtReleaseKeyedEvent( 0, addr, 0, &zero_timeout ) == STATUS_SUCCESS) {} - RtlLeaveCriticalSection( &addr_section ); + pthread_mutex_unlock( &addr_mutex ); } /*********************************************************************** @@ -2294,7 +2287,7 @@ void WINAPI RtlWakeAddressSingle( const void *addr ) { if (fast_wake_addr( addr ) != STATUS_NOT_IMPLEMENTED) return; - RtlEnterCriticalSection( &addr_section ); + pthread_mutex_lock( &addr_mutex ); NtReleaseKeyedEvent( 0, addr, 0, &zero_timeout ); - RtlLeaveCriticalSection( &addr_section ); + pthread_mutex_unlock( &addr_mutex ); } diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index 2a73f17e101..3d56ea5d408 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -162,7 +162,7 @@ extern unsigned int server_call_unlocked( void *req_ptr ) DECLSPEC_HIDDEN; extern void server_enter_uninterrupted_section( pthread_mutex_t *mutex, sigset_t *sigset ) DECLSPEC_HIDDEN; extern void server_leave_uninterrupted_section( pthread_mutex_t *mutex, sigset_t *sigset ) DECLSPEC_HIDDEN; extern unsigned int server_select( const select_op_t *select_op, data_size_t size, UINT flags, - timeout_t abs_timeout, CONTEXT *context, RTL_CRITICAL_SECTION *cs, + timeout_t abs_timeout, CONTEXT *context, pthread_mutex_t *mutex, user_apc_t *user_apc ) DECLSPEC_HIDDEN; extern unsigned int server_wait( const select_op_t *select_op, data_size_t size, UINT flags, const LARGE_INTEGER *timeout ) DECLSPEC_HIDDEN;