From 7a1069e9bd3ba4a7abbc78b9f012bc05e9b818e8 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 20 Apr 2020 00:02:00 +0200 Subject: [PATCH] ntdll: Remove APC handling from RtlWaitOnAddress. It uses non-alertable wait anyway. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/ntdll/ntdll_misc.h | 2 -- dlls/ntdll/server.c | 4 ++-- dlls/ntdll/sync.c | 34 +++++++++++----------------------- 3 files changed, 13 insertions(+), 27 deletions(-) diff --git a/dlls/ntdll/ntdll_misc.h b/dlls/ntdll/ntdll_misc.h index 336d7c0463b..964953e27d1 100644 --- a/dlls/ntdll/ntdll_misc.h +++ b/dlls/ntdll/ntdll_misc.h @@ -128,8 +128,6 @@ extern int server_pipe( int fd[2] ) DECLSPEC_HIDDEN; extern NTSTATUS alloc_object_attributes( const OBJECT_ATTRIBUTES *attr, struct object_attributes **ret, data_size_t *ret_len ) DECLSPEC_HIDDEN; extern NTSTATUS validate_open_object_attributes( const OBJECT_ATTRIBUTES *attr ) DECLSPEC_HIDDEN; -extern int wait_select_reply( void *cookie ) DECLSPEC_HIDDEN; -extern void invoke_apc( const user_apc_t *apc ) DECLSPEC_HIDDEN; /* module handling */ extern LIST_ENTRY tls_links DECLSPEC_HIDDEN; diff --git a/dlls/ntdll/server.c b/dlls/ntdll/server.c index be080a9f73b..3de5a93556f 100644 --- a/dlls/ntdll/server.c +++ b/dlls/ntdll/server.c @@ -349,7 +349,7 @@ void server_leave_uninterrupted_section( RTL_CRITICAL_SECTION *cs, sigset_t *sig * * Wait for a reply on the waiting pipe of the current thread. */ -int wait_select_reply( void *cookie ) +static int wait_select_reply( void *cookie ) { int signaled; struct wake_up_reply reply; @@ -381,7 +381,7 @@ int wait_select_reply( void *cookie ) } -void invoke_apc( const user_apc_t *apc ) +static void invoke_apc( const user_apc_t *apc ) { switch( apc->type ) { diff --git a/dlls/ntdll/sync.c b/dlls/ntdll/sync.c index be00ac75d07..d3927a05af3 100644 --- a/dlls/ntdll/sync.c +++ b/dlls/ntdll/sync.c @@ -2557,9 +2557,7 @@ NTSTATUS WINAPI RtlWaitOnAddress( const void *addr, const void *cmp, SIZE_T size { select_op_t select_op; NTSTATUS ret; - BOOL user_apc = FALSE; timeout_t abs_timeout = timeout ? timeout->QuadPart : TIMEOUT_INFINITE; - user_apc_t apc; if (size != 1 && size != 2 && size != 4 && size != 8) return STATUS_INVALID_PARAMETER; @@ -2567,9 +2565,12 @@ 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; - select_op.keyed_event.op = SELECT_KEYED_EVENT_WAIT; - select_op.keyed_event.handle = wine_server_obj_handle( keyed_event ); - select_op.keyed_event.key = wine_server_client_ptr( addr ); + RtlEnterCriticalSection( &addr_section ); + if (!compare_addr( addr, cmp, size )) + { + RtlLeaveCriticalSection( &addr_section ); + return STATUS_SUCCESS; + } if (abs_timeout < 0) { @@ -2579,25 +2580,12 @@ NTSTATUS WINAPI RtlWaitOnAddress( const void *addr, const void *cmp, SIZE_T size abs_timeout -= now.QuadPart; } - for (;;) - { - RtlEnterCriticalSection( &addr_section ); - if (!compare_addr( addr, cmp, size )) - ret = STATUS_SUCCESS; - else - ret = server_select( &select_op, sizeof(select_op.keyed_event), SELECT_INTERRUPTIBLE, abs_timeout, NULL, &apc ); - RtlLeaveCriticalSection( &addr_section ); + select_op.keyed_event.op = SELECT_KEYED_EVENT_WAIT; + select_op.keyed_event.handle = wine_server_obj_handle( keyed_event ); + select_op.keyed_event.key = wine_server_client_ptr( addr ); - if (ret != STATUS_USER_APC) break; - invoke_apc( &apc ); - - /* if we ran a user apc we have to check once more if additional apcs are queued, - * but we don't want to wait */ - abs_timeout = 0; - user_apc = TRUE; - } - - if (ret == STATUS_TIMEOUT && user_apc) ret = STATUS_USER_APC; + ret = server_select( &select_op, sizeof(select_op.keyed_event), SELECT_INTERRUPTIBLE, abs_timeout, NULL, NULL ); + RtlLeaveCriticalSection( &addr_section ); return ret; }