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.
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 /* End System Headers */
67 struct apr_proc_mutex_unix_lock_methods_t {
69 apr_status_t (*create)(apr_proc_mutex_t *, const char *);
70 apr_status_t (*acquire)(apr_proc_mutex_t *);
71 apr_status_t (*tryacquire)(apr_proc_mutex_t *);
72 apr_status_t (*release)(apr_proc_mutex_t *);
73 apr_status_t (*cleanup)(void *);
74 apr_status_t (*child_init)(apr_proc_mutex_t **, apr_pool_t *, const char *);
75 apr_status_t (*perms_set)(apr_proc_mutex_t *, apr_fileperms_t, apr_uid_t, apr_gid_t);
79 typedef struct apr_proc_mutex_unix_lock_methods_t apr_proc_mutex_unix_lock_methods_t;
81 /* bit values for flags field in apr_unix_lock_methods_t */
82 #define APR_PROCESS_LOCK_MECH_IS_GLOBAL 1
84 #if !APR_HAVE_UNION_SEMUN && defined(APR_HAS_SYSVSEM_SERIALIZE)
88 unsigned short *array;
92 struct apr_proc_mutex_t {
94 const apr_proc_mutex_unix_lock_methods_t *meth;
98 apr_os_proc_mutex_t os; /* Native mutex holder. */
100 #if APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
101 apr_file_t *interproc; /* For apr_file_ calls on native fd. */
102 int interproc_closing; /* whether the native fd is opened/closed with
103 * 'interproc' or apr_os_file_put()ed (hence
104 * needing an an explicit close for consistency
105 * with other methods).
108 #if APR_HAS_PROC_PTHREAD_SERIALIZE
109 int pthread_refcounting; /* Whether the native mutex is refcounted or
110 * apr_os_proc_mutex_put()ed, which makes
111 * refcounting impossible/undesirable.
116 void apr_proc_mutex_unix_setup_lock(void);
118 #endif /* PROC_MUTEX_H */