commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r810574 - in /commons/sandbox/runtime/trunk/src/main/native/os/win32: pmutex.c psema.c
Date Wed, 02 Sep 2009 15:38:47 GMT
Author: mturk
Date: Wed Sep  2 15:38:47 2009
New Revision: 810574

URL: http://svn.apache.org/viewvc?rev=810574&view=rev
Log:
Make sure we use signal event as firts object in wait

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c
    commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c?rev=810574&r1=810573&r2=810574&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/pmutex.c Wed Sep  2 15:38:47 2009
@@ -45,7 +45,7 @@
             return ACR_SUCCESS;
         }
         else
-            return ACR_EBADF;            
+            return ACR_EBADF;
     }
     return ACR_EFTYPE;
 }
@@ -119,8 +119,8 @@
     DWORD  ws;
     HANDLE wh[2];
 
-    wh[0] = (HANDLE)ACR_IOH(mutex);
-    wh[1] = dll_psig_handle;
+    wh[0] = dll_psig_handle;
+    wh[1] = (HANDLE)ACR_IOH(mutex);
     if (ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
         return ACR_EFTYPE;
     }
@@ -131,24 +131,29 @@
         rc = 0;
         ws = WaitForMultipleObjectsEx(2, wh, FALSE, INFINITE, TRUE);
 
-        if (ws == WAIT_OBJECT_0 || ws == WAIT_ABANDONED) {
-            /* We got the lock */
-            return 0;
-        }
-        else if (ws == WAIT_OBJECT_0 + 1) {
+        else if (ws == WAIT_OBJECT_0) {
             /* Signal event is set
              * TODO: Deliver a signal
              */
             rc = ACR_EINTR;
         }
+        if (ws == WAIT_OBJECT_0 + 1 || ws == WAIT_ABANDONED_0 + 1) {
+            /* We got the lock */
+            return 0;
+        }
         else if (ws == WAIT_IO_COMPLETION) {
             /* APC queued to this thread
              * TODO: Deliver a signal
              */
             rc = ACR_TIMEUP;
         }
-        else
+        else if (ws == WAIT_ERROR) {
+            /* We got the error while waiting
+             */
             rc = ACR_GET_OS_ERROR();
+        }
+        else
+            rc = ACR_ENOLOCK;
     } while (rc == ACR_EINTR);
 
     return rc;

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c?rev=810574&r1=810573&r2=810574&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/psema.c Wed Sep  2 15:38:47 2009
@@ -153,30 +153,35 @@
         return ACR_EINVAL;
     }
 
-    wh[0] = s;
-    wh[1] = dll_psig_handle;
+    wh[0] = dll_psig_handle;
+    wh[1] = s;
     do {
         rc = 0;
         ws = WaitForMultipleObjectsEx(2, wh, FALSE, INFINITE, TRUE);
 
-        if (ws == WAIT_OBJECT_0 || ws == WAIT_ABANDONED) {
-            /* We got the lock */
-            return 0;
-        }
-        else if (ws == WAIT_OBJECT_0 + 1) {
+        if (ws == WAIT_OBJECT_0) {
             /* Signal event is set
              * TODO: Deliver a signal
              */
             rc = ACR_EINTR;
         }
+        else if (ws == WAIT_OBJECT_0 + 1) {
+            /* We got the lock */
+            return 0;
+        }
         else if (ws == WAIT_IO_COMPLETION) {
             /* APC queued to this thread
              * TODO: Deliver a signal
              */
             rc = ACR_TIMEUP;
         }
-        else
+        else if (ws == WAIT_ERROR) {
+            /* We got the error while waiting
+             */
             rc = ACR_GET_OS_ERROR();
+        }
+        else
+            rc = ACR_ENOLOCK;
     } while (rc == ACR_EINTR);
 
     return rc;



Mime
View raw message