GME  13
apr_arch_proc_mutex.h
Go to the documentation of this file.
00001 /* Licensed to the Apache Software Foundation (ASF) under one or more
00002  * contributor license agreements.  See the NOTICE file distributed with
00003  * this work for additional information regarding copyright ownership.
00004  * The ASF licenses this file to You under the Apache License, Version 2.0
00005  * (the "License"); you may not use this file except in compliance with
00006  * the License.  You may obtain a copy of the License at
00007  *
00008  *     http://www.apache.org/licenses/LICENSE-2.0
00009  *
00010  * Unless required by applicable law or agreed to in writing, software
00011  * distributed under the License is distributed on an "AS IS" BASIS,
00012  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00013  * See the License for the specific language governing permissions and
00014  * limitations under the License.
00015  */
00016 
00017 #ifndef PROC_MUTEX_H
00018 #define PROC_MUTEX_H
00019 
00020 #include "apr.h"
00021 #include "apr_private.h"
00022 #include "apr_general.h"
00023 #include "apr_lib.h"
00024 #include "apr_proc_mutex.h"
00025 #include "apr_pools.h"
00026 #include "apr_portable.h"
00027 #include "apr_file_io.h"
00028 #include "apr_arch_file_io.h"
00029 
00030 /* System headers required by Locks library */
00031 #if APR_HAVE_SYS_TYPES_H
00032 #include <sys/types.h>
00033 #endif
00034 #if APR_HAVE_STDIO_H
00035 #include <stdio.h>
00036 #endif
00037 #if APR_HAVE_FCNTL_H
00038 #include <fcntl.h>
00039 #endif
00040 
00041 #ifdef HAVE_SYS_IPC_H
00042 #include <sys/ipc.h>
00043 #endif
00044 #ifdef HAVE_SYS_SEM_H
00045 #include <sys/sem.h>
00046 #endif
00047 #ifdef HAVE_SYS_FILE_H
00048 #include <sys/file.h>
00049 #endif
00050 #if APR_HAVE_STDLIB_H
00051 #include <stdlib.h>
00052 #endif
00053 #if APR_HAVE_UNISTD_H
00054 #include <unistd.h>
00055 #endif
00056 #if APR_HAVE_STRING_H
00057 #include <string.h>
00058 #endif
00059 #ifdef HAVE_SYS_MMAN_H
00060 #include <sys/mman.h>
00061 #endif
00062 #if APR_HAVE_PTHREAD_H
00063 #include <pthread.h>
00064 #endif
00065 #if APR_HAVE_SEMAPHORE_H
00066 #include <semaphore.h>
00067 #endif
00068 /* End System Headers */
00069 
00070 struct apr_proc_mutex_unix_lock_methods_t {
00071     unsigned int flags;
00072     apr_status_t (*create)(apr_proc_mutex_t *, const char *);
00073     apr_status_t (*acquire)(apr_proc_mutex_t *);
00074     apr_status_t (*tryacquire)(apr_proc_mutex_t *);
00075     apr_status_t (*release)(apr_proc_mutex_t *);
00076     apr_status_t (*cleanup)(void *);
00077     apr_status_t (*child_init)(apr_proc_mutex_t **, apr_pool_t *, const char *);
00078     const char *name;
00079 };
00080 typedef struct apr_proc_mutex_unix_lock_methods_t apr_proc_mutex_unix_lock_methods_t;
00081 
00082 /* bit values for flags field in apr_unix_lock_methods_t */
00083 #define APR_PROCESS_LOCK_MECH_IS_GLOBAL          1
00084 
00085 #if !APR_HAVE_UNION_SEMUN && defined(APR_HAS_SYSVSEM_SERIALIZE)
00086 union semun {
00087     int val;
00088     struct semid_ds *buf;
00089     unsigned short *array;
00090 };
00091 #endif
00092 
00093 struct apr_proc_mutex_t {
00094     apr_pool_t *pool;
00095     const apr_proc_mutex_unix_lock_methods_t *meth;
00096     const apr_proc_mutex_unix_lock_methods_t *inter_meth;
00097     int curr_locked;
00098     char *fname;
00099 #if APR_HAS_SYSVSEM_SERIALIZE || APR_HAS_FCNTL_SERIALIZE || APR_HAS_FLOCK_SERIALIZE
00100     apr_file_t *interproc;
00101 #endif
00102 #if APR_HAS_POSIXSEM_SERIALIZE
00103     sem_t *psem_interproc;
00104 #endif
00105 #if APR_HAS_PROC_PTHREAD_SERIALIZE
00106     pthread_mutex_t *pthread_interproc;
00107 #endif
00108 };
00109 
00110 void apr_proc_mutex_unix_setup_lock(void);
00111 
00112 #endif  /* PROC_MUTEX_H */
00113