NTDLL: NtWaitForSingleObject doesn't return WAIT_FAILED
Mike McCormack
mike at codeweavers.com
Sat Jun 25 02:37:14 CDT 2005
ChangeLog:
* NtWaitForSingleObject doesn't return WAIT_FAILED
* use STATUS_WAIT_0 not WAIT_OBJECT_0
-------------- next part --------------
Index: dlls/ntdll/rtl.c
===================================================================
RCS file: /home/wine/wine/dlls/ntdll/rtl.c,v
retrieving revision 1.75
diff -u -p -r1.75 rtl.c
--- dlls/ntdll/rtl.c 21 Jun 2005 09:52:41 -0000 1.75
+++ dlls/ntdll/rtl.c 25 Jun 2005 07:36:23 -0000
@@ -167,10 +167,13 @@ start:
wait:
if( fWait )
{
+ NTSTATUS status;
+
rwl->uExclusiveWaiters++;
RtlLeaveCriticalSection( &rwl->rtlCS );
- if( NtWaitForSingleObject( rwl->hExclusiveReleaseSemaphore, FALSE, NULL ) == WAIT_FAILED )
+ status = NtWaitForSingleObject( rwl->hExclusiveReleaseSemaphore, FALSE, NULL );
+ if( HIWORD(status) )
goto done;
goto start; /* restart the acquisition to avoid deadlocks */
}
@@ -191,7 +194,7 @@ done:
*/
BYTE WINAPI RtlAcquireResourceShared(LPRTL_RWLOCK rwl, BYTE fWait)
{
- DWORD dwWait = WAIT_FAILED;
+ NTSTATUS status = STATUS_UNSUCCESSFUL;
BYTE retVal = 0;
if( !rwl ) return 0;
@@ -210,14 +213,15 @@ start:
{
rwl->uSharedWaiters++;
RtlLeaveCriticalSection( &rwl->rtlCS );
- if( (dwWait = NtWaitForSingleObject( rwl->hSharedReleaseSemaphore, FALSE, NULL )) == WAIT_FAILED )
+ status = NtWaitForSingleObject( rwl->hSharedReleaseSemaphore, FALSE, NULL );
+ if( HIWORD(status) )
goto done;
goto start;
}
}
else
{
- if( dwWait != WAIT_OBJECT_0 ) /* otherwise RtlReleaseResource() has already done it */
+ if( status != STATUS_WAIT_0 ) /* otherwise RtlReleaseResource() has already done it */
rwl->iNumberActive++;
retVal = 1;
}
More information about the wine-patches
mailing list