You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by mt...@apache.org on 2011/04/19 17:29:29 UTC

svn commit: r1095115 - in /commons/sandbox/runtime/trunk/src/main: java/org/apache/commons/runtime/platform/unix/SysVMutex.java native/os/unix/procmutex.c test/org/apache/commons/runtime/TestMutex.java

Author: mturk
Date: Tue Apr 19 15:29:29 2011
New Revision: 1095115

URL: http://svn.apache.org/viewvc?rev=1095115&view=rev
Log:
Close only the owner

Modified:
    commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVMutex.java
    commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c
    commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMutex.java

Modified: commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVMutex.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVMutex.java?rev=1095115&r1=1095114&r2=1095115&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVMutex.java (original)
+++ commons/sandbox/runtime/trunk/src/main/java/org/apache/commons/runtime/platform/unix/SysVMutex.java Tue Apr 19 15:29:29 2011
@@ -112,10 +112,11 @@ final class SysVMutex extends Mutex
         int rc;
         if (fd == -1)
             throw new ClosedDescriptorException();
-        close0(fd);
+        release0(fd);
         if (owner) {
             // Unlink if we are the semaphore owner.
-            rc = Posix.unlink(name);
+            Posix.unlink(name);
+            rc = close0(fd);
             if (rc != 0)
                 throw new SystemException(Status.describe(rc));
         }
@@ -133,11 +134,12 @@ final class SysVMutex extends Mutex
         throws Throwable
     {
         if (fd != -1) {
-            close0(fd);
-        }
-        if (owner) {
-            // Unlink if we are the semaphore owner.
-            Posix.unlink(name);
+            release0(fd);
+            if (owner) {
+                // Unlink if we are the semaphore owner.
+                Posix.unlink(name);
+                close0(fd);
+            }
         }
     }
 

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c?rev=1095115&r1=1095114&r2=1095115&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/procmutex.c Tue Apr 19 15:29:29 2011
@@ -222,16 +222,7 @@ cleanup:
 
 ACR_UNX_EXPORT(jint, SysVMutex, close0)(JNI_STDARGS, jint fd)
 {
-    int    rc;
     union  semun ick;
-    struct sembuf op;
-
-    op.sem_num = 0;
-    op.sem_op  = 1;
-    op.sem_flg = SEM_UNDO;
-    do {
-        rc = semop(fd, &op, 1);
-    } while (rc == -1 && errno == EINTR);
 
     ick.val = 0;
     if (semctl(fd, 0, IPC_RMID, ick) == 0)
@@ -240,6 +231,7 @@ ACR_UNX_EXPORT(jint, SysVMutex, close0)(
         return ACR_GET_OS_ERROR();
 }
 
+
 ACR_UNX_EXPORT(jint, SysVMutex, wait0)(JNI_STDARGS, jint fd)
 {
     int rc;

Modified: commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMutex.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMutex.java?rev=1095115&r1=1095114&r2=1095115&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMutex.java (original)
+++ commons/sandbox/runtime/trunk/src/main/test/org/apache/commons/runtime/TestMutex.java Tue Apr 19 15:29:29 2011
@@ -85,6 +85,8 @@ public class TestMutex extends Assert
         s.close();
         System.out.println("[child]  Done.");
         System.out.flush();
+        s = Mutex.open(mtxname);
+        s.close();
     }
 
 }