summaryrefslogtreecommitdiff
path: root/locks/netware
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2016-03-06 00:19:51 +0000
committerYann Ylavic <ylavic@apache.org>2016-03-06 00:19:51 +0000
commit4374120da1da5fefd2a1865868a698cc416f83c3 (patch)
tree976669566fec3c84f71506cbd1797ee26f8ab426 /locks/netware
parentace1569206bf502316ad17a0514b9c25daca59f1 (diff)
downloadapr-4374120da1da5fefd2a1865868a698cc416f83c3.tar.gz
apr_proc/global_mutex: Fix API regarding the native OS mutexes
accessors from/to available APR mechanisms, adding the new functions apr_os_proc_mutex_get_ex() and apr_os_proc_mutex_set_ex() which give control to the user over the selected mechanisms, including the missing POSIX semaphores (sem_t) on platforms supporting them. For POSIX sems, this moves the "sem_t *psem_interproc;" member from struct apr_proc_mutex_t to apr_os_proc_mutex_t (now complete) so that we can avoid members duplication between the two structs, and hence replace all the doublons in apr_os_proc_mutex_t with an apr_os_proc_mutex_t member, called "os", to be used for runtime. This first commit aims to be backportable to 1.6.x, thus does not address the Netware case which requires an incompatible change of the apr_proc_mutex_t to a pointer type (the implementation is here since very similar to other changes is this commit, but it is commented out for now, a simple follow up is coming with the type change for trunk only...). git-svn-id: https://svn.apache.org/repos/asf/apr/apr/trunk@1733775 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'locks/netware')
-rw-r--r--locks/netware/proc_mutex.c68
1 files changed, 60 insertions, 8 deletions
diff --git a/locks/netware/proc_mutex.c b/locks/netware/proc_mutex.c
index 4217b1cf0..04b7672f9 100644
--- a/locks/netware/proc_mutex.c
+++ b/locks/netware/proc_mutex.c
@@ -105,6 +105,11 @@ APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex)
return NULL;
}
+APR_DECLARE(apr_lockmech_e) apr_proc_mutex_mech(apr_proc_mutex_t *mutex)
+{
+ return APR_LOCK_DEFAULT;
+}
+
APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex)
{
return "netwarethread";
@@ -121,18 +126,65 @@ 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)
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_get_ex(apr_os_proc_mutex_t *ospmutex,
+ apr_proc_mutex_t *pmutex,
+ apr_lockmech_e *mech)
{
- if (pmutex)
- ospmutex = pmutex->mutex->mutex;
- return APR_ENOLOCK;
+#if 1
+ /* We need to change apr_os_proc_mutex_t to a pointer type
+ * to be able to implement this function.
+ */
+ return APR_ENOTIMPL;
+#else
+ if (!pmutex->mutex) {
+ return APR_ENOLOCK;
+ }
+ *ospmutex = pmutex->mutex->mutex;
+ if (mech) {
+ *mech = APR_LOCK_DEFAULT;
+ }
+ return APR_SUCCESS;
+#endif
+}
+
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
+ apr_proc_mutex_t *pmutex)
+{
+ return apr_os_proc_mutex_get_ex(ospmutex, pmutex, NULL);
}
-apr_status_t apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex,
- apr_os_proc_mutex_t *ospmutex,
- apr_pool_t *pool)
+APR_DECLARE(apr_status_t) apr_os_proc_mutex_put_ex(apr_proc_mutex_t **pmutex,
+ apr_os_proc_mutex_t *ospmutex,
+ apr_lockmech_e mech,
+ apr_pool_t *pool)
{
+ if (pool == NULL) {
+ return APR_ENOPOOL;
+ }
+ if (mech != APR_LOCK_DEFAULT) {
+ return APR_ENOTIMPL;
+ }
+#if 1
+ /* We need to change apr_os_proc_mutex_t to a pointer type
+ * to be able to implement this function.
+ */
return APR_ENOTIMPL;
+#else
+ if ((*pmutex) == NULL) {
+ (*pmutex) = apr_pcalloc(pool, sizeof(apr_proc_mutex_t));
+ (*pmutex)->pool = pool;
+ }
+ (*pmutex)->mutex = apr_pcalloc(pool, sizeof(apr_thread_mutex_t));
+ (*pmutex)->mutex->mutex = *ospmutex;
+ (*pmutex)->mutex->pool = pool;
+ return APR_SUCCESS;
+#endif
+}
+
+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)
+{
+ return apr_os_proc_mutex_put_ex(pmutex, ospmutex, APR_LOCK_DEFAULT, pool);
}