ntdll: NtWaitForMultipleObjects()'s third arguments means 'wait_any', not 'wait_all'.

This commit is contained in:
Nikolay Sivov 2014-09-01 10:40:42 +04:00 committed by Alexandre Julliard
parent 60de49770c
commit 7b7d8374a4
4 changed files with 29 additions and 7 deletions

View File

@ -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? */

View File

@ -24,6 +24,7 @@
#include <stdio.h>
#include <windef.h>
#include <winbase.h>
#include <winternl.h>
#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; i++)
{
/* the lowest index is checked first and remaining events are untouched */
r = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, 0, 0);
r = WaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, FALSE, 0);
ok( r == WAIT_OBJECT_0+i, "should signal handle #%d first, got %d\n", i, r);
}
/* run same test with Nt* call */
for (i=0; i<MAXIMUM_WAIT_OBJECTS; i++)
SetEvent(maxevents[i]);
/* a manual-reset event remains signaled, an auto-reset event is cleared */
r = pNtWaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, TRUE, FALSE, NULL);
ok( r == WAIT_OBJECT_0, "should signal lowest handle first, got %d\n", r);
r = pNtWaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, TRUE, FALSE, NULL);
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; i++)
{
/* the lowest index is checked first and remaining events are untouched */
r = pNtWaitForMultipleObjects(MAXIMUM_WAIT_OBJECTS, maxevents, TRUE, FALSE, NULL);
ok( r == WAIT_OBJECT_0+i, "should signal handle #%d first, got %d\n", i, r);
}
@ -2287,6 +2306,8 @@ static void test_srwlock_example(void)
START_TEST(sync)
{
HMODULE hdll = GetModuleHandleA("kernel32.dll");
HMODULE hntdll = GetModuleHandleA("ntdll.dll");
pChangeTimerQueueTimer = (void*)GetProcAddress(hdll, "ChangeTimerQueueTimer");
pCreateTimerQueue = (void*)GetProcAddress(hdll, "CreateTimerQueue");
pCreateTimerQueueTimer = (void*)GetProcAddress(hdll, "CreateTimerQueueTimer");
@ -2312,6 +2333,7 @@ START_TEST(sync)
pReleaseSRWLockShared = (void *)GetProcAddress(hdll, "ReleaseSRWLockShared");
pTryAcquireSRWLockExclusive = (void *)GetProcAddress(hdll, "TryAcquireSRWLockExclusive");
pTryAcquireSRWLockShared = (void *)GetProcAddress(hdll, "TryAcquireSRWLockShared");
pNtWaitForMultipleObjects = (void *)GetProcAddress(hntdll, "NtWaitForMultipleObjects");
test_signalandwait();
test_mutex();

View File

@ -849,7 +849,7 @@ NTSTATUS WINAPI NtSetTimerResolution(IN ULONG resolution,
* NtWaitForMultipleObjects (NTDLL.@)
*/
NTSTATUS WINAPI NtWaitForMultipleObjects( DWORD count, const HANDLE *handles,
BOOLEAN wait_all, BOOLEAN alertable,
BOOLEAN wait_any, BOOLEAN alertable,
const LARGE_INTEGER *timeout )
{
select_op_t select_op;
@ -858,7 +858,7 @@ NTSTATUS WINAPI NtWaitForMultipleObjects( DWORD count, const HANDLE *handles,
if (!count || count > 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 );
}

View File

@ -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)
{