feat:replace boost library with C++11 std library
This commit is contained in:
+204
@@ -0,0 +1,204 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apr.h"
|
||||
|
||||
#include "apr_strings.h"
|
||||
#include "apr_arch_global_mutex.h"
|
||||
#include "apr_proc_mutex.h"
|
||||
#include "apr_thread_mutex.h"
|
||||
#include "apr_portable.h"
|
||||
|
||||
static apr_status_t global_mutex_cleanup(void *data)
|
||||
{
|
||||
apr_global_mutex_t *m = (apr_global_mutex_t *)data;
|
||||
apr_status_t rv;
|
||||
|
||||
rv = apr_proc_mutex_destroy(m->proc_mutex);
|
||||
|
||||
#if APR_HAS_THREADS
|
||||
if (m->thread_mutex) {
|
||||
if (rv != APR_SUCCESS) {
|
||||
(void)apr_thread_mutex_destroy(m->thread_mutex);
|
||||
}
|
||||
else {
|
||||
rv = apr_thread_mutex_destroy(m->thread_mutex);
|
||||
}
|
||||
}
|
||||
#endif /* APR_HAS_THREADS */
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_global_mutex_create(apr_global_mutex_t **mutex,
|
||||
const char *fname,
|
||||
apr_lockmech_e mech,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
apr_status_t rv;
|
||||
apr_global_mutex_t *m;
|
||||
|
||||
m = (apr_global_mutex_t *)apr_palloc(pool, sizeof(*m));
|
||||
m->pool = pool;
|
||||
|
||||
rv = apr_proc_mutex_create(&m->proc_mutex, fname, mech, m->pool);
|
||||
if (rv != APR_SUCCESS) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if APR_HAS_THREADS
|
||||
if (m->proc_mutex->meth->flags & APR_PROCESS_LOCK_MECH_IS_GLOBAL) {
|
||||
m->thread_mutex = NULL; /* We don't need a thread lock. */
|
||||
}
|
||||
else {
|
||||
rv = apr_thread_mutex_create(&m->thread_mutex,
|
||||
APR_THREAD_MUTEX_DEFAULT, m->pool);
|
||||
if (rv != APR_SUCCESS) {
|
||||
rv = apr_proc_mutex_destroy(m->proc_mutex);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
#endif /* APR_HAS_THREADS */
|
||||
|
||||
apr_pool_cleanup_register(m->pool, (void *)m,
|
||||
global_mutex_cleanup, apr_pool_cleanup_null);
|
||||
*mutex = m;
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_global_mutex_child_init(
|
||||
apr_global_mutex_t **mutex,
|
||||
const char *fname,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
apr_status_t rv;
|
||||
|
||||
rv = apr_proc_mutex_child_init(&((*mutex)->proc_mutex), fname, pool);
|
||||
return rv;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_global_mutex_lock(apr_global_mutex_t *mutex)
|
||||
{
|
||||
apr_status_t rv;
|
||||
|
||||
#if APR_HAS_THREADS
|
||||
if (mutex->thread_mutex) {
|
||||
rv = apr_thread_mutex_lock(mutex->thread_mutex);
|
||||
if (rv != APR_SUCCESS) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
#endif /* APR_HAS_THREADS */
|
||||
|
||||
rv = apr_proc_mutex_lock(mutex->proc_mutex);
|
||||
|
||||
#if APR_HAS_THREADS
|
||||
if (rv != APR_SUCCESS) {
|
||||
if (mutex->thread_mutex) {
|
||||
(void)apr_thread_mutex_unlock(mutex->thread_mutex);
|
||||
}
|
||||
}
|
||||
#endif /* APR_HAS_THREADS */
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_global_mutex_trylock(apr_global_mutex_t *mutex)
|
||||
{
|
||||
apr_status_t rv;
|
||||
|
||||
#if APR_HAS_THREADS
|
||||
if (mutex->thread_mutex) {
|
||||
rv = apr_thread_mutex_trylock(mutex->thread_mutex);
|
||||
if (rv != APR_SUCCESS) {
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
#endif /* APR_HAS_THREADS */
|
||||
|
||||
rv = apr_proc_mutex_trylock(mutex->proc_mutex);
|
||||
|
||||
#if APR_HAS_THREADS
|
||||
if (rv != APR_SUCCESS) {
|
||||
if (mutex->thread_mutex) {
|
||||
(void)apr_thread_mutex_unlock(mutex->thread_mutex);
|
||||
}
|
||||
}
|
||||
#endif /* APR_HAS_THREADS */
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_global_mutex_unlock(apr_global_mutex_t *mutex)
|
||||
{
|
||||
apr_status_t rv;
|
||||
|
||||
rv = apr_proc_mutex_unlock(mutex->proc_mutex);
|
||||
#if APR_HAS_THREADS
|
||||
if (mutex->thread_mutex) {
|
||||
if (rv != APR_SUCCESS) {
|
||||
(void)apr_thread_mutex_unlock(mutex->thread_mutex);
|
||||
}
|
||||
else {
|
||||
rv = apr_thread_mutex_unlock(mutex->thread_mutex);
|
||||
}
|
||||
}
|
||||
#endif /* APR_HAS_THREADS */
|
||||
return rv;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_os_global_mutex_get(apr_os_global_mutex_t *ospmutex,
|
||||
apr_global_mutex_t *pmutex)
|
||||
{
|
||||
ospmutex->pool = pmutex->pool;
|
||||
ospmutex->proc_mutex = pmutex->proc_mutex;
|
||||
#if APR_HAS_THREADS
|
||||
ospmutex->thread_mutex = pmutex->thread_mutex;
|
||||
#endif
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_global_mutex_destroy(apr_global_mutex_t *mutex)
|
||||
{
|
||||
return apr_pool_cleanup_run(mutex->pool, mutex, global_mutex_cleanup);
|
||||
}
|
||||
|
||||
APR_DECLARE(const char *) apr_global_mutex_lockfile(apr_global_mutex_t *mutex)
|
||||
{
|
||||
return apr_proc_mutex_lockfile(mutex->proc_mutex);
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_lockmech_e) apr_global_mutex_mech(apr_global_mutex_t *mutex)
|
||||
{
|
||||
return apr_proc_mutex_mech(mutex->proc_mutex);
|
||||
}
|
||||
|
||||
APR_DECLARE(const char *) apr_global_mutex_name(apr_global_mutex_t *mutex)
|
||||
{
|
||||
return apr_proc_mutex_name(mutex->proc_mutex);
|
||||
}
|
||||
|
||||
APR_PERMS_SET_IMPLEMENT(global_mutex)
|
||||
{
|
||||
apr_status_t rv;
|
||||
apr_global_mutex_t *mutex = (apr_global_mutex_t *)theglobal_mutex;
|
||||
|
||||
rv = APR_PERMS_SET_FN(proc_mutex)(mutex->proc_mutex, perms, uid, gid);
|
||||
return rv;
|
||||
}
|
||||
|
||||
APR_POOL_IMPLEMENT_ACCESSOR(global_mutex)
|
||||
|
||||
+1261
File diff suppressed because it is too large
Load Diff
+135
@@ -0,0 +1,135 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apr.h"
|
||||
|
||||
#if APR_HAS_THREADS
|
||||
|
||||
#include "apr_arch_thread_mutex.h"
|
||||
#include "apr_arch_thread_cond.h"
|
||||
|
||||
static apr_status_t thread_cond_cleanup(void *data)
|
||||
{
|
||||
apr_thread_cond_t *cond = (apr_thread_cond_t *)data;
|
||||
apr_status_t rv;
|
||||
|
||||
rv = pthread_cond_destroy(&cond->cond);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (rv) {
|
||||
rv = errno;
|
||||
}
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_cond_create(apr_thread_cond_t **cond,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
apr_thread_cond_t *new_cond;
|
||||
apr_status_t rv;
|
||||
|
||||
new_cond = apr_palloc(pool, sizeof(apr_thread_cond_t));
|
||||
|
||||
new_cond->pool = pool;
|
||||
|
||||
if ((rv = pthread_cond_init(&new_cond->cond, NULL))) {
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
rv = errno;
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
apr_pool_cleanup_register(new_cond->pool,
|
||||
(void *)new_cond, thread_cond_cleanup,
|
||||
apr_pool_cleanup_null);
|
||||
|
||||
*cond = new_cond;
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_cond_wait(apr_thread_cond_t *cond,
|
||||
apr_thread_mutex_t *mutex)
|
||||
{
|
||||
apr_status_t rv;
|
||||
|
||||
rv = pthread_cond_wait(&cond->cond, &mutex->mutex);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (rv) {
|
||||
rv = errno;
|
||||
}
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_cond_timedwait(apr_thread_cond_t *cond,
|
||||
apr_thread_mutex_t *mutex,
|
||||
apr_interval_time_t timeout)
|
||||
{
|
||||
apr_status_t rv;
|
||||
apr_time_t then;
|
||||
struct timespec abstime;
|
||||
|
||||
then = apr_time_now() + timeout;
|
||||
abstime.tv_sec = apr_time_sec(then);
|
||||
abstime.tv_nsec = apr_time_usec(then) * 1000; /* nanoseconds */
|
||||
|
||||
rv = pthread_cond_timedwait(&cond->cond, &mutex->mutex, &abstime);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (rv) {
|
||||
rv = errno;
|
||||
}
|
||||
#endif
|
||||
if (ETIMEDOUT == rv) {
|
||||
return APR_TIMEUP;
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_cond_signal(apr_thread_cond_t *cond)
|
||||
{
|
||||
apr_status_t rv;
|
||||
|
||||
rv = pthread_cond_signal(&cond->cond);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (rv) {
|
||||
rv = errno;
|
||||
}
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_cond_broadcast(apr_thread_cond_t *cond)
|
||||
{
|
||||
apr_status_t rv;
|
||||
|
||||
rv = pthread_cond_broadcast(&cond->cond);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (rv) {
|
||||
rv = errno;
|
||||
}
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_cond_destroy(apr_thread_cond_t *cond)
|
||||
{
|
||||
return apr_pool_cleanup_run(cond->pool, cond, thread_cond_cleanup);
|
||||
}
|
||||
|
||||
APR_POOL_IMPLEMENT_ACCESSOR(thread_cond)
|
||||
|
||||
#endif /* APR_HAS_THREADS */
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apr_arch_thread_mutex.h"
|
||||
#define APR_WANT_MEMFUNC
|
||||
#include "apr_want.h"
|
||||
|
||||
#if APR_HAS_THREADS
|
||||
|
||||
static apr_status_t thread_mutex_cleanup(void *data)
|
||||
{
|
||||
apr_thread_mutex_t *mutex = data;
|
||||
apr_status_t rv;
|
||||
|
||||
rv = pthread_mutex_destroy(&mutex->mutex);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (rv) {
|
||||
rv = errno;
|
||||
}
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_mutex_create(apr_thread_mutex_t **mutex,
|
||||
unsigned int flags,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
apr_thread_mutex_t *new_mutex;
|
||||
apr_status_t rv;
|
||||
|
||||
#ifndef HAVE_PTHREAD_MUTEX_RECURSIVE
|
||||
if (flags & APR_THREAD_MUTEX_NESTED) {
|
||||
return APR_ENOTIMPL;
|
||||
}
|
||||
#endif
|
||||
|
||||
new_mutex = apr_pcalloc(pool, sizeof(apr_thread_mutex_t));
|
||||
new_mutex->pool = pool;
|
||||
|
||||
#ifdef HAVE_PTHREAD_MUTEX_RECURSIVE
|
||||
if (flags & APR_THREAD_MUTEX_NESTED) {
|
||||
pthread_mutexattr_t mattr;
|
||||
|
||||
rv = pthread_mutexattr_init(&mattr);
|
||||
if (rv) return rv;
|
||||
|
||||
rv = pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
|
||||
if (rv) {
|
||||
pthread_mutexattr_destroy(&mattr);
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = pthread_mutex_init(&new_mutex->mutex, &mattr);
|
||||
|
||||
pthread_mutexattr_destroy(&mattr);
|
||||
} else
|
||||
#endif
|
||||
rv = pthread_mutex_init(&new_mutex->mutex, NULL);
|
||||
|
||||
if (rv) {
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
rv = errno;
|
||||
#endif
|
||||
return rv;
|
||||
}
|
||||
|
||||
apr_pool_cleanup_register(new_mutex->pool,
|
||||
new_mutex, thread_mutex_cleanup,
|
||||
apr_pool_cleanup_null);
|
||||
|
||||
*mutex = new_mutex;
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_mutex_lock(apr_thread_mutex_t *mutex)
|
||||
{
|
||||
apr_status_t rv;
|
||||
|
||||
rv = pthread_mutex_lock(&mutex->mutex);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (rv) {
|
||||
rv = errno;
|
||||
}
|
||||
#endif
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_mutex_trylock(apr_thread_mutex_t *mutex)
|
||||
{
|
||||
apr_status_t rv;
|
||||
|
||||
rv = pthread_mutex_trylock(&mutex->mutex);
|
||||
if (rv) {
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
rv = errno;
|
||||
#endif
|
||||
return (rv == EBUSY) ? APR_EBUSY : rv;
|
||||
}
|
||||
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_mutex_unlock(apr_thread_mutex_t *mutex)
|
||||
{
|
||||
apr_status_t status;
|
||||
|
||||
status = pthread_mutex_unlock(&mutex->mutex);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (status) {
|
||||
status = errno;
|
||||
}
|
||||
#endif
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_mutex_destroy(apr_thread_mutex_t *mutex)
|
||||
{
|
||||
return apr_pool_cleanup_run(mutex->pool, mutex, thread_mutex_cleanup);
|
||||
}
|
||||
|
||||
APR_POOL_IMPLEMENT_ACCESSOR(thread_mutex)
|
||||
|
||||
#endif /* APR_HAS_THREADS */
|
||||
@@ -0,0 +1,181 @@
|
||||
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apr_arch_thread_rwlock.h"
|
||||
#include "apr_private.h"
|
||||
|
||||
#if APR_HAS_THREADS
|
||||
|
||||
#ifdef HAVE_PTHREAD_RWLOCKS
|
||||
|
||||
/* The rwlock must be initialized but not locked by any thread when
|
||||
* cleanup is called. */
|
||||
static apr_status_t thread_rwlock_cleanup(void *data)
|
||||
{
|
||||
apr_thread_rwlock_t *rwlock = (apr_thread_rwlock_t *)data;
|
||||
apr_status_t stat;
|
||||
|
||||
stat = pthread_rwlock_destroy(&rwlock->rwlock);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (stat) {
|
||||
stat = errno;
|
||||
}
|
||||
#endif
|
||||
return stat;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
apr_thread_rwlock_t *new_rwlock;
|
||||
apr_status_t stat;
|
||||
|
||||
new_rwlock = apr_palloc(pool, sizeof(apr_thread_rwlock_t));
|
||||
new_rwlock->pool = pool;
|
||||
|
||||
if ((stat = pthread_rwlock_init(&new_rwlock->rwlock, NULL))) {
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
stat = errno;
|
||||
#endif
|
||||
return stat;
|
||||
}
|
||||
|
||||
apr_pool_cleanup_register(new_rwlock->pool,
|
||||
(void *)new_rwlock, thread_rwlock_cleanup,
|
||||
apr_pool_cleanup_null);
|
||||
|
||||
*rwlock = new_rwlock;
|
||||
return APR_SUCCESS;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock)
|
||||
{
|
||||
apr_status_t stat;
|
||||
|
||||
stat = pthread_rwlock_rdlock(&rwlock->rwlock);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (stat) {
|
||||
stat = errno;
|
||||
}
|
||||
#endif
|
||||
return stat;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock)
|
||||
{
|
||||
apr_status_t stat;
|
||||
|
||||
stat = pthread_rwlock_tryrdlock(&rwlock->rwlock);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (stat) {
|
||||
stat = errno;
|
||||
}
|
||||
#endif
|
||||
/* Normalize the return code. */
|
||||
if (stat == EBUSY)
|
||||
stat = APR_EBUSY;
|
||||
return stat;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock)
|
||||
{
|
||||
apr_status_t stat;
|
||||
|
||||
stat = pthread_rwlock_wrlock(&rwlock->rwlock);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (stat) {
|
||||
stat = errno;
|
||||
}
|
||||
#endif
|
||||
return stat;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock)
|
||||
{
|
||||
apr_status_t stat;
|
||||
|
||||
stat = pthread_rwlock_trywrlock(&rwlock->rwlock);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (stat) {
|
||||
stat = errno;
|
||||
}
|
||||
#endif
|
||||
/* Normalize the return code. */
|
||||
if (stat == EBUSY)
|
||||
stat = APR_EBUSY;
|
||||
return stat;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock)
|
||||
{
|
||||
apr_status_t stat;
|
||||
|
||||
stat = pthread_rwlock_unlock(&rwlock->rwlock);
|
||||
#ifdef HAVE_ZOS_PTHREADS
|
||||
if (stat) {
|
||||
stat = errno;
|
||||
}
|
||||
#endif
|
||||
return stat;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock)
|
||||
{
|
||||
return apr_pool_cleanup_run(rwlock->pool, rwlock, thread_rwlock_cleanup);
|
||||
}
|
||||
|
||||
#else /* HAVE_PTHREAD_RWLOCKS */
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_create(apr_thread_rwlock_t **rwlock,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
return APR_ENOTIMPL;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_rdlock(apr_thread_rwlock_t *rwlock)
|
||||
{
|
||||
return APR_ENOTIMPL;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_tryrdlock(apr_thread_rwlock_t *rwlock)
|
||||
{
|
||||
return APR_ENOTIMPL;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_wrlock(apr_thread_rwlock_t *rwlock)
|
||||
{
|
||||
return APR_ENOTIMPL;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_trywrlock(apr_thread_rwlock_t *rwlock)
|
||||
{
|
||||
return APR_ENOTIMPL;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_unlock(apr_thread_rwlock_t *rwlock)
|
||||
{
|
||||
return APR_ENOTIMPL;
|
||||
}
|
||||
|
||||
APR_DECLARE(apr_status_t) apr_thread_rwlock_destroy(apr_thread_rwlock_t *rwlock)
|
||||
{
|
||||
return APR_ENOTIMPL;
|
||||
}
|
||||
|
||||
#endif /* HAVE_PTHREAD_RWLOCKS */
|
||||
APR_POOL_IMPLEMENT_ACCESSOR(thread_rwlock)
|
||||
|
||||
#endif /* APR_HAS_THREADS */
|
||||
Reference in New Issue
Block a user