1 /* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include "apr_private.h"
19 #include "apr_portable.h"
20 #include "apr_arch_proc_mutex.h"
21 #include "apr_arch_thread_mutex.h"
23 APR_DECLARE(apr_status_t) apr_proc_mutex_create(apr_proc_mutex_t **mutex,
29 apr_proc_mutex_t *new_mutex = NULL;
30 new_mutex = (apr_proc_mutex_t *)apr_pcalloc(pool, sizeof(apr_proc_mutex_t));
32 if(new_mutex ==NULL) {
36 new_mutex->pool = pool;
37 ret = apr_thread_mutex_create(&(new_mutex->mutex), APR_THREAD_MUTEX_DEFAULT, pool);
39 if (ret == APR_SUCCESS)
45 APR_DECLARE(apr_status_t) apr_proc_mutex_child_init(apr_proc_mutex_t **mutex,
52 APR_DECLARE(apr_status_t) apr_proc_mutex_lock(apr_proc_mutex_t *mutex)
55 return apr_thread_mutex_lock(mutex->mutex);
59 APR_DECLARE(apr_status_t) apr_proc_mutex_trylock(apr_proc_mutex_t *mutex)
62 return apr_thread_mutex_trylock(mutex->mutex);
66 APR_DECLARE(apr_status_t) apr_proc_mutex_unlock(apr_proc_mutex_t *mutex)
69 return apr_thread_mutex_unlock(mutex->mutex);
73 APR_DECLARE(apr_status_t) apr_proc_mutex_cleanup(void *mutex)
75 return apr_proc_mutex_destroy(mutex);
78 APR_DECLARE(apr_status_t) apr_proc_mutex_destroy(apr_proc_mutex_t *mutex)
81 return apr_thread_mutex_destroy(mutex->mutex);
85 APR_DECLARE(const char *) apr_proc_mutex_lockfile(apr_proc_mutex_t *mutex)
90 APR_DECLARE(const char *) apr_proc_mutex_name(apr_proc_mutex_t *mutex)
92 return "netwarethread";
95 APR_DECLARE(const char *) apr_proc_mutex_defname(void)
97 return "netwarethread";
100 APR_POOL_IMPLEMENT_ACCESSOR(proc_mutex)
102 /* Implement OS-specific accessors defined in apr_portable.h */
104 apr_status_t apr_os_proc_mutex_get(apr_os_proc_mutex_t *ospmutex,
105 apr_proc_mutex_t *pmutex)
108 ospmutex = pmutex->mutex->mutex;
112 apr_status_t apr_os_proc_mutex_put(apr_proc_mutex_t **pmutex,
113 apr_os_proc_mutex_t *ospmutex,