From 7b7d8374a40ddae124cdd089e2eedb32e11b9f03 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Mon, 1 Sep 2014 10:40:42 +0400 Subject: [PATCH] ntdll: NtWaitForMultipleObjects()'s third arguments means 'wait_any', not 'wait_all'. --- dlls/kernel32/sync.c | 2 +- dlls/kernel32/tests/sync.c | 28 +++++++++++++++++++++++++--- dlls/ntdll/sync.c | 4 ++-- dlls/ntdll/threadpool.c | 2 +- 4 files changed, 29 insertions(+), 7 deletions(-) diff --git a/dlls/kernel32/sync.c b/dlls/kernel32/sync.c index 8379c1dab15..d399b829f0d 100644 --- a/dlls/kernel32/sync.c +++ b/dlls/kernel32/sync.c @@ -185,7 +185,7 @@ DWORD WINAPI WaitForMultipleObjectsEx( DWORD count, const HANDLE *handles, } } - status = NtWaitForMultipleObjects( count, hloc, wait_all, alertable, + status = NtWaitForMultipleObjects( count, hloc, !wait_all, alertable, get_nt_timeout( &time, timeout ) ); if (HIWORD(status)) /* is it an error code? */ diff --git a/dlls/kernel32/tests/sync.c b/dlls/kernel32/tests/sync.c index 238130270e8..cbe0acb4b61 100644 --- a/dlls/kernel32/tests/sync.c +++ b/dlls/kernel32/tests/sync.c @@ -24,6 +24,7 @@ #include #include #include +#include #include "wine/test.h" @@ -55,6 +56,7 @@ static VOID (WINAPI *pReleaseSRWLockExclusive)(PSRWLOCK); static VOID (WINAPI *pReleaseSRWLockShared)(PSRWLOCK); static BOOLEAN (WINAPI *pTryAcquireSRWLockExclusive)(PSRWLOCK); static BOOLEAN (WINAPI *pTryAcquireSRWLockShared)(PSRWLOCK); +static NTSTATUS (WINAPI *pNtWaitForMultipleObjects)(ULONG,const HANDLE*,BOOLEAN,BOOLEAN,const LARGE_INTEGER*); static void test_signalandwait(void) { @@ -1153,15 +1155,32 @@ static void test_WaitForMultipleObjects(void) } /* a manual-reset event remains signaled, an auto-reset event is cleared */ - r = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, 0, 0); + r = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, FALSE, 0); ok( r == WAIT_OBJECT_0, "should signal lowest handle first, got %d\n", r); - r = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, 0, 0); + r = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, FALSE, 0); ok( r == WAIT_OBJECT_0, "should signal handle #0 first, got %d\n", r); ok(ResetEvent(maxevents[0]), "ResetEvent\n"); for (i=1; i MAXIMUM_WAIT_OBJECTS) return STATUS_INVALID_PARAMETER_1; if (alertable) flags |= SELECT_ALERTABLE; - select_op.wait.op = wait_all ? SELECT_WAIT_ALL : SELECT_WAIT; + select_op.wait.op = wait_any ? SELECT_WAIT : SELECT_WAIT_ALL; for (i = 0; i < count; i++) select_op.wait.handles[i] = wine_server_obj_handle( handles[i] ); return server_select( &select_op, offsetof( select_op_t, wait.handles[count] ), flags, timeout ); } diff --git a/dlls/ntdll/threadpool.c b/dlls/ntdll/threadpool.c index f66f6abe683..fef26fe405b 100644 --- a/dlls/ntdll/threadpool.c +++ b/dlls/ntdll/threadpool.c @@ -322,7 +322,7 @@ static DWORD CALLBACK wait_thread_proc(LPVOID Arg) while (TRUE) { - status = NtWaitForMultipleObjects( 2, handles, FALSE, alertable, + status = NtWaitForMultipleObjects( 2, handles, TRUE, alertable, get_nt_timeout( &timeout, wait_work_item->Milliseconds ) ); if (status == STATUS_WAIT_0 || status == STATUS_TIMEOUT) {