summaryrefslogtreecommitdiff
path: root/locks
diff options
context:
space:
mode:
authorylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2016-04-13 12:05:21 +0000
committerylavic <ylavic@13f79535-47bb-0310-9956-ffa450edef68>2016-04-13 12:05:21 +0000
commit82f12569b1264eefeb2e34db5066f09071cb91cf (patch)
tree6be9240071885d527c138000bd7308b5dccdef61 /locks
parentf37bb67a27440528f6818f1795cf96cef9170e09 (diff)
downloadlibapr-82f12569b1264eefeb2e34db5066f09071cb91cf.tar.gz
Merge r1738925 from trunk:
apr_os_proc_mutex_put_ex: Allow to specify whether the OS native mutex should or not be cleaned up (destroyed) with the constructed APR mutex (given pool), and default to not for the simple _put() function. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/1.6.x@1738927 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'locks')
-rw-r--r--locks/beos/proc_mutex.c10
-rw-r--r--locks/netware/proc_mutex.c9
-rw-r--r--locks/os2/proc_mutex.c8
-rw-r--r--locks/unix/proc_mutex.c10
-rw-r--r--locks/win32/proc_mutex.c10
5 files changed, 42 insertions, 5 deletions
diff --git a/locks/beos/proc_mutex.c b/locks/beos/proc_mutex.c
index d5c681741..1b468714c 100644
--- a/locks/beos/proc_mutex.c
+++ b/locks/beos/proc_mutex.c
@@ -224,6 +224,7 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
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,
+ int register_cleanup,
apr_pool_t *pool)
{
if (pool == NULL) {
@@ -232,12 +233,18 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_put_ex(apr_proc_mutex_t **pmutex,
if (mech != APR_LOCK_DEFAULT && mech != APR_LOCK_DEFAULT_TIMED) {
return APR_ENOTIMPL;
}
+
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;
+
+ if (register_cleanup) {
+ apr_pool_cleanup_register(pool, *pmutex, _proc_mutex_cleanup,
+ apr_pool_cleanup_null);
+ }
return APR_SUCCESS;
}
@@ -245,6 +252,7 @@ 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_TIMED, pool);
+ return apr_os_proc_mutex_put_ex(pmutex, ospmutex, APR_LOCK_DEFAULT_TIMED,
+ 0, pool);
}
diff --git a/locks/netware/proc_mutex.c b/locks/netware/proc_mutex.c
index d5ff52201..52cd04bf9 100644
--- a/locks/netware/proc_mutex.c
+++ b/locks/netware/proc_mutex.c
@@ -156,6 +156,7 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
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,
+ int register_cleanup,
apr_pool_t *pool)
{
if (pool == NULL) {
@@ -175,6 +176,11 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_put_ex(apr_proc_mutex_t **pmutex,
(*pmutex)->mutex = apr_pcalloc(pool, sizeof(apr_thread_mutex_t));
(*pmutex)->mutex->mutex = *ospmutex;
(*pmutex)->mutex->pool = pool;
+
+ if (register_cleanup) {
+ apr_pool_cleanup_register(pool, *pmutex, apr_proc_mutex_cleanup,
+ apr_pool_cleanup_null);
+ }
return APR_SUCCESS;
#else
return APR_ENOTIMPL;
@@ -185,6 +191,7 @@ 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);
+ return apr_os_proc_mutex_put_ex(pmutex, ospmutex, APR_LOCK_DEFAULT,
+ 0, pool);
}
diff --git a/locks/os2/proc_mutex.c b/locks/os2/proc_mutex.c
index 83f64c848..847f775da 100644
--- a/locks/os2/proc_mutex.c
+++ b/locks/os2/proc_mutex.c
@@ -268,6 +268,7 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
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,
+ int register_cleanup,
apr_pool_t *pool)
{
apr_proc_mutex_t *new;
@@ -285,6 +286,10 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_put_ex(apr_proc_mutex_t **pmutex,
new->hMutex = *ospmutex;
*pmutex = new;
+ if (register_cleanup) {
+ apr_pool_cleanup_register(pool, *pmutex, apr_proc_mutex_cleanup,
+ apr_pool_cleanup_null);
+ }
return APR_SUCCESS;
}
@@ -292,6 +297,7 @@ 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_TIMED, pool);
+ return apr_os_proc_mutex_put_ex(pmutex, ospmutex, APR_LOCK_DEFAULT_TIMED,
+ 0, pool);
}
diff --git a/locks/unix/proc_mutex.c b/locks/unix/proc_mutex.c
index 06ea49327..b8bf8d897 100644
--- a/locks/unix/proc_mutex.c
+++ b/locks/unix/proc_mutex.c
@@ -1374,12 +1374,14 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
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,
+ int register_cleanup,
apr_pool_t *pool)
{
apr_status_t rv;
if (pool == NULL) {
return APR_ENOPOOL;
}
+
if ((*pmutex) == NULL) {
(*pmutex) = (apr_proc_mutex_t *)apr_pcalloc(pool,
sizeof(apr_proc_mutex_t));
@@ -1392,6 +1394,11 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_put_ex(apr_proc_mutex_t **pmutex,
0, pool);
}
#endif
+
+ if (rv == APR_SUCCESS && register_cleanup) {
+ apr_pool_cleanup_register(pool, *pmutex, apr_proc_mutex_cleanup,
+ apr_pool_cleanup_null);
+ }
return rv;
}
@@ -1399,6 +1406,7 @@ 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);
+ return apr_os_proc_mutex_put_ex(pmutex, ospmutex, APR_LOCK_DEFAULT,
+ 0, pool);
}
diff --git a/locks/win32/proc_mutex.c b/locks/win32/proc_mutex.c
index 83042ce35..9e227f762 100644
--- a/locks/win32/proc_mutex.c
+++ b/locks/win32/proc_mutex.c
@@ -265,6 +265,7 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
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,
+ int register_cleanup,
apr_pool_t *pool)
{
if (pool == NULL) {
@@ -273,12 +274,18 @@ APR_DECLARE(apr_status_t) apr_os_proc_mutex_put_ex(apr_proc_mutex_t **pmutex,
if (mech != APR_LOCK_DEFAULT && mech != APR_LOCK_DEFAULT_TIMED) {
return APR_ENOTIMPL;
}
+
if ((*pmutex) == NULL) {
(*pmutex) = (apr_proc_mutex_t *)apr_palloc(pool,
sizeof(apr_proc_mutex_t));
(*pmutex)->pool = pool;
}
(*pmutex)->handle = *ospmutex;
+
+ if (register_cleanup) {
+ apr_pool_cleanup_register(pool, *pmutex, proc_mutex_cleanup,
+ apr_pool_cleanup_null);
+ }
return APR_SUCCESS;
}
@@ -286,6 +293,7 @@ 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_TIMED, pool);
+ return apr_os_proc_mutex_put_ex(pmutex, ospmutex, APR_LOCK_DEFAULT_TIMED,
+ 0, pool);
}