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 2009/08/07 14:44:36 UTC
svn commit: r801977 - in /commons/sandbox/runtime/trunk/src/main/native:
Makefile.msc.in include/acr_procmutex.h os/darwin/pmutex.c os/unix/pmutex.c
Author: mturk
Date: Fri Aug 7 12:44:36 2009
New Revision: 801977
URL: http://svn.apache.org/viewvc?rev=801977&view=rev
Log:
Implement attach for mutexes
Modified:
commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
commons/sandbox/runtime/trunk/src/main/native/include/acr_procmutex.h
commons/sandbox/runtime/trunk/src/main/native/os/darwin/pmutex.c
commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=801977&r1=801976&r2=801977&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Fri Aug 7 12:44:36 2009
@@ -95,6 +95,7 @@
$(SRCDIR)/os/win32/platform.$(OBJ) \
$(SRCDIR)/os/win32/os.$(OBJ) \
$(SRCDIR)/os/win32/ios.$(OBJ) \
+ $(SRCDIR)/os/win32/pmutex.$(OBJ) \
$(SRCDIR)/os/win32/shm.$(OBJ) \
$(SRCDIR)/os/win32/syslog.$(OBJ) \
$(SRCDIR)/os/win32/group.$(OBJ) \
Modified: commons/sandbox/runtime/trunk/src/main/native/include/acr_procmutex.h
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_procmutex.h?rev=801977&r1=801976&r2=801977&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_procmutex.h (original)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_procmutex.h Fri Aug 7 12:44:36 2009
@@ -47,6 +47,17 @@
ACR_DECLARE(int) ACR_ProcMutexCreate(JNIEnv *env, const acr_pchar_t *fname);
/**
+ * Re-open a mutex in child process.
+ * @param env JNI environment to use.
+ * @param fname A file name to use if the lock mechanism requires one. This
+ * argument should always be provided. The lock code itself will
+ * determine if it should be used.
+ * @remark This function must be called to maintain portability, even
+ * if the underlying lock mechanism does not require it.
+ */
+ACR_DECLARE(int) ACR_ProcMutexAttach(JNIEnv *env, const acr_pchar_t *fname);
+
+/**
* Acquire the lock for the given mutex. If the mutex is already locked,
* the current thread will be put to sleep until the lock becomes available.
* @param env JNI environment to use.
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=801977&r1=801976&r2=801977&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 7 12:44:36 2009
@@ -111,6 +111,12 @@
}
}
+ACR_DECLARE(int) ACR_ProcMutexAttach(JNIEnv *_E, const acr_pchar_t *fname)
+{
+ ACR_SET_OS_ERROR(ACR_ENOTIMPL);
+ return -1;
+}
+
ACR_DECLARE(int) ACR_ProcMutexLock(JNIEnv *_E, int mutex)
{
int rc;
Modified: commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c
URL: http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c?rev=801977&r1=801976&r2=801977&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/os/unix/pmutex.c Fri Aug 7 12:44:36 2009
@@ -57,7 +57,7 @@
{
union semun ick;
int rc = 0;
- acr_pmutex_t *m;
+ acr_pmutex_t *m;
m = ACR_Calloc(_E, THROW_FMARK, sizeof(acr_pmutex_t));
if (!m)
@@ -97,6 +97,12 @@
}
}
+ACR_DECLARE(int) ACR_ProcMutexAttach(JNIEnv *_E, const acr_pchar_t *fname)
+{
+ ACR_SET_OS_ERROR(ACR_ENOTIMPL);
+ return -1;
+}
+
ACR_DECLARE(int) ACR_ProcMutexLock(JNIEnv *_E, int mutex)
{
int rc;
@@ -106,7 +112,7 @@
if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
ACR_SET_OS_ERROR(ACR_EINVAL);
return -1;
- }
+ }
op.sem_num = 0;
op.sem_op = -1;
op.sem_flg = SEM_UNDO;
@@ -130,7 +136,7 @@
if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
return ACR_EINVAL;
- }
+ }
op.sem_num = 0;
op.sem_op = -1;
op.sem_flg = SEM_UNDO | IPC_NOWAIT;
@@ -143,6 +149,8 @@
if (errno == EAGAIN) {
return ACR_EBUSY;
}
+ else
+ return ACR_GET_OS_ERROR();
}
else
m->locked = 1;
@@ -158,7 +166,7 @@
if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
return ACR_EINVAL;
- }
+ }
m->locked = 0;
op.sem_num = 0;
@@ -183,7 +191,7 @@
if (IS_INVALID_HANDLE(m) || ACR_IOH_TYPE(mutex) != ACR_DT_MUTEX) {
return ACR_EINVAL;
- }
+ }
buf.sem_perm.uid = uid;
buf.sem_perm.gid = gid;
buf.sem_perm.mode = ACR_UnixPermsToMode(perms);