summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CHANGES5
-rw-r--r--docs/manual/mod/mpm_common.xml45
-rw-r--r--include/ap_mmn.h3
-rw-r--r--include/mpm_common.h1
-rw-r--r--include/util_mutex.h60
-rw-r--r--modules/ssl/mod_ssl.c28
-rw-r--r--modules/ssl/ssl_engine_config.c83
-rw-r--r--modules/ssl/ssl_private.h3
-rw-r--r--server/Makefile.in2
-rw-r--r--server/core.c5
-rw-r--r--server/mpm_common.c66
-rw-r--r--server/util_mutex.c167
12 files changed, 307 insertions, 161 deletions
diff --git a/CHANGES b/CHANGES
index 26deeeb095..6679ac0124 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 e36a2f3518..0f391dca64 100644
--- a/docs/manual/mod/mpm_common.xml
+++ b/docs/manual/mod/mpm_common.xml
@@ -40,7 +40,8 @@ accepting requests on network sockets</description>
<usage>
<p>The <directive>AcceptMutex</directive> 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</description>
listing the available methods.</p>
<dl>
- <dt><code>flock</code></dt>
+ <dt><code>flock&lt;<i>:/path/to/lockfile</i>&gt;</code></dt>
<dd>uses the <code>flock(2)</code> system call to lock the
- file defined by the <directive module="mpm_common"
- >LockFile</directive> directive.</dd>
+ file defined by the optional <i>/path/to/lockfile</i>
+ parameter. One can also use the <directive module="mpm_common"
+ >LockFile</directive> directive to specify the lockfile,
+ although this is depreciated.</dd>
- <dt><code>fcntl</code></dt>
+ <dt><code>fcntl&lt;<i>:/path/to/lockfile</i>&gt;</code></dt>
<dd>uses the <code>fcntl(2)</code> system call to lock the
- file defined by the <directive module="mpm_common"
- >LockFile</directive> directive.</dd>
+ file defined by the optional <i>/path/to/lockfile</i>
+ parameter. One can also use the <directive module="mpm_common"
+ >LockFile</directive> directive to specify the lockfile,
+ although this is depreciated.</dd>
+
+ <dt><code>file&lt;<i>:/path/to/lockfile</i>&gt;</code></dt>
+ <dd>This directive tells the SSL Module to pick the "best" file locking
+ implementation available to it, choosing between <code>fcntl</code> and
+ <code>flock</code>, in that order. It is only available when the underlying
+ platform and <glossary>APR</glossary> supports at least one of the 2.</dd>
<dt><code>posixsem</code></dt>
<dd>uses POSIX compatible semaphores to implement the mutex.</dd>
+ <dt><code>sysvsem</code></dt>
+ <dd>uses SySV-style semaphores to implement the mutex.</dd>
+
+ <dt><code>sem</code></dt>
+ <dd>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
+ <glossary>APR</glossary> supports at least one of the 2.</dd>
+
<dt><code>pthread</code></dt>
<dd>uses POSIX mutexes as implemented by the POSIX Threads
(PThreads) specification.</dd>
- <dt><code>sysvsem</code></dt>
- <dd>uses SySV-style semaphores to implement the mutex.</dd>
</dl>
<p>If you want to find out the compile time chosen default
@@ -386,7 +404,7 @@ The <var>protocol</var> argument was added in 2.1.5</compatibility>
<directivesynopsis>
<name>LockFile</name>
-<description>Location of the accept serialization lock file</description>
+<description>Location of the accept serialization lock file <b>(depreciated)</b></description>
<syntax>LockFile <var>filename</var></syntax>
<default>LockFile logs/accept.lock</default>
<contextlist><context>server config</context></contextlist>
@@ -412,6 +430,13 @@ The <var>protocol</var> argument was added in 2.1.5</compatibility>
creating a lockfile with the same name as the one the server will try
to create.</p>
</note>
+ <note type="warning"><title>Depreciated</title>
+ <p>This directive is depreciated. It is strongly suggested that
+ you use <directive module="mpm_common">AcceptMutex</directive> to
+ specify both the mutex locking implementation as well as
+ the lockfile location.</p>
+ </note>
+
</usage>
<seealso><directive module="mpm_common">AcceptMutex</directive></seealso>
</directivesynopsis>
diff --git a/include/ap_mmn.h b/include/ap_mmn.h
index 9153bfc5e5..cf8a93b03c 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 bc4480a792..20a74ac642 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 0000000000..1503800852
--- /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 8341e189c4..edf2dfbf76 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 <assert.h>
/*
@@ -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 def6566389..12c28b8747 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 6afc00afe2..75c5ff022a 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 bd4f8fc79a..0a64441aba 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 24e14a4248..5f7d3241cd 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 26a7489103..ac85bb087b 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 0000000000..c8017b6ddc
--- /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;
+}