From: Jim Jagielski Date: Tue, 24 Oct 2006 13:17:29 +0000 (+0000) Subject: Once SSLMutex allowed for the setting of both the X-Git-Tag: 2.3.0~2051 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=707d1dabb908ca954b4a5a11aa6f998d76b07499;p=thirdparty%2Fapache%2Fhttpd.git Once SSLMutex allowed for the setting of both the locking method and the lockfile location, I never liked how AcceptMutex was linked to LockFile. This seemed unnecessary. Much better to have AcceptMutex do both as well. Plus, now that we will likely see other modules require a "standard" way of setting mutexes, why not have Apache provide that as an API of sorts. Anyway, LockFile is now depreciated and AcceptMutex is now SSLMutex-like. We also provide a short function that "parses" out a mutex parameter and strips out the mechanism and lockfile location. AcceptMutex and SSLMutex is this capability. git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@467326 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/CHANGES b/CHANGES index 26deeeb095f..6679ac01246 100644 --- a/CHANGES +++ b/CHANGES @@ -2,6 +2,11 @@ Changes with Apache 2.3.0 [Remove entries to the current 2.0 and 2.2 section below, when backported] + *) The LockFile directive, which specifies the location of + the accept() mutex lockfile, is depreciated. Instead, the + AcceptMutex directive now takes an optional lockfile + location parameter, ala SSLMutex. [Jim Jagielski] + *) Fix address-in-use startup failure caused by corruption of the list of listen sockets in some configurations with multiple generic Listen directives. [Jeff Trawick] diff --git a/docs/manual/mod/mpm_common.xml b/docs/manual/mod/mpm_common.xml index e36a2f3518a..0f391dca648 100644 --- a/docs/manual/mod/mpm_common.xml +++ b/docs/manual/mod/mpm_common.xml @@ -40,7 +40,8 @@ accepting requests on network sockets

The AcceptMutex directives sets the - method that Apache uses to serialize multiple children accepting + method (and lockfile location if appropriate) that Apache uses to + serialize multiple children accepting requests on network sockets. Prior to Apache 2.0, the method was selectable only at compile time. The optimal method to use is highly architecture and platform dependent. For further details, @@ -55,25 +56,42 @@ accepting requests on network sockets listing the available methods.

-
flock
+
flock<:/path/to/lockfile>
uses the flock(2) system call to lock the - file defined by the LockFile directive.
+ file defined by the optional /path/to/lockfile + parameter. One can also use the LockFile directive to specify the lockfile, + although this is depreciated. -
fcntl
+
fcntl<:/path/to/lockfile>
uses the fcntl(2) system call to lock the - file defined by the LockFile directive.
+ file defined by the optional /path/to/lockfile + parameter. One can also use the LockFile directive to specify the lockfile, + although this is depreciated. + +
file<:/path/to/lockfile>
+
This directive tells the SSL Module to pick the "best" file locking + implementation available to it, choosing between fcntl and + flock, in that order. It is only available when the underlying + platform and APR supports at least one of the 2.
posixsem
uses POSIX compatible semaphores to implement the mutex.
+
sysvsem
+
uses SySV-style semaphores to implement the mutex.
+ +
sem
+
This directive tells the SSL Module to pick the "best" semaphore + implementation available to it, choosing between Posix and SystemV IPC, + in that order. It is only available when the underlying platform and + APR supports at least one of the 2.
+
pthread
uses POSIX mutexes as implemented by the POSIX Threads (PThreads) specification.
-
sysvsem
-
uses SySV-style semaphores to implement the mutex.

If you want to find out the compile time chosen default @@ -386,7 +404,7 @@ The protocol argument was added in 2.1.5 LockFile -Location of the accept serialization lock file +Location of the accept serialization lock file (depreciated) LockFile filename LockFile logs/accept.lock server config @@ -412,6 +430,13 @@ The protocol argument was added in 2.1.5 creating a lockfile with the same name as the one the server will try to create.

+ Depreciated +

This directive is depreciated. It is strongly suggested that + you use AcceptMutex to + specify both the mutex locking implementation as well as + the lockfile location.

