httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject svn commit: r467326 - in /httpd/httpd/trunk: ./ docs/manual/mod/ include/ modules/ssl/ server/
Date Tue, 24 Oct 2006 13:17:31 GMT
Author: jim
Date: Tue Oct 24 06:17:29 2006
New Revision: 467326

URL: http://svn.apache.org/viewvc?view=rev&rev=467326
Log:
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.


Added:
    httpd/httpd/trunk/include/util_mutex.h   (with props)
    httpd/httpd/trunk/server/util_mutex.c   (with props)
Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/docs/manual/mod/mpm_common.xml
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/mpm_common.h
    httpd/httpd/trunk/modules/ssl/mod_ssl.c
    httpd/httpd/trunk/modules/ssl/ssl_engine_config.c
    httpd/httpd/trunk/modules/ssl/ssl_private.h
    httpd/httpd/trunk/server/Makefile.in
    httpd/httpd/trunk/server/core.c
    httpd/httpd/trunk/server/mpm_common.c

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?view=diff&rev=467326&r1=467325&r2=467326
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Tue Oct 24 06:17:29 2006
@@ -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]

Modified: httpd/httpd/trunk/docs/manual/mod/mpm_common.xml
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/manual/mod/mpm_common.xml?view=diff&rev=467326&r1=467325&r2=467326
==============================================================================
--- httpd/httpd/trunk/docs/manual/mod/mpm_common.xml (original)
+++ httpd/httpd/trunk/docs/manual/mod/mpm_common.xml Tue Oct 24 06:17:29 2006
@@ -40,7 +40,8 @@
 
 <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 @@
     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 @@
 
 <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 @@
       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>

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?view=diff&rev=467326&r1=467325&r2=467326
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Tue Oct 24 06:17:29 2006
@@ -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()
  *
  */
 

Modified: httpd/httpd/trunk/include/mpm_common.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/mpm_common.h?view=diff&rev=467326&r1=467325&r2=467326
==============================================================================
--- httpd/httpd/trunk/include/mpm_common.h (original)
+++ httpd/httpd/trunk/include/mpm_common.h Tue Oct 24 06:17:29 2006
@@ -286,7 +286,6 @@
  */
 #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

Added: httpd/httpd/trunk/include/util_mutex.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/util_mutex.h?view=auto&rev=467326
==============================================================================
--- httpd/httpd/trunk/include/util_mutex.h (added)
+++ httpd/httpd/trunk/include/util_mutex.h Tue Oct 24 06:17:29 2006
@@ -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 */
+/** @} */

Propchange: httpd/httpd/trunk/include/util_mutex.h
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: httpd/httpd/trunk/modules/ssl/mod_ssl.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/mod_ssl.c?view=diff&rev=467326&r1=467325&r2=467326
==============================================================================
--- httpd/httpd/trunk/modules/ssl/mod_ssl.c (original)
+++ httpd/httpd/trunk/modules/ssl/mod_ssl.c Tue Oct 24 06:17:29 2006
@@ -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`, "

Modified: httpd/httpd/trunk/modules/ssl/ssl_engine_config.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_engine_config.c?view=diff&rev=467326&r1=467325&r2=467326
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_engine_config.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_engine_config.c Tue Oct 24 06:17:29 2006
@@ -27,6 +27,7 @@
                                            damned if you don't.''
                                                -- Unknown        */
 #include "ssl_private.h"
+#include "util_mutex.h"
 
 /*  _________________________________________________________________
 **
@@ -337,17 +338,9 @@
                              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 @@
     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;
 
-    /* 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);
+    rv = ap_parse_mutex(arg_, cmd->server->process->pool,
+                        &mc->nMutexMech, &mc->szMutexFile);
 
-            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;
 }

Modified: httpd/httpd/trunk/modules/ssl/ssl_private.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_private.h?view=diff&rev=467326&r1=467325&r2=467326
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_private.h (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_private.h Tue Oct 24 06:17:29 2006
@@ -491,9 +491,6 @@
 /**  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 *);

Modified: httpd/httpd/trunk/server/Makefile.in
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/Makefile.in?view=diff&rev=467326&r1=467325&r2=467326
==============================================================================
--- httpd/httpd/trunk/server/Makefile.in (original)
+++ httpd/httpd/trunk/server/Makefile.in Tue Oct 24 06:17:29 2006
@@ -10,7 +10,7 @@
     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 \

Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?view=diff&rev=467326&r1=467325&r2=467326
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Tue Oct 24 06:17:29 2006
@@ -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 @@
 #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 @@
 #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,

Modified: httpd/httpd/trunk/server/mpm_common.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_common.c?view=diff&rev=467326&r1=467325&r2=467326
==============================================================================
--- httpd/httpd/trunk/server/mpm_common.c (original)
+++ httpd/httpd/trunk/server/mpm_common.c Tue Oct 24 06:17:29 2006
@@ -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 @@
 #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;
 }
 

Added: httpd/httpd/trunk/server/util_mutex.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_mutex.c?view=auto&rev=467326
==============================================================================
--- httpd/httpd/trunk/server/util_mutex.c (added)
+++ httpd/httpd/trunk/server/util_mutex.c Tue Oct 24 06:17:29 2006
@@ -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;
+}

Propchange: httpd/httpd/trunk/server/util_mutex.c
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message