util_mutex.c revision cc0bf3af983afd28b83699bb17f53225752e589d
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann/* Licensed to the Apache Software Foundation (ASF) under one or more
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * contributor license agreements. See the NOTICE file distributed with
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * this work for additional information regarding copyright ownership.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * The ASF licenses this file to You under the Apache License, Version 2.0
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * (the "License"); you may not use this file except in compliance with
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * the License. You may obtain a copy of the License at
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * http://www.apache.org/licenses/LICENSE-2.0
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * Unless required by applicable law or agreed to in writing, software
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * distributed under the License is distributed on an "AS IS" BASIS,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * See the License for the specific language governing permissions and
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * limitations under the License.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * util_mutex.c: Useful functions for determining allowable
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * mutexes and mutex settings
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannconst char AP_DECLARE_DATA ap_all_available_mutexes_string[] =
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann "Mutex mechanisms are: `none', `default'"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ", `sysvsem'"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ", `posixsem'"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ", `pthread'"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#if APR_HAS_FLOCK_SERIALIZE || APR_HAS_FCNTL_SERIALIZE
5476ad087c0f2d45ab0dab1bab9ef3e9d70418bcMarcel Holtmann#if (APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)) || APR_HAS_POSIXSEM_SERIALIZE
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmannconst char AP_DECLARE_DATA ap_available_mutexes_string[] =
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann "Mutex mechanisms are: `default'"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ", `sysvsem'"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ", `posixsem'"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann ", `pthread'"
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#if APR_HAS_FLOCK_SERIALIZE || APR_HAS_FCNTL_SERIALIZE
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#if (APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)) || APR_HAS_POSIXSEM_SERIALIZE
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel HoltmannAP_DECLARE(apr_status_t) ap_parse_mutex(const char *arg, apr_pool_t *pool,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Split arg into meth and file */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann if (!strcasecmp(meth, "none") || !strcasecmp(meth, "no")) {
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* APR determines temporary filename unless overridden below,
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * we presume file indicates an mutexfile is a file path
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * unless the method sets mutexfile=file and NULLs file
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* NOTE: previously, 'yes' implied 'sem' */
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann if (!strcasecmp(meth, "default") || !strcasecmp(meth, "yes")) {
7cfa80f07e94c3e48703d145ef03a73dd6e7b983Marcel Holtmann else if (!strcasecmp(meth, "fcntl") || !strcasecmp(meth, "file")) {
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann else if (!strcasecmp(meth, "flock") || !strcasecmp(meth, "file")) {
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann else if (!strcasecmp(meth, "posixsem") || !strcasecmp(meth, "sem")) {
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Posix/SysV semaphores aren't file based, use the literal name
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * if provided and fall back on APR's default if not. Today, APR
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * will ignore it, but once supported it has an absurdly short limit.
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann else if (!strcasecmp(meth, "sysvsem") || !strcasecmp(meth, "sem")) {
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann /* Unless the method above assumed responsibility for setting up
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * mutexfile and NULLing out file, presume it is a file we
94f5bbc626f2a4102debd9b17c964170a887cb49Marcel Holtmann * are looking to use