+
+
AcceptMutex diff --git a/include/ap_mmn.h b/include/ap_mmn.h index 9153bfc5e5c..cf8a93b03cb 100644 --- a/include/ap_mmn.h +++ b/include/ap_mmn.h @@ -124,6 +124,9 @@ * 20060905.0 (2.3.0-dev) Replaced ap_get_server_version() with * ap_get_server_banner() and ap_get_server_description() * 20060905.1 (2.3.0-dev) Enable retry=0 for the worker (minor) + * 20060905.2 (2.3.0-dev) Added ap_all_available_mutexes_string, + * ap_available_mutexes_string and + * ap_parse_mutex() * */ diff --git a/include/mpm_common.h b/include/mpm_common.h index bc4480a792d..20a74ac6424 100644 --- a/include/mpm_common.h +++ b/include/mpm_common.h @@ -286,7 +286,6 @@ const char *ap_mpm_set_lockfile(cmd_parms *cmd, void *dummy, */ #ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH extern apr_lockmech_e ap_accept_lock_mech; -extern const char ap_valid_accept_mutex_string[]; const char *ap_mpm_set_accept_lock_mech(cmd_parms *cmd, void *dummy, const char *arg); #endif diff --git a/include/util_mutex.h b/include/util_mutex.h new file mode 100644 index 00000000000..1503800852c --- /dev/null +++ b/include/util_mutex.h @@ -0,0 +1,60 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/** + * @file util_mutex.h + * @brief Apache Mutex support library + * + * @defgroup APACHE_CORE_MUTEX Mutex Library + * @ingroup APACHE_CORE + * @{ + */ + +#ifndef UTIL_MUTEX_H +#define UTIL_MUTEX_H + +#include "httpd.h" +#include "apr_global_mutex.h" + +#ifdef __cplusplus +extern "C" { +#endif + +AP_DECLARE_DATA extern const char ap_available_mutexes_string[]; +AP_DECLARE_DATA extern const char ap_all_available_mutexes_string[]; + +/** + * Get Mutex config data and parse it + * @param arg The mutex config string + * @param pool The allocation pool + * @param mutexmech The APR mutex locking mechanism + * @param mutexfile The lockfile to use as required + * @return APR status code + * @deffunc apr_status_t ap_parse_mutex(const char *arg, apr_pool_t *pool, + apr_lockmech_e *mutexmech, + const char **mutexfile) + */ +AP_DECLARE(apr_status_t) ap_parse_mutex(const char *arg, apr_pool_t *pool, + apr_lockmech_e *mutexmech, + const char **mutexfile); + + +#ifdef __cplusplus +} +#endif + +#endif /* UTIL_MUTEX_H */ +/** @} */ diff --git a/modules/ssl/mod_ssl.c b/modules/ssl/mod_ssl.c index 8341e189c41..edf2dfbf76a 100644 --- a/modules/ssl/mod_ssl.c +++ b/modules/ssl/mod_ssl.c @@ -27,6 +27,7 @@ #include "ssl_private.h" #include "mod_ssl.h" #include "util_md5.h" +#include "util_mutex.h" #include /* @@ -47,36 +48,11 @@ #define AP_END_CMD { NULL } -const char ssl_valid_ssl_mutex_string[] = - "Valid SSLMutex mechanisms are: `none', `default'" -#if APR_HAS_FLOCK_SERIALIZE - ", `flock:/path/to/file'" -#endif -#if APR_HAS_FCNTL_SERIALIZE - ", `fcntl:/path/to/file'" -#endif -#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM) - ", `sysvsem'" -#endif -#if APR_HAS_POSIXSEM_SERIALIZE - ", `posixsem'" -#endif -#if APR_HAS_PROC_PTHREAD_SERIALIZE - ", `pthread'" -#endif -#if APR_HAS_FLOCK_SERIALIZE || APR_HAS_FCNTL_SERIALIZE - ", `file:/path/to/file'" -#endif -#if (APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)) || APR_HAS_POSIXSEM_SERIALIZE - ", `sem'" -#endif - " "; - static const command_rec ssl_config_cmds[] = { /* * Global (main-server) context configuration directives */ - SSL_CMD_SRV(Mutex, TAKE1, ssl_valid_ssl_mutex_string) + SSL_CMD_SRV(Mutex, TAKE1, ap_all_available_mutexes_string) SSL_CMD_SRV(PassPhraseDialog, TAKE1, "SSL dialog mechanism for the pass phrase query " "(`builtin', `|/path/to/pipe_program`, " diff --git a/modules/ssl/ssl_engine_config.c b/modules/ssl/ssl_engine_config.c index def65663895..12c28b87478 100644 --- a/modules/ssl/ssl_engine_config.c +++ b/modules/ssl/ssl_engine_config.c @@ -27,6 +27,7 @@ damned if you don't.'' -- Unknown */ #include "ssl_private.h" +#include "util_mutex.h" /* _________________________________________________________________ ** @@ -337,17 +338,9 @@ const char *ssl_cmd_SSLMutex(cmd_parms *cmd, void *dcfg, const char *arg_) { + apr_status_t rv; const char *err; SSLModConfigRec *mc = myModConfig(cmd->server); - /* Split arg_ into meth and file */ - char *meth = apr_pstrdup(cmd->temp_pool, arg_); - char *file = strchr(meth, ':'); - if (file) { - *(file++) = '\0'; - if (!*file) { - file = NULL; - } - } if ((err = ap_check_cmd_context(cmd, GLOBAL_ONLY))) { return err; @@ -356,72 +349,22 @@ const char *ssl_cmd_SSLMutex(cmd_parms *cmd, if (ssl_config_global_isfixed(mc)) { return NULL; } - if (!strcasecmp(meth, "none") || !strcasecmp(meth, "no")) { - mc->nMutexMode = SSL_MUTEXMODE_NONE; - return NULL; - } - /* APR determines temporary filename unless overridden below, - * we presume file indicates an szMutexFile is a file path - * unless the method sets szMutexFile=file and NULLs file - */ - mc->nMutexMode = SSL_MUTEXMODE_USED; - mc->szMutexFile = NULL; + rv = ap_parse_mutex(arg_, cmd->server->process->pool, + &mc->nMutexMech, &mc->szMutexFile); - /* NOTE: previously, 'yes' implied 'sem' */ - if (!strcasecmp(meth, "default") || !strcasecmp(meth, "yes")) { - mc->nMutexMech = APR_LOCK_DEFAULT; - } -#if APR_HAS_FCNTL_SERIALIZE - else if ((!strcasecmp(meth, "fcntl") || !strcasecmp(meth, "file")) && file) { - mc->nMutexMech = APR_LOCK_FCNTL; - } -#endif -#if APR_HAS_FLOCK_SERIALIZE - else if ((!strcasecmp(meth, "flock") || !strcasecmp(meth, "file")) && file) { - mc->nMutexMech = APR_LOCK_FLOCK; - } -#endif -#if APR_HAS_POSIXSEM_SERIALIZE - else if (!strcasecmp(meth, "posixsem") || !strcasecmp(meth, "sem")) { - mc->nMutexMech = APR_LOCK_POSIXSEM; - /* Posix/SysV semaphores aren't file based, use the literal name - * if provided and fall back on APR's default if not. Today, APR - * will ignore it, but once supported it has an absurdly short limit. - */ - if (file) { - mc->szMutexFile = apr_pstrdup(cmd->server->process->pool, file); - - file = NULL; - } - } -#endif -#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM) - else if (!strcasecmp(meth, "sysvsem") || !strcasecmp(meth, "sem")) { - mc->nMutexMech = APR_LOCK_SYSVSEM; - } -#endif -#if APR_HAS_PROC_PTHREAD_SERIALIZE - else if (!strcasecmp(meth, "pthread")) { - mc->nMutexMech = APR_LOCK_PROC_PTHREAD; - } -#endif - else { + if (rv == APR_ENOLOCK) { + mc->nMutexMode = SSL_MUTEXMODE_NONE; + return NULL; + } else if (rv == APR_ENOTIMPL) { return apr_pstrcat(cmd->pool, "Invalid SSLMutex argument ", arg_, - " (", ssl_valid_ssl_mutex_string, ")", NULL); + " (", ap_all_available_mutexes_string, ")", NULL); + } else if (rv == APR_BADARG) { + return apr_pstrcat(cmd->pool, "Invalid SSLMutex filepath ", + arg_, NULL); } - /* Unless the method above assumed responsibility for setting up - * mc->szMutexFile and NULLing out file, presume it is a file we - * are looking to use - */ - if (file) { - mc->szMutexFile = ap_server_root_relative(cmd->server->process->pool, file); - if (!mc->szMutexFile) { - return apr_pstrcat(cmd->pool, "Invalid SSLMutex ", meth, - ": filepath ", file, NULL); - } - } + mc->nMutexMode = SSL_MUTEXMODE_USED; return NULL; } diff --git a/modules/ssl/ssl_private.h b/modules/ssl/ssl_private.h index 6afc00afe27..75c5ff022a1 100644 --- a/modules/ssl/ssl_private.h +++ b/modules/ssl/ssl_private.h @@ -491,9 +491,6 @@ typedef struct { /** API glue structures */ extern module AP_MODULE_DECLARE_DATA ssl_module; -/** "global" stuff */ -extern const char ssl_valid_ssl_mutex_string[]; - /** configuration handling */ SSLModConfigRec *ssl_config_global_create(server_rec *); void ssl_config_global_fix(SSLModConfigRec *); diff --git a/server/Makefile.in b/server/Makefile.in index bd4f8fc79a6..0a64441abac 100644 --- a/server/Makefile.in +++ b/server/Makefile.in @@ -10,7 +10,7 @@ LTLIBRARY_SOURCES = \ test_char.h \ config.c log.c main.c vhost.c util.c \ util_script.c util_md5.c util_cfgtree.c util_ebcdic.c util_time.c \ - connection.c listen.c \ + connection.c listen.c util_mutex.c \ mpm_common.c util_charset.c util_debug.c util_xml.c \ util_filter.c util_pcre.c exports.c \ scoreboard.c error_bucket.c protocol.c core.c request.c provider.c \ diff --git a/server/core.c b/server/core.c index 24e14a42485..5f7d3241cd7 100644 --- a/server/core.c +++ b/server/core.c @@ -42,6 +42,7 @@ #include "apr_buckets.h" #include "util_filter.h" #include "util_ebcdic.h" +#include "util_mutex.h" #include "mpm.h" #include "mpm_common.h" #include "scoreboard.h" @@ -3322,7 +3323,7 @@ AP_INIT_TAKE1("ScoreBoardFile", ap_mpm_set_scoreboard, NULL, RSRC_CONF, #endif #ifdef AP_MPM_WANT_SET_LOCKFILE AP_INIT_TAKE1("LockFile", ap_mpm_set_lockfile, NULL, RSRC_CONF, - "The lockfile used when Apache needs to lock the accept() call"), + "The lockfile used when Apache needs to lock the accept() call (depreciated)"), #endif #ifdef AP_MPM_WANT_SET_MAX_REQUESTS AP_INIT_TAKE1("MaxRequestsPerChild", ap_mpm_set_max_requests, NULL, RSRC_CONF, @@ -3334,7 +3335,7 @@ AP_INIT_TAKE1("CoreDumpDirectory", ap_mpm_set_coredumpdir, NULL, RSRC_CONF, #endif #ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH AP_INIT_TAKE1("AcceptMutex", ap_mpm_set_accept_lock_mech, NULL, RSRC_CONF, - ap_valid_accept_mutex_string), + ap_available_mutexes_string), #endif #ifdef AP_MPM_WANT_SET_MAX_MEM_FREE AP_INIT_TAKE1("MaxMemFree", ap_mpm_set_max_mem_free, NULL, RSRC_CONF, diff --git a/server/mpm_common.c b/server/mpm_common.c index 26a74891031..ac85bb087be 100644 --- a/server/mpm_common.c +++ b/server/mpm_common.c @@ -44,6 +44,7 @@ #include "ap_mpm.h" #include "ap_listen.h" #include "mpm_default.h" +#include "util_mutex.h" #ifdef AP_MPM_WANT_SET_SCOREBOARD #include "scoreboard.h" @@ -810,72 +811,41 @@ const char * ap_mpm_set_graceful_shutdown(cmd_parms *cmd, void *dummy, #ifdef AP_MPM_WANT_SET_ACCEPT_LOCK_MECH apr_lockmech_e ap_accept_lock_mech = APR_LOCK_DEFAULT; -const char ap_valid_accept_mutex_string[] = - "Valid accept mutexes for this platform and MPM are: default" -#if APR_HAS_FLOCK_SERIALIZE - ", flock" -#endif -#if APR_HAS_FCNTL_SERIALIZE - ", fcntl" -#endif -#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM) - ", sysvsem" -#endif -#if APR_HAS_POSIXSEM_SERIALIZE - ", posixsem" -#endif -#if APR_HAS_PROC_PTHREAD_SERIALIZE - ", pthread" -#endif - "."; - AP_DECLARE(const char *) ap_mpm_set_accept_lock_mech(cmd_parms *cmd, void *dummy, const char *arg) { + apr_status_t rv; + const char *lockfile; const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY); if (err != NULL) { return err; } - if (!strcasecmp(arg, "default")) { - ap_accept_lock_mech = APR_LOCK_DEFAULT; - } -#if APR_HAS_FLOCK_SERIALIZE - else if (!strcasecmp(arg, "flock")) { - ap_accept_lock_mech = APR_LOCK_FLOCK; - } -#endif -#if APR_HAS_FCNTL_SERIALIZE - else if (!strcasecmp(arg, "fcntl")) { - ap_accept_lock_mech = APR_LOCK_FCNTL; + rv = ap_parse_mutex(arg, cmd->server->process->pool, + &ap_accept_lock_mech, &lockfile); + + if ((rv == APR_ENOTIMPL) || (rv == APR_ENOLOCK)) { + return apr_pstrcat(cmd->pool, "Invalid AcceptMutex argument ", arg, + " (", ap_available_mutexes_string, ")", NULL); + } else if (rv == APR_BADARG) { + return apr_pstrcat(cmd->pool, "Invalid AcceptMutex filepath ", + arg, NULL); } -#endif /* perchild can't use SysV sems because the permissions on the accept * mutex can't be set to allow all processes to use the mutex and * at the same time keep all users from being able to dink with the * mutex */ -#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM) - else if (!strcasecmp(arg, "sysvsem")) { - ap_accept_lock_mech = APR_LOCK_SYSVSEM; - } -#endif -#if APR_HAS_POSIXSEM_SERIALIZE - else if (!strcasecmp(arg, "posixsem")) { - ap_accept_lock_mech = APR_LOCK_POSIXSEM; +#if defined(PERCHILD_MPM) + if (ap_accept_lock_mech == APR_LOCK_SYSVSEM) { + return apr_pstrcat(cmd->pool, "Invalid AcceptMutex argument ", arg, + " (", ap_available_mutexes_string, ")", NULL); } #endif -#if APR_HAS_PROC_PTHREAD_SERIALIZE - else if (!strcasecmp(arg, "pthread")) { - ap_accept_lock_mech = APR_LOCK_PROC_PTHREAD; - } -#endif - else { - return apr_pstrcat(cmd->pool, arg, " is an invalid mutex mechanism; ", - ap_valid_accept_mutex_string, NULL); - } + if (lockfile && !ap_lock_fname) + ap_lock_fname = lockfile; return NULL; } diff --git a/server/util_mutex.c b/server/util_mutex.c new file mode 100644 index 00000000000..c8017b6ddce --- /dev/null +++ b/server/util_mutex.c @@ -0,0 +1,167 @@ +/* Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +/* + * util_mutex.c: Useful functions for determining allowable + * mutexes and mutex settings + */ + + +#include "apr.h" +#include "apr_strings.h" +#include "apr_lib.h" + +#define APR_WANT_STRFUNC +#include "apr_want.h" + +#define CORE_PRIVATE + +#include "ap_config.h" +#include "httpd.h" +#include "http_main.h" +#include "http_config.h" +#include "util_mutex.h" + +AP_DECLARE_DATA const char ap_all_available_mutexes_string[] = + "Mutex mechanisms are: `none', `default'" +#if APR_HAS_FLOCK_SERIALIZE + ", `flock:/path/to/file'" +#endif +#if APR_HAS_FCNTL_SERIALIZE + ", `fcntl:/path/to/file'" +#endif +#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM) + ", `sysvsem'" +#endif +#if APR_HAS_POSIXSEM_SERIALIZE + ", `posixsem'" +#endif +#if APR_HAS_PROC_PTHREAD_SERIALIZE + ", `pthread'" +#endif +#if APR_HAS_FLOCK_SERIALIZE || APR_HAS_FCNTL_SERIALIZE + ", `file:/path/to/file'" +#endif +#if (APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)) || APR_HAS_POSIXSEM_SERIALIZE + ", `sem'" +#endif + " "; + +AP_DECLARE_DATA const char ap_available_mutexes_string[] = + "Mutex mechanisms are: `default'" +#if APR_HAS_FLOCK_SERIALIZE + ", `flock:/path/to/file'" +#endif +#if APR_HAS_FCNTL_SERIALIZE + ", `fcntl:/path/to/file'" +#endif +#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM) + ", `sysvsem'" +#endif +#if APR_HAS_POSIXSEM_SERIALIZE + ", `posixsem'" +#endif +#if APR_HAS_PROC_PTHREAD_SERIALIZE + ", `pthread'" +#endif +#if APR_HAS_FLOCK_SERIALIZE || APR_HAS_FCNTL_SERIALIZE + ", `file:/path/to/file'" +#endif +#if (APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM)) || APR_HAS_POSIXSEM_SERIALIZE + ", `sem'" +#endif + " "; + + +AP_DECLARE(apr_status_t) ap_parse_mutex(const char *arg, apr_pool_t *pool, + apr_lockmech_e *mutexmech, + const char **mutexfile) +{ + /* Split arg into meth and file */ + char *meth = apr_pstrdup(pool, arg); + char *file = strchr(meth, ':'); + if (file) { + *(file++) = '\0'; + if (!*file) { + file = NULL; + } + } + + if (!strcasecmp(meth, "none") || !strcasecmp(meth, "no")) { + return APR_ENOLOCK; + } + + /* APR determines temporary filename unless overridden below, + * we presume file indicates an mutexfile is a file path + * unless the method sets mutexfile=file and NULLs file + */ + *mutexfile = NULL; + + /* NOTE: previously, 'yes' implied 'sem' */ + if (!strcasecmp(meth, "default") || !strcasecmp(meth, "yes")) { + *mutexmech = APR_LOCK_DEFAULT; + } +#if APR_HAS_FCNTL_SERIALIZE + else if (!strcasecmp(meth, "fcntl") || !strcasecmp(meth, "file")) { + *mutexmech = APR_LOCK_FCNTL; + } +#endif +#if APR_HAS_FLOCK_SERIALIZE + else if (!strcasecmp(meth, "flock") || !strcasecmp(meth, "file")) { + *mutexmech = APR_LOCK_FLOCK; + } +#endif +#if APR_HAS_POSIXSEM_SERIALIZE + else if (!strcasecmp(meth, "posixsem") || !strcasecmp(meth, "sem")) { + *mutexmech = APR_LOCK_POSIXSEM; + /* Posix/SysV semaphores aren't file based, use the literal name + * if provided and fall back on APR's default if not. Today, APR + * will ignore it, but once supported it has an absurdly short limit. + */ + if (file) { + *mutexfile = apr_pstrdup(pool, file); + + file = NULL; + } + } +#endif +#if APR_HAS_SYSVSEM_SERIALIZE && !defined(PERCHILD_MPM) + else if (!strcasecmp(meth, "sysvsem") || !strcasecmp(meth, "sem")) { + *mutexmech = APR_LOCK_SYSVSEM; + } +#endif +#if APR_HAS_PROC_PTHREAD_SERIALIZE + else if (!strcasecmp(meth, "pthread")) { + *mutexmech = APR_LOCK_PROC_PTHREAD; + } +#endif + else { + return APR_ENOTIMPL; + } + + /* Unless the method above assumed responsibility for setting up + * mutexfile and NULLing out file, presume it is a file we + * are looking to use + */ + if (file) { + *mutexfile = ap_server_root_relative(pool, file); + if (!*mutexfile) { + return APR_BADARG; + } + } + + return APR_SUCCESS; +}