1
/* Copyright 2000-2005 The Apache Software Foundation or its licensors, as
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
* you may not use this file except in compliance with the License.
6
* 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.
21
#include "apr_private.h"
22
#include "apr_general.h"
24
#include "apr_proc_mutex.h"
25
#include "apr_pools.h"
26
#include "apr_portable.h"
27
#include "apr_file_io.h"
28
#include "apr_arch_file_io.h"
30
/* System headers required by Locks library */
31
#if APR_HAVE_SYS_TYPES_H
32
#include <sys/types.h>
47
#ifdef HAVE_SYS_FILE_H
59
#ifdef HAVE_SYS_MMAN_H
62
#if APR_HAVE_PTHREAD_H
65
#if APR_HAVE_SEMAPHORE_H
66
#include <semaphore.h>
68
/* End System Headers */
70
struct apr_proc_mutex_unix_lock_methods_t {
72
apr_status_t (*create)(apr_proc_mutex_t *, const char *);
73
apr_status_t (*acquire)(apr_proc_mutex_t *);
74
apr_status_t (*tryacquire)(apr_proc_mutex_t *);
75
apr_status_t (*release)(apr_proc_mutex_t *);
76
apr_status_t (*cleanup)(void *);
77
apr_status_t (*child_init)(apr_proc_mutex_t **, apr_pool_t *, const char *);
80
typedef struct apr_proc_mutex_unix_lock_methods_t apr_proc_mutex_unix_lock_methods_t;
82
/* bit values for flags field in apr_unix_lock_methods_t */
83
#define APR_PROCESS_LOCK_MECH_IS_GLOBAL 1
85
#if !APR_HAVE_UNION_SEMUN && defined(APR_HAS_SYSVSEM_SERIALIZE)
89
unsigned short *array;
93
struct apr_proc_mutex_t {
95
const apr_proc_mutex_unix_lock_methods_t *meth;
96
const apr_proc_mutex_unix_lock_methods_t *inter_meth;
99
#if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
100
apr_file_t *interproc;
102
#if APR_HAS_POSIXSEM_SERIALIZE
103
sem_t *psem_interproc;
105
#if APR_HAS_PROC_PTHREAD_SERIALIZE
106
pthread_mutex_t *pthread_interproc;
110
void apr_proc_mutex_unix_setup_lock(void);
112
#endif /* PROC_MUTEX_H */