Daniel Lehman : ntdll: Use the configured CriticalSection timeout in RtlpWaitForCriticalSection.

Alexandre Julliard julliard at wine.codeweavers.com
Thu Sep 11 13:40:14 CDT 2014


Module: wine
Branch: master
Commit: 27b3a5cce4e7092fe9776dfb57fcf1b602a92538
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=27b3a5cce4e7092fe9776dfb57fcf1b602a92538

Author: Daniel Lehman <dlehman at esri.com>
Date:   Tue Sep  9 11:25:46 2014 -0700

ntdll: Use the configured CriticalSection timeout in RtlpWaitForCriticalSection.

---

 dlls/ntdll/critsection.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/dlls/ntdll/critsection.c b/dlls/ntdll/critsection.c
index 839c7ca..6e0332b 100644
--- a/dlls/ntdll/critsection.c
+++ b/dlls/ntdll/critsection.c
@@ -435,10 +435,12 @@ NTSTATUS WINAPI RtlDeleteCriticalSection( RTL_CRITICAL_SECTION *crit )
  */
 NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit )
 {
+    LONGLONG timeout = NtCurrentTeb()->Peb->CriticalSectionTimeout.QuadPart / -10000000;
     for (;;)
     {
         EXCEPTION_RECORD rec;
         NTSTATUS status = wait_semaphore( crit, 5 );
+        timeout -= 5;
 
         if ( status == STATUS_TIMEOUT )
         {
@@ -448,11 +450,14 @@ NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit )
             ERR( "section %p %s wait timed out in thread %04x, blocked by %04x, retrying (60 sec)\n",
                  crit, debugstr_a(name), GetCurrentThreadId(), HandleToULong(crit->OwningThread) );
             status = wait_semaphore( crit, 60 );
+            timeout -= 60;
+
             if ( status == STATUS_TIMEOUT && TRACE_ON(relay) )
             {
                 ERR( "section %p %s wait timed out in thread %04x, blocked by %04x, retrying (5 min)\n",
                      crit, debugstr_a(name), GetCurrentThreadId(), HandleToULong(crit->OwningThread) );
                 status = wait_semaphore( crit, 300 );
+                timeout -= 300;
             }
         }
         if (status == STATUS_WAIT_0) break;
@@ -460,6 +465,9 @@ NTSTATUS WINAPI RtlpWaitForCriticalSection( RTL_CRITICAL_SECTION *crit )
         /* Throw exception only for Wine internal locks */
         if ((!crit->DebugInfo) || (!crit->DebugInfo->Spare[0])) continue;
 
+        /* only throw deadlock exception if configured timeout is reached */
+        if (timeout > 0) continue;
+
         rec.ExceptionCode    = STATUS_POSSIBLE_DEADLOCK;
         rec.ExceptionFlags   = 0;
         rec.ExceptionRecord  = NULL;




More information about the wine-cvs mailing list