commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r804230 - in /commons/sandbox/runtime/trunk/src: main/native/os/hpux/shm.c main/native/os/unix/shm.c main/native/test/testcase.c test/org/apache/commons/runtime/TestPrivate.java
Date Fri, 14 Aug 2009 13:58:31 GMT
Author: mturk
Date: Fri Aug 14 13:58:30 2009
New Revision: 804230

URL: http://svn.apache.org/viewvc?rev=804230&view=rev
Log:
Some hacks for OS's that return EINVAL if shm is already attached

Modified:
    commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c
    commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c
    commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
    commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java

Modified: commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c?rev=804230&r1=804229&r2=804230&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/hpux/shm.c Fri Aug 14 13:58:30 2009
@@ -490,3 +490,16 @@
         return m->reqsize;
 }
 
+#if defined(ACR_ENABLE_TEST)
+int acr_shm_detach(int shm)
+{
+    acr_shm_t *m = (acr_shm_t *)ACR_IOH(shm);
+    if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(shm) != ACR_DT_SHM) {
+        ACR_SET_OS_ERROR(ACR_EINVAL);
+        return -1;
+    }
+    else
+        return shmdt(m->base);
+}
+#endif
+

Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c?rev=804230&r1=804229&r2=804230&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/shm.c Fri Aug 14 13:58:30 2009
@@ -471,3 +471,17 @@
         return m->reqsize;
 }
 
+#if defined(ACR_ENABLE_TEST)
+int acr_shm_detach(int shm)
+{
+    acr_shm_t *m = (acr_shm_t *)ACR_IOH(shm);
+    if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(shm) != ACR_DT_SHM) {
+        ACR_SET_OS_ERROR(ACR_EINVAL);
+        return -1;
+    }
+    else
+        return shmdt(m->base);
+}
+#endif
+
+ 

Modified: commons/sandbox/runtime/trunk/src/main/native/test/testcase.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/test/testcase.c?rev=804230&r1=804229&r2=804230&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/test/testcase.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/test/testcase.c Fri Aug 14 13:58:30 2009
@@ -678,15 +678,24 @@
 
 ACR_JNI_EXPORT_DECLARE(jint, TestPrivate, test064)(ACR_JNISTDARGS, jint d)
 {
-#if 1
+#if defined(WIN32)
     return ACR_ShmAttach(_E, shr_name);
 #else
+    extern int acr_shm_detach();
     int stat;
     pid_t child;
     if ((child = fork()) == 0) {
-        int rc = ACR_ShmAttach(_E, shr_name);
+        int rc;
+        errno = 0;
+        acr_shm_detach(d);
+        rc = ACR_ShmAttach(_E, shr_name);
         fprintf(stdout, "Attach returned %d errno=%d\n", rc, errno);
         fflush(stdout);
+        if (rc > 0) {
+            rc = ACR_ShmClose(_E, rc);
+            fprintf(stdout, "Close returned %d\n", rc);
+            fflush(stdout);
+        }
         exit(0);
     }
     waitpid(child, &stat, 0);

Modified: commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java?rev=804230&r1=804229&r2=804230&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java (original)
+++ commons/sandbox/runtime/trunk/src/test/org/apache/commons/runtime/TestPrivate.java Fri
Aug 14 13:58:30 2009
@@ -937,7 +937,7 @@
         int sa = test061(1024);
         assertTrue("Shared memory", sa > 0);
 
-        int sb = test064(0);
+        int sb = test064(sa);
         if (sb != 0) {
             assertTrue("Shared memory", sb > 0);
             assertEquals("Shared memory size", 1024, test066(sb));



Mime
View raw message