commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r812063 - /commons/sandbox/runtime/trunk/src/main/native/os/win32/sema.c
Date Mon, 07 Sep 2009 09:48:52 GMT
Author: mturk
Date: Mon Sep  7 09:48:52 2009
New Revision: 812063

URL: http://svn.apache.org/viewvc?rev=812063&view=rev
Log:
Return consistent error codes across calls

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

Modified: commons/sandbox/runtime/trunk/src/main/native/os/win32/sema.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/win32/sema.c?rev=812063&r1=812062&r2=812063&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/win32/sema.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/win32/sema.c Mon Sep  7 09:48:52 2009
@@ -40,11 +40,14 @@
 static int semaphore_cleanup(void *sema, int type, unsigned int flags)
 {
     if (type == ACR_DT_SEMAPHORE) {
-        if (IS_VALID_HANDLE(sema))
+        if (IS_VALID_HANDLE(sema)) {
             CloseHandle(sema);
-        return ACR_SUCCESS;
+            return ACR_SUCCESS;
+        }
+        else
+            return ACR_EBADF;
     }
-    return ACR_EBADF;
+    return ACR_EFTYPE;
 }
 
 ACR_DECLARE(int) ACR_SemaphoreCreate(JNIEnv *_E, const acr_pchar_t *name,
@@ -136,9 +139,13 @@
     int rc = 0;
     HANDLE s = (HANDLE)ACR_IOH_FDATA(sema);
 
-    if (IS_INVALID_HANDLE(s) || ACR_IOH_FTYPE(sema) != ACR_DT_SEMAPHORE) {
-        return ACR_EINVAL;
+    if (ACR_IOH_FTYPE(sema) != ACR_DT_SEMAPHORE) {
+        return ACR_EFTYPE;
     }
+    if (IS_INVALID_HANDLE(s)) {
+        return ACR_EBADF;
+    }
+
     return ACR_ENOTIMPL;
 }
 
@@ -149,8 +156,11 @@
     HANDLE wh[2];
     HANDLE s = (HANDLE)ACR_IOH_FDATA(sema);
 
-    if (ACR_IOH_FTYPE(sema) != ACR_DT_SEMAPHORE || IS_INVALID_HANDLE(s)) {
-        return ACR_EINVAL;
+    if (ACR_IOH_FTYPE(sema) != ACR_DT_SEMAPHORE) {
+        return ACR_EFTYPE;
+    }
+    if (IS_INVALID_HANDLE(s)) {
+        return ACR_EBADF;
     }
 
     wh[0] = dll_psig_handle;
@@ -192,8 +202,11 @@
     int rc;
     HANDLE s = (HANDLE)ACR_IOH_FDATA(sema);
 
-    if (IS_INVALID_HANDLE(s) || ACR_IOH_FTYPE(sema) != ACR_DT_SEMAPHORE) {
-        return ACR_EINVAL;
+    if (ACR_IOH_FTYPE(sema) != ACR_DT_SEMAPHORE) {
+        return ACR_EFTYPE;
+    }
+    if (IS_INVALID_HANDLE(s)) {
+        return ACR_EBADF;
     }
     rc = WaitForSingleObject(s, 0);
 
@@ -212,8 +225,11 @@
     int rc = 0;
     acr_semaphore_t *s = (acr_semaphore_t *)ACR_IOH_FDATA(sema);
 
-    if (IS_INVALID_HANDLE(s) || ACR_IOH_FTYPE(sema) != ACR_DT_SEMAPHORE) {
-        return ACR_EINVAL;
+    if (ACR_IOH_FTYPE(sema) != ACR_DT_SEMAPHORE) {
+        return ACR_EFTYPE;
+    }
+    if (IS_INVALID_HANDLE(s)) {
+        return ACR_EBADF;
     }
 
     for (;;) {
@@ -236,8 +252,11 @@
     int rc = 0;
     HANDLE s = (HANDLE)ACR_IOH_FDATA(sema);
 
-    if (IS_INVALID_HANDLE(s) || ACR_IOH_FTYPE(sema) != ACR_DT_SEMAPHORE) {
-        return ACR_EINVAL;
+    if (ACR_IOH_FTYPE(sema) != ACR_DT_SEMAPHORE) {
+        return ACR_EFTYPE;
+    }
+    if (IS_INVALID_HANDLE(s)) {
+        return ACR_EBADF;
     }
 
     if (!ReleaseSemaphore(s, 1, NULL))



Mime
View raw message