aaron 01/10/19 16:25:28
Modified: include apr_portable.h
locks/beos proc_mutex.c
locks/netware proc_mutex.c
locks/os2 proc_mutex.c
locks/unix proc_mutex.c
locks/win32 proc_mutex.c
Log:
Implement portable accessors for proc mutex. These are equivalent to
apr_os_lock_get/set, but they work for apr_proc_mutex_t types instead.
I did my best to implement these on non-Unix platforms from how I saw
them implemented for apr_os_lock_get/set, but on those platforms they
are untested.
Revision Changes Path
1.71 +33 -4 apr/include/apr_portable.h
Index: apr_portable.h
===================================================================
RCS file: /home/cvs/apr/include/apr_portable.h,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -r1.70 -r1.71
--- apr_portable.h 2001/09/28 14:05:23 1.70
+++ apr_portable.h 2001/10/19 23:25:28 1.71
@@ -75,6 +75,7 @@
#include "apr_network_io.h"
#include "apr_errno.h"
#include "apr_lock.h"
+#include "apr_proc_mutex.h"
#include "apr_time.h"
#include "apr_dso.h"
@@ -97,7 +98,9 @@
typedef HANDLE apr_os_file_t;
typedef HANDLE apr_os_dir_t;
typedef SOCKET apr_os_sock_t;
+/* We're deprecating apr_lock_t, so apr_os_lock_t will be gone too. */
typedef HANDLE apr_os_lock_t;
+typedef HANDLE apr_os_proc_mutex_t;
typedef HANDLE apr_os_thread_t;
typedef PROCESS_INFORMATION apr_os_proc_t;
typedef DWORD apr_os_threadkey_t;
@@ -109,7 +112,9 @@
typedef HFILE apr_os_file_t;
typedef HDIR apr_os_dir_t;
typedef int apr_os_sock_t;
+/* We're deprecating apr_lock_t, so apr_os_lock_t will be gone too. */
typedef HMTX apr_os_lock_t;
+typedef HMTX apr_os_proc_mutex_t;
typedef TID apr_os_thread_t;
typedef PID apr_os_proc_t;
typedef PULONG apr_os_threadkey_t;
@@ -121,7 +126,7 @@
#include <kernel/OS.h>
#include <kernel/image.h>
-struct apr_os_lock_t {
+struct apr_os_proc_mutex_t {
sem_id sem;
int32 ben;
};
@@ -129,7 +134,9 @@
typedef int apr_os_file_t;
typedef DIR apr_os_dir_t;
typedef int apr_os_sock_t;
-typedef struct apr_os_lock_t apr_os_lock_t;
+/* We're deprecating apr_lock_t, so apr_os_lock_t will be gone too. */
+typedef struct apr_os_proc_mutex_t apr_os_lock_t;
+typedef struct apr_os_proc_mutex_t apr_os_proc_mutex_t;
typedef thread_id apr_os_thread_t;
typedef thread_id apr_os_proc_t;
typedef int apr_os_threadkey_t;
@@ -141,7 +148,9 @@
typedef int apr_os_file_t;
typedef DIR apr_os_dir_t;
typedef int apr_os_sock_t;
+/* We're deprecating apr_lock_t, so apr_os_lock_t will be gone too. */
typedef NXMutex_t apr_os_lock_t;
+typedef NXMutex_t apr_os_proc_mutex_t;
typedef NXThreadId_t apr_os_thread_t;
typedef long apr_os_proc_t;
typedef NXKey_t apr_os_threadkey_t;
@@ -154,7 +163,7 @@
* denominator typedefs for all UNIX-like systems. :)
*/
-struct apr_os_lock_t {
+struct apr_os_proc_mutex_t {
#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE ||
APR_HAS_FLOCK_SERIALIZE
int crossproc;
#endif
@@ -172,7 +181,9 @@
typedef int apr_os_file_t;
typedef DIR apr_os_dir_t;
typedef int apr_os_sock_t;
-typedef struct apr_os_lock_t apr_os_lock_t;
+/* We're deprecating apr_lock_t, so apr_os_lock_t will be gone too. */
+typedef struct apr_os_proc_mutex_t apr_os_lock_t;
+typedef struct apr_os_proc_mutex_t apr_os_proc_mutex_t;
#if APR_HAS_THREADS && APR_HAVE_PTHREAD_H
typedef pthread_t apr_os_thread_t;
typedef pthread_key_t apr_os_threadkey_t;
@@ -246,6 +257,14 @@
apr_lock_t *lock);
/**
+ * Convert the proc mutex from os specific type to apr type
+ * @param ospmutex The os specific proc mutex we are converting to.
+ * @param pmutex The apr proc mutex to convert.
+ */
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t
*ospmutex,
+ apr_proc_mutex_t *pmutex);
+
+/**
* Get the exploded time in the platforms native format.
* @param ostime the native time format
* @param aprtime the time to convert
@@ -372,6 +391,16 @@
APR_DECLARE(apr_status_t) apr_os_lock_put(apr_lock_t **lock,
apr_os_lock_t *thelock,
apr_pool_t *cont);
+
+/**
+ * Convert the proc mutex from os specific type to apr type
+ * @param pmutex The apr proc mutex we are converting to.
+ * @param ospmutex The os specific proc mutex to convert.
+ * @param cont The pool to use if it is needed.
+ */
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex,
+ apr_os_proc_mutex_t
*ospmutex,
+ apr_pool_t *cont);
/**
* Put the imploded time in the APR format.
1.3 +27 -0 apr/locks/beos/proc_mutex.c
Index: proc_mutex.c
===================================================================
RCS file: /home/cvs/apr/locks/beos/proc_mutex.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- proc_mutex.c 2001/09/29 05:03:37 1.2
+++ proc_mutex.c 2001/10/19 23:25:28 1.3
@@ -104,3 +104,30 @@
APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
+/* Implement OS-specific accessors defined in apr_portable.h */
+
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t
*ospmutex,
+ apr_proc_mutex_t *pmutex)
+{
+ ospmutex->sem = pmutex->Lock;
+ ospmutex->ben = pmutex->LockCount;
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex,
+ apr_os_proc_mutex_t
*ospmutex,
+ apr_pool_t *pool)
+{
+ if (pool == NULL) {
+ return APR_ENOPOOL;
+ }
+ if ((*pmutex) == NULL) {
+ (*pmutex) = (apr_proc_mutex_t *)apr_pcalloc(pool,
+
sizeof(apr_proc_mutex_t));
+ (*pmutex)->pool = pool;
+ }
+ (*pmutex)->Lock = ospmutex->sem;
+ (*pmutex)->LockCount = ospmutex->ben;
+ return APR_SUCCESS;
+}
+
1.3 +25 -0 apr/locks/netware/proc_mutex.c
Index: proc_mutex.c
===================================================================
RCS file: /home/cvs/apr/locks/netware/proc_mutex.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- proc_mutex.c 2001/09/29 05:03:37 1.2
+++ proc_mutex.c 2001/10/19 23:25:28 1.3
@@ -103,3 +103,28 @@
APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
+/* Implement OS-specific accessors defined in apr_portable.h */
+
+apr_status_t apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
+ apr_proc_mutex_t *pmutex)
+{
+ ospmutex = pmutex->mutex;
+ return APR_SUCCESS;
+}
+
+apr_status_t apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex,
+ apr_os_proc_mutex_t *ospmutex,
+ apr_pool_t *pool)
+{
+ if (pool == NULL) {
+ return APR_ENOPOOL;
+ }
+ if ((*pmutex) == NULL) {
+ (*pmutex) = (apr_proc_mutex_t *)apr_palloc(pool,
+ sizeof(apr_proc_mutex_t));
+ (*pmutex)->pool = pool;
+ }
+ (*pmutex)->mutex = ospmutex;
+ return APR_SUCCESS;
+}
+
1.4 +25 -0 apr/locks/os2/proc_mutex.c
Index: proc_mutex.c
===================================================================
RCS file: /home/cvs/apr/locks/os2/proc_mutex.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- proc_mutex.c 2001/09/29 05:03:37 1.3
+++ proc_mutex.c 2001/10/19 23:25:28 1.4
@@ -106,3 +106,28 @@
APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
+/* Implement OS-specific accessors defined in apr_portable.h */
+
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t
*ospmutex,
+ apr_proc_mutex_t *pmutex)
+{
+ *ospmutex = pmutex->hMutex;
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex,
+ apr_os_proc_mutex_t
*ospmutex,
+ apr_pool_t *pool)
+{
+ if (pool == NULL) {
+ return APR_ENOPOOL;
+ }
+ if ((*pmutex) == NULL) {
+ (*pmutex) = (apr_proc_mutex_t *)apr_pcalloc(pool,
+
sizeof(apr_proc_mutex_t));
+ (*pmutex)->pool = pool;
+ }
+ (*pmutex)->hMutex = *ospmutex;
+ return APR_SUCCESS;
+}
+
1.5 +35 -0 apr/locks/unix/proc_mutex.c
Index: proc_mutex.c
===================================================================
RCS file: /home/cvs/apr/locks/unix/proc_mutex.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- proc_mutex.c 2001/09/29 05:03:37 1.4
+++ proc_mutex.c 2001/10/19 23:25:28 1.5
@@ -810,3 +810,38 @@
APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
+/* Implement OS-specific accessors defined in apr_portable.h */
+
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t
*ospmutex,
+ apr_proc_mutex_t *pmutex)
+{
+#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE ||
APR_HAS_FLOCK_SERIALIZE
+ ospmutex->crossproc = pmutex->interproc->filedes;
+#endif
+#if APR_HAS_PROC_PTHREAD_SERIALIZE
+ ospmutex->pthread_interproc = pmutex->pthread_interproc;
+#endif
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex,
+ apr_os_proc_mutex_t
*ospmutex,
+ apr_pool_t *pool)
+{
+ if (pool == NULL) {
+ return APR_ENOPOOL;
+ }
+ if ((*pmutex) == NULL) {
+ (*pmutex) = (apr_proc_mutex_t *)apr_pcalloc(pool,
+
sizeof(apr_proc_mutex_t));
+ (*pmutex)->pool = pool;
+ }
+#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE ||
APR_HAS_FLOCK_SERIALIZE
+ apr_os_file_put(&(*pmutex)->interproc, &ospmutex->crossproc, pool);
+#endif
+#if APR_HAS_PROC_PTHREAD_SERIALIZE
+ (*pmutex)->pthread_interproc = ospmutex->pthread_interproc;
+#endif
+ return APR_SUCCESS;
+}
+
1.3 +25 -0 apr/locks/win32/proc_mutex.c
Index: proc_mutex.c
===================================================================
RCS file: /home/cvs/apr/locks/win32/proc_mutex.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- proc_mutex.c 2001/09/29 05:03:37 1.2
+++ proc_mutex.c 2001/10/19 23:25:28 1.3
@@ -103,3 +103,28 @@
APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
+/* Implement OS-specific accessors defined in apr_portable.h */
+
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t
*ospmutex,
+ apr_proc_mutex_t *lock)
+{
+ *ospmutex = pmutex->mutex;
+ return APR_SUCCESS;
+}
+
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex,
+ apr_os_proc_mutex_t
*ospmutex,
+ apr_pool_t *pool)
+{
+ if (pool == NULL) {
+ return APR_ENOPOOL;
+ }
+ if ((*pmutex) == NULL) {
+ (*pmutex) = (apr_proc_mutex_t *)apr_palloc(pool,
+ sizeof(apr_proc_mutex_t));
+ (*pmutex)->pool = pool;
+ }
+ (*pmutex)->mutex = *ospmutex;
+ return APR_SUCCESS;
+}
+