commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mt...@apache.org
Subject svn commit: r806439 - /commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
Date Fri, 21 Aug 2009 07:52:34 GMT
Author: mturk
Date: Fri Aug 21 07:52:34 2009
New Revision: 806439

URL: http://svn.apache.org/viewvc?rev=806439&view=rev
Log:
Few comments on Darwin muteses

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

Modified: commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c?rev=806439&r1=806438&r2=806439&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c Fri Aug 21 07:52:34 2009
@@ -14,6 +14,13 @@
  * limitations under the License.
  */
 
+/* File lock based mutex implementation.
+ * XXX: Darwin uses posix semaphores so they could
+ *      probably be used for mutexes as well.
+ *      Of course they don't have a descent API for
+ *      setting the permissions afterwards.
+ */
+
 #include "acr.h"
 #include "acr_private.h"
 #include "acr_arch.h"
@@ -67,7 +74,7 @@
         }
         if (m->filedes > 0)
             close(m->filedes);
-        if (m->fname) { 
+        if (m->fname) {
             unlink(m->fname);
             free(m->fname);
         }
@@ -99,7 +106,7 @@
     if (m->anon)
         m->filedes = mkstemp(m->fname);
     else
-        m->filedes = open(m->fname, O_CREAT | O_WRONLY | O_EXCL, 0644);
+        m->filedes = open(m->fname, O_CREAT | O_WRONLY | O_EXCL, 0660);
 
     if (m->filedes < 0) {
         rc =  ACR_GET_OS_ERROR();
@@ -121,7 +128,7 @@
 }
 
 ACR_DECLARE(int) ACR_ProcMutexAttach(JNIEnv *_E, const acr_pchar_t *fname)
-{    
+{
     int rc = 0;
     acr_pmutex_t *m;
 
@@ -162,7 +169,7 @@
 
     if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
         return ACR_EINVAL;
-    }        
+    }
 
     op.l_whence = SEEK_SET;   /* from current point */
     op.l_start  = 0;          /* -"- */
@@ -190,7 +197,7 @@
 
     if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
         return ACR_EINVAL;
-    }        
+    }
     op.l_whence = SEEK_SET;   /* from current point */
     op.l_start  = 0;          /* -"- */
     op.l_len    = 0;          /* until end of file */
@@ -220,7 +227,7 @@
 
     if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
         return ACR_EINVAL;
-    }        
+    }
 
     m->locked   = 0;
     op.l_whence = SEEK_SET;   /* from current point */
@@ -245,7 +252,7 @@
 
     if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
         return ACR_EINVAL;
-    }        
+    }
     if (!(perms & ACR_FPROT_GSETID))
         gid = -1;
     if (fchown(m->filedes, uid, gid) < 0) {
@@ -263,6 +270,17 @@
     return acr_ioh_close(mutex);
 }
 
+ACR_DECLARE(int) ACR_ProcMutexRemove(JNIEnv *_E, const acr_pchar_t *filename)
+{
+
+    if (unlink(filename)) {
+        ACR_THROW_IO_ERROR();
+        return ACR_GET_OS_ERROR();
+    }
+    else
+        return ACR_SUCCESS;
+}
+
 ACR_CLASS_LDEF(Mutex)
 {
     int rv;



Mime
View raw message