]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - include/arch/unix/apr_arch_proc_mutex.h
Vendor import apr-1.6.5
[FreeBSD/FreeBSD.git] / include / arch / unix / apr_arch_proc_mutex.h
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
7  *
8  *     http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17 #ifndef PROC_MUTEX_H
18 #define PROC_MUTEX_H
19
20 #include "apr.h"
21 #include "apr_private.h"
22 #include "apr_general.h"
23 #include "apr_lib.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"
29
30 /* System headers required by Locks library */
31 #if APR_HAVE_SYS_TYPES_H
32 #include <sys/types.h>
33 #endif
34 #if APR_HAVE_STDIO_H
35 #include <stdio.h>
36 #endif
37 #if APR_HAVE_FCNTL_H
38 #include <fcntl.h>
39 #endif
40
41 #ifdef HAVE_SYS_IPC_H
42 #include <sys/ipc.h>
43 #endif
44 #ifdef HAVE_SYS_SEM_H
45 #include <sys/sem.h>
46 #endif
47 #ifdef HAVE_SYS_FILE_H
48 #include <sys/file.h>
49 #endif
50 #if APR_HAVE_STDLIB_H
51 #include <stdlib.h>
52 #endif
53 #if APR_HAVE_UNISTD_H
54 #include <unistd.h>
55 #endif
56 #if APR_HAVE_STRING_H
57 #include <string.h>
58 #endif
59 #ifdef HAVE_SYS_MMAN_H
60 #include <sys/mman.h>
61 #endif
62 #if APR_HAVE_PTHREAD_H
63 #include <pthread.h>
64 #endif
65 /* End System Headers */
66
67 struct apr_proc_mutex_unix_lock_methods_t {
68     unsigned int flags;
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);
76     apr_lockmech_e mech;
77     const char *name;
78 };
79 typedef struct apr_proc_mutex_unix_lock_methods_t apr_proc_mutex_unix_lock_methods_t;
80
81 /* bit values for flags field in apr_unix_lock_methods_t */
82 #define APR_PROCESS_LOCK_MECH_IS_GLOBAL          1
83
84 #if !APR_HAVE_UNION_SEMUN && defined(APR_HAS_SYSVSEM_SERIALIZE)
85 union semun {
86     int val;
87     struct semid_ds *buf;
88     unsigned short *array;
89 };
90 #endif
91
92 struct apr_proc_mutex_t {
93     apr_pool_t *pool;
94     const apr_proc_mutex_unix_lock_methods_t *meth;
95     int curr_locked;
96     char *fname;
97
98     apr_os_proc_mutex_t os;     /* Native mutex holder. */
99
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).
106                                  */
107 #endif
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.
112                                  */
113 #endif
114 };
115
116 void apr_proc_mutex_unix_setup_lock(void);
117
118 #endif  /* PROC_MUTEX_H */
119