httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject svn commit: r883540 - in /httpd/httpd/trunk: ./ build/ docs/conf/ docs/conf/extra/ include/ modules/aaa/ modules/core/ modules/examples/ modules/generators/ modules/ldap/ modules/mappers/ modules/ssl/ server/ server/mpm/prefork/ server/mpm/worker/ test/
Date Mon, 23 Nov 2009 23:17:54 GMT
Author: trawick
Date: Mon Nov 23 23:17:51 2009
New Revision: 883540

URL: http://svn.apache.org/viewvc?rev=883540&view=rev
Log:
Replace AcceptMutex, LockFile, RewriteLock, SSLMutex, SSLStaplingMutex,
and WatchdogMutexPath with a single Mutex directive.  Add APIs to
simplify setup and user customization of APR proc and global mutexes.  
(See util_mutex.h.)  Build-time setting DEFAULT_LOCKFILE is no longer
respected; set DEFAULT_REL_RUNTIMEDIR instead.

Some existing modules, such as mod_ldap and mod_auth_digest gain 
configurability for their mutexes.

Modified:
    httpd/httpd/trunk/CHANGES
    httpd/httpd/trunk/build/mkconfNW.awk
    httpd/httpd/trunk/docs/conf/extra/httpd-mpm.conf.in
    httpd/httpd/trunk/docs/conf/extra/httpd-ssl.conf.in
    httpd/httpd/trunk/docs/conf/httpd.conf.in
    httpd/httpd/trunk/include/ap_mmn.h
    httpd/httpd/trunk/include/ap_slotmem.h
    httpd/httpd/trunk/include/mpm_common.h
    httpd/httpd/trunk/include/util_ldap.h
    httpd/httpd/trunk/include/util_mutex.h
    httpd/httpd/trunk/modules/aaa/mod_auth_digest.c
    httpd/httpd/trunk/modules/core/mod_watchdog.c
    httpd/httpd/trunk/modules/core/mod_watchdog.h
    httpd/httpd/trunk/modules/examples/mod_example_ipc.c
    httpd/httpd/trunk/modules/generators/mod_info.c
    httpd/httpd/trunk/modules/ldap/util_ldap.c
    httpd/httpd/trunk/modules/mappers/mod_rewrite.c
    httpd/httpd/trunk/modules/ssl/mod_ssl.c
    httpd/httpd/trunk/modules/ssl/ssl_engine_config.c
    httpd/httpd/trunk/modules/ssl/ssl_engine_mutex.c
    httpd/httpd/trunk/modules/ssl/ssl_private.h
    httpd/httpd/trunk/modules/ssl/ssl_util_stapling.c
    httpd/httpd/trunk/server/core.c
    httpd/httpd/trunk/server/main.c
    httpd/httpd/trunk/server/mpm/prefork/mpm_default.h
    httpd/httpd/trunk/server/mpm/prefork/prefork.c
    httpd/httpd/trunk/server/mpm/worker/mpm_default.h
    httpd/httpd/trunk/server/mpm/worker/worker.c
    httpd/httpd/trunk/server/mpm_common.c
    httpd/httpd/trunk/server/util_mutex.c
    httpd/httpd/trunk/test/make_sni.sh

Modified: httpd/httpd/trunk/CHANGES
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/CHANGES?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/CHANGES [utf-8] (original)
+++ httpd/httpd/trunk/CHANGES [utf-8] Mon Nov 23 23:17:51 2009
@@ -10,6 +10,12 @@
      mod_proxy_ftp: NULL pointer dereference on error paths.
      [Stefan Fritsch <sf fritsch.de>, Joe Orton]
 
+  *) Replace AcceptMutex, LockFile, RewriteLock, SSLMutex, SSLStaplingMutex,
+     and WatchdogMutexPath with a single Mutex directive.  Add APIs to
+     simplify setup and user customization of APR proc and global mutexes.  
+     (See util_mutex.h.)  Build-time setting DEFAULT_LOCKFILE is no longer
+     respected; set DEFAULT_REL_RUNTIMEDIR instead.  [Jeff Trawick]
+
   *) http_core: KeepAlive no longer accepts other than On|Off.
      [Takashi Sato]
 

Modified: httpd/httpd/trunk/build/mkconfNW.awk
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/build/mkconfNW.awk?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/build/mkconfNW.awk (original)
+++ httpd/httpd/trunk/build/mkconfNW.awk Mon Nov 23 23:17:51 2009
@@ -100,8 +100,8 @@
     sub(/^SSLSessionCache/, "#SSLSessionCache")
 }
 
-match ($0,/^SSLMutex +"file:@exp_runtimedir@\/ssl_mutex"/) {
-    sub(/"file:@exp_runtimedir@\/ssl_mutex"/, "default")
+match ($0,/^Mutex +"file:@rel_runtimedir@"/) {
+    sub(/"file:@rel_runtimedir@"/, "default")
 }
 
 match ($0,/@@.*@@/) {

Modified: httpd/httpd/trunk/docs/conf/extra/httpd-mpm.conf.in
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/extra/httpd-mpm.conf.in?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/conf/extra/httpd-mpm.conf.in (original)
+++ httpd/httpd/trunk/docs/conf/extra/httpd-mpm.conf.in Mon Nov 23 23:17:51 2009
@@ -13,20 +13,6 @@
 </IfModule>
 
 #
-# The accept serialization lock file MUST BE STORED ON A LOCAL DISK.
-#
-<IfModule !mpm_simple_module>
-<IfModule !mpm_winnt_module>
-<IfModule !mpm_netware_module>
-<IfModule !mpm_mpmt_os2_module>
-LockFile "@rel_logfiledir@/accept.lock"
-</IfModule>
-</IfModule>
-</IfModule>
-</IfModule>
-
-
-#
 # Only one of the below sections will be relevant on your
 # installed httpd.  Use "apachectl -l" to find out the
 # active mpm.

Modified: httpd/httpd/trunk/docs/conf/extra/httpd-ssl.conf.in
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/extra/httpd-ssl.conf.in?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/conf/extra/httpd-ssl.conf.in (original)
+++ httpd/httpd/trunk/docs/conf/extra/httpd-ssl.conf.in Mon Nov 23 23:17:51 2009
@@ -56,11 +56,6 @@
 SSLSessionCache        "shmcb:@exp_runtimedir@/ssl_scache(512000)"
 SSLSessionCacheTimeout  300
 
-#   Semaphore:
-#   Configure the path to the mutual exclusion semaphore the
-#   SSL engine uses internally for inter-process synchronization. 
-SSLMutex  "file:@exp_runtimedir@/ssl_mutex"
-
 ##
 ## SSL Virtual Host Context
 ##

Modified: httpd/httpd/trunk/docs/conf/httpd.conf.in
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/docs/conf/httpd.conf.in?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/docs/conf/httpd.conf.in (original)
+++ httpd/httpd/trunk/docs/conf/httpd.conf.in Mon Nov 23 23:17:51 2009
@@ -22,13 +22,23 @@
 # configuration, error, and log files are kept.
 #
 # Do not add a slash at the end of the directory path.  If you point
-# ServerRoot at a non-local disk, be sure to point the LockFile directive
-# at a local disk.  If you wish to share the same ServerRoot for multiple
-# httpd daemons, you will need to change at least LockFile and PidFile.
+# ServerRoot at a non-local disk, be sure to specify a local disk on the
+# Mutex directive, if file-based mutexes are used.  If you wish to share the
+# same ServerRoot for multiple httpd daemons, you will need to change at
+# least PidFile.
 #
 ServerRoot "@@ServerRoot@@"
 
 #
+# Mutex: Allows you to set the mutex mechanism and mutex file directory
+# for individual mutexes, or change the global defaults
+#
+# Uncomment only if mutexes are file-based and the default mutex file
+# directory is not appropriate.
+#
+# Mutex default file:@rel_runtimedir@
+
+#
 # Listen: Allows you to bind Apache to specific IP addresses and/or
 # ports, instead of the default. See also the <VirtualHost>
 # directive.

Modified: httpd/httpd/trunk/include/ap_mmn.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_mmn.h?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_mmn.h (original)
+++ httpd/httpd/trunk/include/ap_mmn.h Mon Nov 23 23:17:51 2009
@@ -205,6 +205,7 @@
  * 20091011.1 (2.3.3-dev)  add debug_level to util_ldap_state_t
  * 20091031.0 (2.3.3-dev)  remove public LDAP referral-related macros
  * 20091119.0 (2.3.4-dev)  dav_error interface uses apr_status_t parm, not errno
+ * 20091119.1 (2.3.4-dev)  ap_mutex_register(), ap_{proc,global}_mutex_create()
  *
  */
 
@@ -213,7 +214,7 @@
 #ifndef MODULE_MAGIC_NUMBER_MAJOR
 #define MODULE_MAGIC_NUMBER_MAJOR 20091119
 #endif
-#define MODULE_MAGIC_NUMBER_MINOR 0                     /* 0...n */
+#define MODULE_MAGIC_NUMBER_MINOR 1                     /* 0...n */
 
 /**
  * Determine if the server's current MODULE_MAGIC_NUMBER is at least a

Modified: httpd/httpd/trunk/include/ap_slotmem.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/ap_slotmem.h?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/include/ap_slotmem.h (original)
+++ httpd/httpd/trunk/include/ap_slotmem.h Mon Nov 23 23:17:51 2009
@@ -40,10 +40,6 @@
 #include "apr_global_mutex.h"
 #include "apr_file_io.h"
 
-#ifdef AP_NEED_SET_MUTEX_PERMS
-#include "unixd.h"
-#endif
-
 #if APR_HAVE_UNISTD_H
 #include <unistd.h>         /* for getpid() */
 #endif

Modified: httpd/httpd/trunk/include/mpm_common.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/mpm_common.h?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/include/mpm_common.h (original)
+++ httpd/httpd/trunk/include/mpm_common.h Mon Nov 23 23:17:51 2009
@@ -264,20 +264,6 @@
 const char *ap_mpm_set_pidfile(cmd_parms *cmd, void *dummy,
                                const char *arg);
 
-/**
- * The name of lockfile used when Apache needs to lock the accept() call.
- */
-extern const char *ap_lock_fname;
-const char *ap_mpm_set_lockfile(cmd_parms *cmd, void *dummy,
-                                const char *arg);
-
-/**
- * The system mutex implementation to use for the accept mutex.
- */
-extern apr_lockmech_e ap_accept_lock_mech;
-const char *ap_mpm_set_accept_lock_mech(cmd_parms *cmd, void *dummy,
-                                        const char *arg);
-
 /*
  * Set the scorboard file.
  */
@@ -347,6 +333,11 @@
 /* get MPM name (e.g., "prefork" or "event") */
 AP_DECLARE_HOOK(const char *,mpm_get_name,(void))
 
+/* mutex type string for accept mutex, if any; MPMs should use the
+ * same mutex type for ease of configuration
+ */
+#define ap_accept_mutex_type "mpm-accept"
+
 #ifdef __cplusplus
 }
 #endif

Modified: httpd/httpd/trunk/include/util_ldap.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/util_ldap.h?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/include/util_ldap.h (original)
+++ httpd/httpd/trunk/include/util_ldap.h Mon Nov 23 23:17:51 2009
@@ -156,7 +156,6 @@
 
     /* cache ald */
     void *util_ldap_cache;
-    char *lock_file;           /* filename for shm lock mutex */
     long  connectionTimeout;
     int   verify_svr_cert;
     int debug_level;                    /* SDK debug level */

Modified: httpd/httpd/trunk/include/util_mutex.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/include/util_mutex.h?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/include/util_mutex.h (original)
+++ httpd/httpd/trunk/include/util_mutex.h Mon Nov 23 23:17:51 2009
@@ -98,6 +98,110 @@
                                         apr_lockmech_e *mutexmech,
                                         const char **mutexfile);
 
+/* private function to process the Mutex directive */
+AP_DECLARE(const char *) ap_set_mutex(cmd_parms *cmd, void *dummy,
+                                      const char *typelist,
+                                      const char *mechfile);
+
+/**
+ * option flags for ap_mutex_register(), ap_global_mutex_create(), and
+ * ap_proc_mutex_create()
+ */
+#define AP_MUTEX_ALLOW_NONE    1 /* allow "none" as mutex implementation;
+                                  * respected only on ap_mutex_register()
+                                  */
+#define AP_MUTEX_DEFAULT_NONE  2 /* default to "none" for this mutex;
+                                  * respected only on ap_mutex_register()
+                                  */
+
+/**
+ * Register a module's mutex type with core to allow configuration
+ * with the Mutex directive.  This must be called in the pre_config
+ * hook; otherwise, configuration directives referencing this mutex
+ * type will be rejected.
+ *
+ * The default_dir and default_mech parameters allow a module to set
+ * defaults for the lock file directory and mechanism.  These could
+ * be based on compile-time settings.  These aren't required except
+ * in special circumstances.
+ *
+ * The order of precedence for the choice of mechanism and lock file
+ * directory is:
+ *
+ *   1. Mutex directive specifically for this mutex
+ *      e.g., Mutex mpm-default flock:/tmp/mpmlocks
+ *   2. Mutex directive for global default
+ *      e.g., Mutex default flock:/tmp/httpdlocks
+ *   3. Defaults for this mutex provided on the ap_mutex_register()
+ *   4. Built-in defaults for all mutexes, which are
+ *      APR_LOCK_DEFAULT and DEFAULT_REL_RUNTIMEDIR.
+ *
+ * @param pconf The pconf pool
+ * @param type The type name of the mutex, used as the basename of the
+ * file associated with the mutex, if any.  This must be unique among
+ * all mutex types (mutex creation accommodates multi-instance mutex
+ * types); mod_foo might have mutex  types "foo-pipe" and "foo-shm"
+ * @param default_dir Default dir for any lock file required for this
+ * lock, to override built-in defaults; should be NULL for most
+ * modules, to respect built-in defaults
+ * @param default_mech Default mechanism for this lock, to override
+ * built-in defaults; should be APR_LOCK_DEFAULT for most modules, to
+ * respect built-in defaults
+ * or NULL if there are no defaults for this mutex.
+ * @param options combination of AP_MUTEX_* constants, or 0 for defaults
+ */
+AP_DECLARE(apr_status_t) ap_mutex_register(apr_pool_t *pconf,
+                                           const char *type,
+                                           const char *default_dir,
+                                           apr_lockmech_e default_mech,
+                                           apr_int32_t options);
+
+/**
+ * Create an APR global mutex that has been registered previously with
+ * ap_mutex_register().  Mutex files, permissions, and error logging will
+ * be handled internally.
+ * @param mutex The memory address where the newly created mutex will be
+ * stored.  If this mutex is disabled, mutex will be set to NULL on
+ * output.  (That is allowed only if the AP_MUTEX_ALLOW_NONE flag is
+ * passed to ap_mutex_register().)
+ * @param type The type name of the mutex, matching the type name passed
+ * to ap_mutex_register().
+ * @param instance_id A unique string to be used in the lock filename IFF
+ * this mutex type is multi-instance, NULL otherwise.
+ * @param s server_rec of main server
+ * @param pconf pool
+ * @param options combination of AP_MUTEX_* constants, or 0 for defaults
+ * (currently none are defined for this function)
+ */
+AP_DECLARE(apr_status_t) ap_global_mutex_create(apr_global_mutex_t **mutex,
+                                                const char *type,
+                                                const char *instance_id,
+                                                server_rec *s,
+                                                apr_pool_t *pconf,
+                                                apr_int32_t options);
+
+/**
+ * Create an APR proc mutex that has been registered previously with
+ * ap_mutex_register().  Mutex files, permissions, and error logging will
+ * be handled internally.
+ * @param mutex The memory address where the newly created mutex will be
+ * stored.  If this mutex is disabled, mutex will be set to NULL on
+ * output.  (That is allowed only if the AP_MUTEX_ALLOW_NONE flag is
+ * passed to ap_mutex_register().)
+ * @param type The type name of the mutex, matching the type name passed
+ * to ap_mutex_register().
+ * @param instance_id A unique string to be used in the lock filename IFF
+ * this mutex type is multi-instance, NULL otherwise.
+ * @param s server_rec of main server
+ * @param pconf pool
+ * @param options combination of AP_MUTEX_* constants, or 0 for defaults
+ * (currently none are defined for this function)
+ */
+AP_DECLARE(apr_status_t) ap_proc_mutex_create(apr_proc_mutex_t **mutex,
+                                              const char *type,
+                                              const char *instance_id,
+                                              server_rec *s, apr_pool_t *p,
+                                              apr_int32_t options);
 
 #ifdef __cplusplus
 }

Modified: httpd/httpd/trunk/modules/aaa/mod_auth_digest.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/aaa/mod_auth_digest.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/aaa/mod_auth_digest.c (original)
+++ httpd/httpd/trunk/modules/aaa/mod_auth_digest.c Mon Nov 23 23:17:51 2009
@@ -74,6 +74,7 @@
 #include "http_protocol.h"
 #include "apr_uri.h"
 #include "util_md5.h"
+#include "util_mutex.h"
 #include "apr_shm.h"
 #include "apr_rmm.h"
 #include "ap_provider.h"
@@ -179,8 +180,8 @@
 static apr_time_t     *otn_counter;     /* one-time-nonce counter */
 static apr_global_mutex_t *client_lock = NULL;
 static apr_global_mutex_t *opaque_lock = NULL;
-static const char     *client_lock_name;
-static const char     *opaque_lock_name;
+static const char     *client_lock_type = "authdigest-client";
+static const char     *opaque_lock_type = "authdigest-opaque";
 static const char     *client_shm_filename;
 
 #define DEF_SHMEM_SIZE  1000L           /* ~ 12 entries */
@@ -321,12 +322,7 @@
     client_list->tbl_len     = num_buckets;
     client_list->num_entries = 0;
 
-    client_lock_name = apr_psprintf(ctx, "%s/authdigest_lock.%"APR_PID_T_FMT, tempdir, 
-                                    getpid());
-    /* FIXME: get the client_lock_name from a directive so we're portable
-     * to non-process-inheriting operating systems, like Win32. */
-    sts = apr_global_mutex_create(&client_lock, client_lock_name,
-                                  APR_LOCK_DEFAULT, ctx);
+    sts = ap_global_mutex_create(&client_lock, client_lock_type, NULL, s, ctx, 0);
     if (sts != APR_SUCCESS) {
         log_error_and_cleanup("failed to create lock (client_lock)", sts, s);
         return !OK;
@@ -342,11 +338,7 @@
     }
     *opaque_cntr = 1UL;
 
-    opaque_lock_name = apr_psprintf(ctx, "%s/authdigest_opaque_lock.%"APR_PID_T_FMT,
-                                    tempdir, 
-                                    getpid());
-    sts = apr_global_mutex_create(&opaque_lock, opaque_lock_name,
-                                  APR_LOCK_DEFAULT, ctx);
+    sts = ap_global_mutex_create(&opaque_lock, opaque_lock_type, NULL, s, ctx, 0);
     if (sts != APR_SUCCESS) {
         log_error_and_cleanup("failed to create lock (opaque_lock)", sts, s);
         return !OK;
@@ -370,6 +362,21 @@
 
 #endif /* APR_HAS_SHARED_MEMORY */
 
+static int pre_init(apr_pool_t *pconf, apr_pool_t *plog, apr_pool_t *ptemp)
+{
+    apr_status_t rv;
+
+    rv = ap_mutex_register(pconf, client_lock_type, NULL, APR_LOCK_DEFAULT, 0);
+    if (rv == APR_SUCCESS) {
+        rv = ap_mutex_register(pconf, opaque_lock_type, NULL, APR_LOCK_DEFAULT,
+                               0);
+    }
+    if (rv != APR_SUCCESS) {
+        return rv;
+    }
+
+    return OK;
+}
 
 static int initialize_module(apr_pool_t *p, apr_pool_t *plog,
                              apr_pool_t *ptemp, server_rec *s)
@@ -428,12 +435,16 @@
         return;
     }
 
-    sts = apr_global_mutex_child_init(&client_lock, client_lock_name, p);
+    sts = apr_global_mutex_child_init(&client_lock,
+                                      apr_global_mutex_lockfile(client_lock),
+                                      p);
     if (sts != APR_SUCCESS) {
         log_error_and_cleanup("failed to create lock (client_lock)", sts, s);
         return;
     }
-    sts = apr_global_mutex_child_init(&opaque_lock, opaque_lock_name, p);
+    sts = apr_global_mutex_child_init(&opaque_lock,
+                                      apr_global_mutex_lockfile(opaque_lock),
+                                      p);
     if (sts != APR_SUCCESS) {
         log_error_and_cleanup("failed to create lock (opaque_lock)", sts, s);
         return;
@@ -2033,6 +2044,7 @@
     static const char * const cfgPost[]={ "http_core.c", NULL };
     static const char * const parsePre[]={ "mod_proxy.c", NULL };
 
+    ap_hook_pre_config(pre_init, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_post_config(initialize_module, NULL, cfgPost, APR_HOOK_MIDDLE);
     ap_hook_child_init(initialize_child, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_post_read_request(parse_hdr_and_update_nc, parsePre, NULL, APR_HOOK_MIDDLE);

Modified: httpd/httpd/trunk/modules/core/mod_watchdog.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/core/mod_watchdog.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/core/mod_watchdog.c (original)
+++ httpd/httpd/trunk/modules/core/mod_watchdog.c Mon Nov 23 23:17:51 2009
@@ -20,10 +20,7 @@
 #include "mod_watchdog.h"
 #include "ap_provider.h"
 #include "ap_mpm.h"
-
-#ifdef AP_NEED_SET_MUTEX_PERMS
-#include "unixd.h"
-#endif
+#include "util_mutex.h"
 
 #define AP_WATCHODG_PGROUP    "watchdog"
 #define AP_WATCHODG_PVERSION  "parent"
@@ -46,7 +43,6 @@
 {
     apr_thread_mutex_t   *startup;
     apr_proc_mutex_t     *mutex;
-    const char           *mutex_path;
     const char           *name;
     watchdog_list_t      *callbacks;
     int                   is_running;
@@ -66,11 +62,11 @@
     server_rec *s;
 };
 
-static char *wd_mutex_path = NULL;
 static wd_server_conf_t *wd_server_conf = NULL;
 static apr_interval_time_t wd_interval = AP_WD_TM_INTERVAL;
 static int wd_interval_set = 0;
 static int mpm_is_forked = AP_MPMQ_NOT_SUPPORTED;
+static const char *wd_proc_mutex_type = "wd-proc";
 
 static apr_status_t wd_worker_cleanup(void *data)
 {
@@ -276,7 +272,8 @@
 
     if (w->singleton) {
         /* Initialize singleton mutex in child */
-        rc = apr_proc_mutex_child_init(&w->mutex, w->mutex_path, p);
+        rc = apr_proc_mutex_child_init(&w->mutex,
+                                       apr_proc_mutex_lockfile(w->mutex), p);
         if (rc != APR_SUCCESS)
             return rc;
     }
@@ -387,38 +384,6 @@
     return APR_SUCCESS;
 }
 
-static apr_status_t wd_create_mutex(ap_watchdog_t *w, apr_pool_t *p)
-{
-    apr_status_t rv;
-    apr_lockmech_e mech = APR_LOCK_DEFAULT;
-    const char *mb_path = wd_mutex_path ? wd_mutex_path : "logs";
-
-    w->mutex_path = ap_server_root_relative(p,
-                                        apr_pstrcat(p, mb_path,
-                                        "/.wdc-", w->name, ".mutex", NULL));
-
-    /* TODO: Check the mutex mechanisms */
-#if APR_HAS_FCNTL_SERIALIZE
-    mech = APR_LOCK_FCNTL;
-#else
-#if APR_HAS_FLOCK_SERIALIZE
-    mech = APR_LOCK_FLOCK;
-#endif
-#endif
-    rv = apr_proc_mutex_create(&w->mutex, w->mutex_path, mech, p);
-#ifdef AP_NEED_SET_MUTEX_PERMS
-    if (rv == APR_SUCCESS) {
-        rv = ap_unixd_set_proc_mutex_perms(w->mutex);
-        if (rv != APR_SUCCESS) {
-            /* Destroy the mutex early */
-            apr_proc_mutex_destroy(w->mutex);
-            w->mutex = NULL;
-        }
-    }
-#endif
-    return rv;
-}
-
 /*--------------------------------------------------------------------------*/
 /*                                                                          */
 /* Pre config hook.                                                         */
@@ -451,6 +416,12 @@
             return rv;
         }
     }
+
+    if ((rv = ap_mutex_register(pconf, wd_proc_mutex_type, NULL,
+                                APR_LOCK_DEFAULT, 0)) != APR_SUCCESS) {
+        return rv;
+    }
+
     return OK;
 }
 
@@ -557,10 +528,10 @@
                      * Create mutexes for singleton watchdogs
                      */
                     if (w->singleton) {
-                        rv = wd_create_mutex(w, wd_server_conf->pool);
+                        rv = ap_proc_mutex_create(&w->mutex, wd_proc_mutex_type,
+                                                  w->name, s,
+                                                  wd_server_conf->pool, 0);
                         if (rv != APR_SUCCESS) {
-                            ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
-                                    "Watchdog: Failed to create mutex.");
                             return rv;
                         }
                     }
@@ -614,30 +585,6 @@
 
 /*--------------------------------------------------------------------------*/
 /*                                                                          */
-/* WatchdogMutexPath directive                                              */
-/*                                                                          */
-/*--------------------------------------------------------------------------*/
-static const char *wd_cmd_mutex_path(cmd_parms *cmd, void *dummy,
-                                     const char *arg)
-{
-    const char *errs = ap_check_cmd_context(cmd, GLOBAL_ONLY);
-
-    if (errs != NULL)
-        return errs;
-
-    if (wd_mutex_path != NULL)
-       return "Duplicate WatchdogMutexPath directives are not allowed";
-
-    wd_mutex_path = apr_pstrdup(cmd->pool, arg);
-    if (wd_mutex_path == NULL)
-        return "Invalid WatchdogMutexPath name";
-    if (wd_mutex_path[strlen(wd_mutex_path) - 1] == '/')
-        wd_mutex_path[strlen(wd_mutex_path) - 1] = '\0';
-    return NULL;
-}
-
-/*--------------------------------------------------------------------------*/
-/*                                                                          */
 /* WatchdogInterval directive                                               */
 /*                                                                          */
 /*--------------------------------------------------------------------------*/
@@ -667,13 +614,6 @@
 static const command_rec wd_directives[] =
 {
     AP_INIT_TAKE1(
-        "WatchdogMutexPath",                /* directive name               */
-        wd_cmd_mutex_path,                  /* config action routine        */
-        NULL,                               /* argument to include in call  */
-        RSRC_CONF,                          /* where available              */
-        "Path where the Watchdog mutexes will be created"
-    ),
-    AP_INIT_TAKE1(
         "WatchdogInterval",                 /* directive name               */
         wd_cmd_watchdog_int,                /* config action routine        */
         NULL,                               /* argument to include in call  */

Modified: httpd/httpd/trunk/modules/core/mod_watchdog.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/core/mod_watchdog.h?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/core/mod_watchdog.h (original)
+++ httpd/httpd/trunk/modules/core/mod_watchdog.h Mon Nov 23 23:17:51 2009
@@ -44,10 +44,6 @@
 #include "apr_global_mutex.h"
 #include "apr_thread_mutex.h"
 
-#ifdef AP_NEED_SET_MUTEX_PERMS
-#include "unixd.h"
-#endif
-
 #if APR_HAVE_UNISTD_H
 #include <unistd.h>         /* for getpid() */
 #endif

Modified: httpd/httpd/trunk/modules/examples/mod_example_ipc.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/examples/mod_example_ipc.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/examples/mod_example_ipc.c (original)
+++ httpd/httpd/trunk/modules/examples/mod_example_ipc.c Mon Nov 23 23:17:51 2009
@@ -52,13 +52,9 @@
 #include "http_config.h"
 #include "http_log.h"
 #include "http_protocol.h"
+#include "util_mutex.h"
 #include "ap_config.h"
 
-#if !defined(OS2) && !defined(WIN32) && !defined(NETWARE)
-#include "unixd.h"
-#define MOD_EXIPC_SET_MUTEX_PERMS /* XXX Apache should define something */
-#endif
-
 #if APR_HAVE_SYS_TYPES_H
 #include <sys/types.h>
 #endif
@@ -80,7 +76,7 @@
 apr_shm_t *exipc_shm; /* Pointer to shared memory block */
 char *shmfilename; /* Shared memory file name, used on some systems */
 apr_global_mutex_t *exipc_mutex; /* Lock around shared memory segment access */
-char *mutexfilename; /* Lock file name, used on some systems */
+static const char *exipc_mutex_type = "example-ipc-shm";
 
 /* Data structure for shared memory block */
 typedef struct exipc_data {
@@ -100,6 +96,18 @@
     return OK;
 }
 
+/*
+ * This routine is called in the parent; we must register our
+ * mutex type before the config is processed so that users can
+ * adjust the mutex settings using the Mutex directive.
+ */
+
+static int exipc_pre_config(apr_pool_t *pconf, apr_pool_t *plog, 
+                            apr_pool_t *ptemp)
+{
+    ap_mutex_register(pconf, exipc_mutex_type, NULL, APR_LOCK_DEFAULT, 0);
+    return OK;
+}
 
 /* 
  * This routine is called in the parent, so we'll set up the shared
@@ -140,8 +148,8 @@
     } /* Kilroy was here */
 
     /* 
-     * Both the shared memory and mutex allocation routines take a
-     * file name. Depending on system-specific implementation of these
+     * The shared memory allocation routines take a file name.
+     * Depending on system-specific implementation of these
      * routines, that file may or may not actually be created. We'd
      * like to store those files in the operating system's designated
      * temporary directory, which APR can point us to.
@@ -178,39 +186,11 @@
 
     /* Create global mutex */
 
-    /* 
-     * Create another unique filename to lock upon. Note that
-     * depending on OS and locking mechanism of choice, the file
-     * may or may not be actually created. 
-     */
-    mutexfilename = apr_psprintf(pconf, "%s/httpd_mutex.%ld", tempdir,
-                                 (long int) getpid());
-  
-    rs = apr_global_mutex_create(&exipc_mutex, (const char *) mutexfilename, 
-                                 APR_LOCK_DEFAULT, pconf);
-    if (APR_SUCCESS != rs) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, rs, s, 
-                     "Failed to create mutex on file %s", 
-                     mutexfilename);
-        return HTTP_INTERNAL_SERVER_ERROR;
-    }
-
-    /* 
-     * After the mutex is created, its permissions need to be adjusted
-     * on unix platforms so that the child processe can acquire
-     * it. This call takes care of that. The preprocessor define was
-     * set up early in this source file since Apache doesn't provide
-     * it.
-     */
-#ifdef MOD_EXIPC_SET_MUTEX_PERMS
-    rs = ap_unixd_set_global_mutex_perms(exipc_mutex);
+    rs = ap_global_mutex_create(&exipc_mutex, exipc_mutex_type, NULL, s, pconf,
+                                0);
     if (APR_SUCCESS != rs) {
-        ap_log_error(APLOG_MARK, APLOG_CRIT, rs, s, 
-                     "Parent could not set permissions on Example IPC "
-                     "mutex: check User and Group directives");
         return HTTP_INTERNAL_SERVER_ERROR;
     }
-#endif /* MOD_EXIPC_SET_MUTEX_PERMS */
 
     /* 
      * Destroy the shm segment when the configuration pool gets destroyed. This
@@ -236,12 +216,12 @@
      * the mutex pointer global here. 
      */
     rs = apr_global_mutex_child_init(&exipc_mutex, 
-                                     (const char *) mutexfilename, 
+                                     apr_global_mutex_lockfile(exipc_mutex),
                                      p);
     if (APR_SUCCESS != rs) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, rs, s, 
-                     "Failed to reopen mutex on file %s", 
-                     shmfilename);
+                     "Failed to reopen mutex %s in child", 
+                     exipc_mutex_type);
         /* There's really nothing else we can do here, since This
          * routine doesn't return a status. If this ever goes wrong,
          * it will turn Apache into a fork bomb. Let's hope it never
@@ -367,6 +347,7 @@
 
 static void exipc_register_hooks(apr_pool_t *p)
 {
+    ap_hook_pre_config(exipc_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_post_config(exipc_post_config, NULL, NULL, APR_HOOK_MIDDLE); 
     ap_hook_child_init(exipc_child_init, NULL, NULL, APR_HOOK_MIDDLE); 
     ap_hook_handler(exipc_handler, NULL, NULL, APR_HOOK_MIDDLE);

Modified: httpd/httpd/trunk/modules/generators/mod_info.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/generators/mod_info.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/generators/mod_info.c (original)
+++ httpd/httpd/trunk/modules/generators/mod_info.c Mon Nov 23 23:17:51 2009
@@ -528,10 +528,6 @@
     ap_rputs(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n", r);
 #endif
 
-#ifdef DEFAULT_LOCKFILE
-    ap_rputs(" -D DEFAULT_LOCKFILE=\"" DEFAULT_LOCKFILE "\"\n", r);
-#endif
-
 #ifdef DEFAULT_ERRORLOG
     ap_rputs(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n", r);
 #endif

Modified: httpd/httpd/trunk/modules/ldap/util_ldap.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ldap/util_ldap.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ldap/util_ldap.c (original)
+++ httpd/httpd/trunk/modules/ldap/util_ldap.c Mon Nov 23 23:17:51 2009
@@ -28,6 +28,7 @@
 #include "http_log.h"
 #include "http_protocol.h"
 #include "http_request.h"
+#include "util_mutex.h"
 #include "util_ldap.h"
 #include "util_ldap_cache.h"
 
@@ -41,10 +42,6 @@
 #error mod_ldap requires APR-util to have LDAP support built in
 #endif
 
-#ifdef AP_NEED_SET_MUTEX_PERMS
-#include "unixd.h"
-#endif
-
 /* Default define for ldap functions that need a SIZELIMIT but
  * do not have the define
  * XXX This should be removed once a supporting #define is 
@@ -67,6 +64,7 @@
 #define AP_LDAP_CHASEREFERRALS_ON 1
 
 module AP_MODULE_DECLARE_DATA ldap_module;
+static const char *ldap_cache_lock_type = "ldap-cache";
 
 #define LDAP_CACHE_LOCK() do {                                  \
     if (st->util_ldap_cache_lock)                               \
@@ -2518,6 +2516,20 @@
 
 }
 
+static int util_ldap_pre_config(apr_pool_t *pconf, apr_pool_t *plog,
+                                apr_pool_t *ptemp)
+{
+    apr_status_t result;
+
+    result = ap_mutex_register(pconf, ldap_cache_lock_type, NULL,
+                               APR_LOCK_DEFAULT, 0);
+    if (result != APR_SUCCESS) {
+        return result;
+    }
+
+    return OK;
+}
+
 static int util_ldap_post_config(apr_pool_t *p, apr_pool_t *plog,
                                  apr_pool_t *ptemp, server_rec *s)
 {
@@ -2567,30 +2579,12 @@
             return DONE;
         }
 
-
-#if APR_HAS_SHARED_MEMORY
-        if (st->cache_file) {
-            st->lock_file = apr_pstrcat(st->pool, st->cache_file, ".lck",
-                                        NULL);
-        }
-#endif
-
-        result = apr_global_mutex_create(&st->util_ldap_cache_lock,
-                                         st->lock_file, APR_LOCK_DEFAULT,
-                                         st->pool);
+        result = ap_global_mutex_create(&st->util_ldap_cache_lock,
+                                        ldap_cache_lock_type, NULL, s, p, 0);
         if (result != APR_SUCCESS) {
             return result;
         }
 
-#ifdef AP_NEED_SET_MUTEX_PERMS
-        result = ap_unixd_set_global_mutex_perms(st->util_ldap_cache_lock);
-        if (result != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_CRIT, result, s,
-                         "LDAP cache: failed to set mutex permissions");
-            return result;
-        }
-#endif
-
         /* merge config in all vhost */
         s_vhost = s->next;
         while (s_vhost) {
@@ -2607,7 +2601,6 @@
                          "for VHOST: %s", st->cache_shm, st->cache_rmm,
                          s_vhost->server_hostname);
 #endif
-            st_vhost->lock_file = st->lock_file;
             s_vhost = s_vhost->next;
         }
 #if APR_HAS_SHARED_MEMORY
@@ -2684,12 +2677,12 @@
     if (!st->util_ldap_cache_lock) return;
 
     sts = apr_global_mutex_child_init(&st->util_ldap_cache_lock,
-                                      st->lock_file, p);
+              apr_global_mutex_lockfile(st->util_ldap_cache_lock), p);
     if (sts != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_CRIT, sts, s,
                      "Failed to initialise global mutex %s in child process %"
                      APR_PID_T_FMT ".",
-                     st->lock_file, getpid());
+                     ldap_cache_lock_type, getpid());
     }
 }
 
@@ -2795,6 +2788,7 @@
     APR_REGISTER_OPTIONAL_FN(uldap_ssl_supported);
     APR_REGISTER_OPTIONAL_FN(uldap_cache_check_subgroups);
 
+    ap_hook_pre_config(util_ldap_pre_config, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_post_config(util_ldap_post_config,NULL,NULL,APR_HOOK_MIDDLE);
     ap_hook_handler(util_ldap_handler, NULL, NULL, APR_HOOK_MIDDLE);
     ap_hook_child_init(util_ldap_child_init, NULL, NULL, APR_HOOK_MIDDLE);

Modified: httpd/httpd/trunk/modules/mappers/mod_rewrite.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/mappers/mod_rewrite.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/mappers/mod_rewrite.c (original)
+++ httpd/httpd/trunk/modules/mappers/mod_rewrite.c Mon Nov 23 23:17:51 2009
@@ -94,15 +94,12 @@
 #include "http_log.h"
 #include "http_protocol.h"
 #include "http_vhost.h"
+#include "util_mutex.h"
 
 #include "mod_ssl.h"
 
 #include "mod_rewrite.h"
 
-#ifdef AP_NEED_SET_MUTEX_PERMS
-#include "unixd.h"
-#endif
-
 static ap_dbd_t *(*dbd_acquire)(request_rec*) = NULL;
 static void (*dbd_prepare)(server_rec*, const char*, const char*) = NULL;
 
@@ -382,8 +379,8 @@
 static int rewrite_rand_init_done = 0;
 
 /* Locks/Mutexes */
-static const char *lockname;
 static apr_global_mutex_t *rewrite_mapr_lock_acquire = NULL;
+const char *rewritemap_mutex_type = "rewrite-map";
 
 /* Optional functions imported from mod_ssl when loaded: */
 static APR_OPTIONAL_FN_TYPE(ssl_var_lookup) *rewrite_ssl_lookup = NULL;
@@ -1232,7 +1229,6 @@
     rewrite_server_conf *conf;
     apr_hash_index_t *hi;
     apr_status_t rc;
-    int lock_warning_issued = 0;
 
     conf = ap_get_module_config(s->module_config, &rewrite_module);
 
@@ -1259,13 +1255,6 @@
             continue;
         }
 
-        if (!lock_warning_issued && (!lockname || !*lockname)) {
-            ap_log_error(APLOG_MARK, APLOG_WARNING, 0, s,
-                         "mod_rewrite: Running external rewrite maps "
-                         "without defining a RewriteLock is DANGEROUS!");
-            ++lock_warning_issued;
-        }
-
         rc = rewritemap_program_child(p, map->argv[0], map->argv,
                                       &fpout, &fpin);
         if (rc != APR_SUCCESS || fpin == NULL || fpout == NULL) {
@@ -2646,45 +2635,26 @@
 {
     apr_status_t rc;
 
-    /* only operate if a lockfile is used */
-    if (lockname == NULL || *(lockname) == '\0') {
-        return APR_SUCCESS;
-    }
-
     /* create the lockfile */
-    rc = apr_global_mutex_create(&rewrite_mapr_lock_acquire, lockname,
-                                 APR_LOCK_DEFAULT, p);
-    if (rc != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_CRIT, rc, s,
-                     "mod_rewrite: Parent could not create RewriteLock "
-                     "file %s", lockname);
-        return rc;
-    }
-
-#ifdef AP_NEED_SET_MUTEX_PERMS
-    rc = ap_unixd_set_global_mutex_perms(rewrite_mapr_lock_acquire);
+    /* XXX See if there are any rewrite map programs before creating
+     * the mutex.
+     */
+    rc = ap_global_mutex_create(&rewrite_mapr_lock_acquire,
+                                rewritemap_mutex_type, NULL, s, p, 0);
     if (rc != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_CRIT, rc, s,
-                     "mod_rewrite: Parent could not set permissions "
-                     "on RewriteLock; check User and Group directives");
         return rc;
     }
-#endif
 
     return APR_SUCCESS;
 }
 
 static apr_status_t rewritelock_remove(void *data)
 {
-    /* only operate if a lockfile is used */
-    if (lockname == NULL || *(lockname) == '\0') {
-        return APR_SUCCESS;
-    }
-
     /* destroy the rewritelock */
-    apr_global_mutex_destroy (rewrite_mapr_lock_acquire);
-    rewrite_mapr_lock_acquire = NULL;
-    lockname = NULL;
+    if (rewrite_mapr_lock_acquire) {
+        apr_global_mutex_destroy(rewrite_mapr_lock_acquire);
+        rewrite_mapr_lock_acquire = NULL;
+    }
     return(0);
 }
 
@@ -3158,23 +3128,6 @@
     return NULL;
 }
 
-static const char *cmd_rewritelock(cmd_parms *cmd, void *dconf, const char *a1)
-{
-    const char *error;
-
-    if ((error = ap_check_cmd_context(cmd, GLOBAL_ONLY)) != NULL)
-        return error;
-
-    /* fixup the path, especially for rewritelock_remove() */
-    lockname = ap_server_root_relative(cmd->pool, a1);
-
-    if (!lockname) {
-        return apr_pstrcat(cmd->pool, "Invalid RewriteLock path ", a1, NULL);
-    }
-
-    return NULL;
-}
-
 static const char *cmd_rewritebase(cmd_parms *cmd, void *in_dconf,
                                    const char *a1)
 {
@@ -4279,6 +4232,8 @@
 {
     APR_OPTIONAL_FN_TYPE(ap_register_rewrite_mapfunc) *map_pfn_register;
 
+    ap_mutex_register(pconf, rewritemap_mutex_type, NULL, APR_LOCK_DEFAULT, 0);
+
     /* register int: rewritemap handlers */
     map_pfn_register = APR_RETRIEVE_OPTIONAL_FN(ap_register_rewrite_mapfunc);
     if (map_pfn_register) {
@@ -4348,9 +4303,9 @@
 {
     apr_status_t rv = 0; /* get a rid of gcc warning (REWRITELOG_DISABLED) */
 
-    if (lockname != NULL && *(lockname) != '\0') {
+    if (rewrite_mapr_lock_acquire) {
         rv = apr_global_mutex_child_init(&rewrite_mapr_lock_acquire,
-                                         lockname, p);
+                 apr_global_mutex_lockfile(rewrite_mapr_lock_acquire), p);
         if (rv != APR_SUCCESS) {
             ap_log_error(APLOG_MARK, APLOG_CRIT, rv, s,
                          "mod_rewrite: could not init rewrite_mapr_lock_acquire"
@@ -5023,9 +4978,6 @@
                      "an URL-applied regexp-pattern and a substitution URL"),
     AP_INIT_TAKE2(   "RewriteMap",      cmd_rewritemap,      NULL, RSRC_CONF,
                      "a mapname and a filename"),
-    AP_INIT_TAKE1(   "RewriteLock",     cmd_rewritelock,     NULL, RSRC_CONF,
-                     "the filename of a lockfile used for inter-process "
-                     "synchronization"),
 #ifndef REWRITELOG_DISABLED
     AP_INIT_TAKE1(   "RewriteLog",      cmd_rewritelog,      NULL, RSRC_CONF,
                      "the filename of the rewriting logfile"),

Modified: httpd/httpd/trunk/modules/ssl/mod_ssl.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/mod_ssl.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/mod_ssl.c (original)
+++ httpd/httpd/trunk/modules/ssl/mod_ssl.c Mon Nov 23 23:17:51 2009
@@ -54,7 +54,6 @@
     /*
      * Global (main-server) context configuration directives
      */
-    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', "
@@ -201,7 +200,6 @@
     /*
      * OCSP Stapling options
      */
-    SSL_CMD_SRV(StaplingMutex, TAKE1, AP_ALL_AVAILABLE_MUTEXES_STRING)
     SSL_CMD_SRV(StaplingCache, TAKE1,
                 "SSL Stapling Response Cache storage "
                 "(`dbm:/path/to/file')")
@@ -313,6 +311,12 @@
     /* Register to handle mod_status status page generation */
     ssl_scache_status_register(pconf);
 
+    /* Register mutex type names so they can be configured with Mutex */
+    ap_mutex_register(pconf, ssl_cache_mutex_type, NULL, APR_LOCK_DEFAULT, 0);
+#ifdef HAVE_OCSP_STAPLING
+    ap_mutex_register(pconf, ssl_stapling_mutex_type, NULL, APR_LOCK_DEFAULT, 0);
+#endif
+
     return OK;
 }
 

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?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_engine_config.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_engine_config.c Mon Nov 23 23:17:51 2009
@@ -61,9 +61,6 @@
      */
     mc->sesscache_mode         = SSL_SESS_CACHE_OFF;
     mc->sesscache              = NULL;
-    mc->nMutexMode             = SSL_MUTEXMODE_UNSET;
-    mc->nMutexMech             = APR_LOCK_DEFAULT;
-    mc->szMutexFile            = NULL;
     mc->pMutex                 = NULL;
     mc->aRandSeed              = apr_array_make(pool, 4,
                                                 sizeof(ssl_randseed_t));
@@ -74,11 +71,8 @@
     mc->szCryptoDevice         = NULL;
 #endif
 #ifdef HAVE_OCSP_STAPLING
-    mc->stapling_cache                  = NULL;
-    mc->stapling_mutex_mode             = SSL_MUTEXMODE_UNSET;
-    mc->stapling_mutex_mech             = APR_LOCK_DEFAULT;
-    mc->stapling_mutex_file            = NULL;
-    mc->stapling_mutex                 = NULL;
+    mc->stapling_cache         = NULL;
+    mc->stapling_mutex         = NULL;
 #endif
 
     memset(mc->pTmpKeys, 0, sizeof(mc->pTmpKeys));
@@ -383,41 +377,6 @@
  *  Configuration functions for particular directives
  */
 
-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);
-
-    if ((err = ap_check_cmd_context(cmd, GLOBAL_ONLY))) {
-        return err;
-    }
-
-    if (ssl_config_global_isfixed(mc)) {
-        return NULL;
-    }
-
-    rv = ap_parse_mutex(arg_, cmd->server->process->pool,
-                        &mc->nMutexMech, &mc->szMutexFile);
-
-    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_,
-                           " (" AP_ALL_AVAILABLE_MUTEXES_STRING ")", NULL);
-    } else if (rv == APR_BADARG) {
-            return apr_pstrcat(cmd->pool, "Invalid SSLMutex filepath ",
-                               arg_, NULL);
-    }
-
-    mc->nMutexMode  = SSL_MUTEXMODE_USED;
-
-    return NULL;
-}
-
 const char *ssl_cmd_SSLPassPhraseDialog(cmd_parms *cmd,
                                         void *dcfg,
                                         const char *arg)
@@ -1546,44 +1505,6 @@
     return NULL;
 }
 
-const char *ssl_cmd_SSLStaplingMutex(cmd_parms *cmd,
-                                     void *dcfg,
-                                     const char *arg_)
-{
-    apr_status_t rv;
-    const char *err;
-    SSLModConfigRec *mc = myModConfig(cmd->server);
-
-    if ((err = ap_check_cmd_context(cmd, GLOBAL_ONLY))) {
-        return err;
-    }
-
-    if (ssl_config_global_isfixed(mc)) {
-        return NULL;
-    }
-
-    rv = ap_parse_mutex(arg_, cmd->server->process->pool,
-                        &mc->stapling_mutex_mech, &mc->stapling_mutex_file);
-
-    if (rv == APR_ENOLOCK) {
-        mc->stapling_mutex_mode  = SSL_MUTEXMODE_NONE;
-        return NULL;
-    } 
-    else if (rv == APR_ENOTIMPL) {
-        return apr_pstrcat(cmd->pool, "Invalid SSLStaplingMutex argument ",
-                           arg_,
-                           " (" AP_ALL_AVAILABLE_MUTEXES_STRING ")", NULL);
-    } 
-    else if (rv == APR_BADARG) {
-        return apr_pstrcat(cmd->pool, "Invalid SSLStaplingMutex filepath ",
-                           arg_, NULL);
-    }
-
-    mc->stapling_mutex_mode  = SSL_MUTEXMODE_USED;
-
-    return NULL;
-}
-
 const char *ssl_cmd_SSLUseStapling(cmd_parms *cmd, void *dcfg, int flag)
 {   
     SSLSrvConfigRec *sc = mySrvConfig(cmd->server);

Modified: httpd/httpd/trunk/modules/ssl/ssl_engine_mutex.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_engine_mutex.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_engine_mutex.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_engine_mutex.c Mon Nov 23 23:17:51 2009
@@ -30,10 +30,6 @@
 
 #include "ssl_private.h"
 
-#ifdef AP_NEED_SET_MUTEX_PERMS
-#include "unixd.h"
-#endif
-
 int ssl_mutex_init(server_rec *s, apr_pool_t *p)
 {
     SSLModConfigRec *mc = myModConfig(s);
@@ -50,35 +46,13 @@
     if (mc->pMutex) {
         return TRUE;
     }
-    else if (mc->nMutexMode == SSL_MUTEXMODE_NONE) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
-                     "An SSLMutex is required for the '%s' session cache",
-                     mc->sesscache->name);
-        return FALSE;
-    }
 
-    if ((rv = apr_global_mutex_create(&mc->pMutex, mc->szMutexFile,
-                                      mc->nMutexMech, s->process->pool))
+    if ((rv = ap_global_mutex_create(&mc->pMutex, ssl_cache_mutex_type, NULL,
+                                     s, s->process->pool, 0))
             != APR_SUCCESS) {
-        if (mc->szMutexFile)
-            ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
-                         "Cannot create SSLMutex with file `%s'",
-                         mc->szMutexFile);
-        else
-            ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
-                         "Cannot create SSLMutex");
         return FALSE;
     }
 
-#ifdef AP_NEED_SET_MUTEX_PERMS
-    rv = ap_unixd_set_global_mutex_perms(mc->pMutex);
-    if (rv != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
-                     "Could not set permissions on ssl_mutex; check User "
-                     "and Group directives");
-        return FALSE;
-    }
-#endif
     return TRUE;
 }
 
@@ -86,21 +60,24 @@
 {
     SSLModConfigRec *mc = myModConfig(s);
     apr_status_t rv;
+    const char *lockfile;
 
-    if (mc->nMutexMode == SSL_MUTEXMODE_NONE || !mc->sesscache
+    if (mc->pMutex == NULL || !mc->sesscache
         || (mc->sesscache->flags & AP_SOCACHE_FLAG_NOTMPSAFE) == 0) {
         return TRUE;
     }
 
+    lockfile = apr_global_mutex_lockfile(mc->pMutex);
     if ((rv = apr_global_mutex_child_init(&mc->pMutex,
-                                    mc->szMutexFile, p)) != APR_SUCCESS) {
-        if (mc->szMutexFile)
+                                          lockfile,
+                                          p)) != APR_SUCCESS) {
+        if (lockfile)
             ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
-                         "Cannot reinit SSLMutex with file `%s'",
-                         mc->szMutexFile);
+                         "Cannot reinit %s mutex with file `%s'",
+                         ssl_cache_mutex_type, lockfile);
         else
             ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s,
-                         "Cannot reinit SSLMutex");
+                         "Cannot reinit %s mutex", ssl_cache_mutex_type);
         return FALSE;
     }
     return TRUE;

Modified: httpd/httpd/trunk/modules/ssl/ssl_private.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_private.h?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_private.h (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_private.h Mon Nov 23 23:17:51 2009
@@ -39,6 +39,7 @@
 #include "util_script.h"
 #include "util_filter.h"
 #include "util_ebcdic.h"
+#include "util_mutex.h"
 #include "apr.h"
 #include "apr_strings.h"
 #define APR_WANT_STRFUNC
@@ -267,15 +268,6 @@
 typedef unsigned int ssl_pathcheck_t;
 
 /**
- * Define the SSL mutex modes
- */
-typedef enum {
-    SSL_MUTEXMODE_UNSET  = UNSET,
-    SSL_MUTEXMODE_NONE   = 0,
-    SSL_MUTEXMODE_USED   = 1
-} ssl_mutexmode_t;
-
-/**
  * Define the SSL enabled state
  */
 typedef enum {
@@ -403,9 +395,6 @@
     const ap_socache_provider_t *sesscache;
     ap_socache_instance_t *sesscache_context;
 
-    ssl_mutexmode_t nMutexMode;
-    apr_lockmech_e  nMutexMech;
-    const char     *szMutexFile;
     apr_global_mutex_t   *pMutex;
     apr_array_header_t   *aRandSeed;
     apr_hash_t     *tVHostKeys;
@@ -419,9 +408,6 @@
 #ifdef HAVE_OCSP_STAPLING
     const ap_socache_provider_t *stapling_cache;
     ap_socache_instance_t *stapling_cache_context;
-    ssl_mutexmode_t stapling_mutex_mode;
-    apr_lockmech_e  stapling_mutex_mech;
-    const char     *stapling_mutex_file;
     apr_global_mutex_t   *stapling_mutex;
 #endif
 
@@ -566,7 +552,6 @@
 void        *ssl_config_server_merge(apr_pool_t *, void *, void *);
 void        *ssl_config_perdir_create(apr_pool_t *, char *);
 void        *ssl_config_perdir_merge(apr_pool_t *, void *, void *);
-const char  *ssl_cmd_SSLMutex(cmd_parms *, void *, const char *);
 const char  *ssl_cmd_SSLPassPhraseDialog(cmd_parms *, void *, const char *);
 const char  *ssl_cmd_SSLCryptoDevice(cmd_parms *, void *, const char *);
 const char  *ssl_cmd_SSLRandomSeed(cmd_parms *, void *, const char *, const char *, const char *);
@@ -666,7 +651,6 @@
 
 /** OCSP Stapling Support */
 #ifdef HAVE_OCSP_STAPLING
-const char *ssl_cmd_SSLStaplingMutex(cmd_parms *, void *, const char *);
 const char *ssl_cmd_SSLStaplingCache(cmd_parms *, void *, const char *);
 const char *ssl_cmd_SSLUseStapling(cmd_parms *, void *, int);
 const char *ssl_cmd_SSLStaplingResponseTimeSkew(cmd_parms *, void *, const char *);
@@ -741,6 +725,10 @@
 int          ssl_stapling_mutex_init(server_rec *, apr_pool_t *);
 int          ssl_stapling_mutex_reinit(server_rec *, apr_pool_t *);
 
+/* mutex type names for Mutex directive */
+#define ssl_cache_mutex_type    "ssl-cache"
+#define ssl_stapling_mutex_type "ssl-stapling"
+
 /**  Logfile Support  */
 void         ssl_die(void);
 void         ssl_log_ssl_error(const char *, int, int, server_rec *);

Modified: httpd/httpd/trunk/modules/ssl/ssl_util_stapling.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/modules/ssl/ssl_util_stapling.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/modules/ssl/ssl_util_stapling.c (original)
+++ httpd/httpd/trunk/modules/ssl/ssl_util_stapling.c Mon Nov 23 23:17:51 2009
@@ -32,10 +32,6 @@
 #include "ap_mpm.h"
 #include "apr_thread_mutex.h"
 
-#ifdef AP_NEED_SET_MUTEX_PERMS
-#include "unixd.h"
-#endif
-
 #ifdef HAVE_OCSP_STAPLING
 
 /**
@@ -480,36 +476,13 @@
     if (mc->stapling_mutex || sc->server->stapling_enabled != TRUE) {
         return TRUE;
     }
-    if (mc->stapling_mutex_mode == SSL_MUTEXMODE_NONE
-        || mc->stapling_mutex_mode == SSL_MUTEXMODE_UNSET) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
-                     "An SSLStaplingMutex is required for OCSP Stapling");
-        return FALSE;
-    }
 
-    if ((rv = apr_global_mutex_create(&mc->stapling_mutex,
-                                      mc->stapling_mutex_file,
-                                      mc->stapling_mutex_mech, s->process->pool))
-            != APR_SUCCESS) {
-        if (mc->stapling_mutex_file)
-            ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
-                         "Cannot create SSLStaplingMutex with file `%s'",
-                         mc->stapling_mutex_file);
-        else
-            ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
-                         "Cannot create SSLStaplingMutex");
+    if ((rv = ap_global_mutex_create(&mc->stapling_mutex,
+                                     ssl_stapling_mutex_type, NULL, s,
+                                     s->process->pool, 0)) != APR_SUCCESS) {
         return FALSE;
     }
 
-#ifdef AP_NEED_SET_MUTEX_PERMS
-    rv = ap_unixd_set_global_mutex_perms(mc->stapling_mutex);
-    if (rv != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
-                     "Could not set permissions on ssl_mutex; check User "
-                     "and Group directives");
-        return FALSE;
-    }
-#endif
     return TRUE;
 }
 
@@ -517,21 +490,23 @@
 {
     SSLModConfigRec *mc = myModConfig(s);
     apr_status_t rv;
+    const char *lockfile;
 
     if (mc->stapling_mutex == NULL) {
         return TRUE;
     }
 
+    lockfile = apr_global_mutex_lockfile(mc->stapling_mutex);
     if ((rv = apr_global_mutex_child_init(&mc->stapling_mutex,
-                                 mc->stapling_mutex_file, p)) != APR_SUCCESS) {
-        if (mc->stapling_mutex_file) {
+                                          lockfile, p)) != APR_SUCCESS) {
+        if (lockfile) {
             ap_log_error(APLOG_MARK, APLOG_ERR, rv, s,
-                         "Cannot reinit SSLMutex with file `%s'",
-                         mc->szMutexFile);
+                         "Cannot reinit %s mutex with file `%s'",
+                         ssl_stapling_mutex_type, lockfile);
         }
         else {
             ap_log_error(APLOG_MARK, APLOG_WARNING, rv, s,
-                         "Cannot reinit SSLMutex");
+                         "Cannot reinit %s mutex", ssl_stapling_mutex_type);
         }
         return FALSE;
     }

Modified: httpd/httpd/trunk/server/core.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/core.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/server/core.c (original)
+++ httpd/httpd/trunk/server/core.c Mon Nov 23 23:17:51 2009
@@ -3319,6 +3319,8 @@
 AP_INIT_TAKE1("LimitXMLRequestBody", set_limit_xml_req_body, NULL, OR_ALL,
               "Limit (in bytes) on maximum size of an XML-based request "
               "body"),
+AP_INIT_TAKE2("Mutex", ap_set_mutex, NULL, RSRC_CONF,
+              "mutex (or \"default\") and mechanism"),
 
 /* System Resource Controls */
 #ifdef RLIMIT_CPU
@@ -3378,14 +3380,10 @@
               "A file for logging the server process ID"),
 AP_INIT_TAKE1("ScoreBoardFile", ap_mpm_set_scoreboard, NULL, RSRC_CONF,
               "A file for Apache to maintain runtime process management information"),
-AP_INIT_TAKE1("LockFile",  ap_mpm_set_lockfile, NULL, RSRC_CONF,
-              "The lockfile used when Apache needs to lock the accept() call (deprecated)"),
 AP_INIT_TAKE1("MaxRequestsPerChild", ap_mpm_set_max_requests, NULL, RSRC_CONF,
               "Maximum number of requests a particular child serves before dying."),
 AP_INIT_TAKE1("CoreDumpDirectory", ap_mpm_set_coredumpdir, NULL, RSRC_CONF,
               "The location of the directory Apache changes to before dumping core"),
-AP_INIT_TAKE1("AcceptMutex", ap_mpm_set_accept_lock_mech, NULL, RSRC_CONF,
-              AP_AVAILABLE_MUTEXES_STRING),
 AP_INIT_TAKE1("MaxMemFree", ap_mpm_set_max_mem_free, NULL, RSRC_CONF,
               "Maximum number of 1k blocks a particular childs allocator may hold."),
 AP_INIT_TAKE1("ThreadStackSize", ap_mpm_set_thread_stacksize, NULL, RSRC_CONF,

Modified: httpd/httpd/trunk/server/main.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/main.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/server/main.c (original)
+++ httpd/httpd/trunk/server/main.c Mon Nov 23 23:17:51 2009
@@ -237,10 +237,6 @@
     printf(" -D DEFAULT_SCOREBOARD=\"" DEFAULT_SCOREBOARD "\"\n");
 #endif
 
-#ifdef DEFAULT_LOCKFILE
-    printf(" -D DEFAULT_LOCKFILE=\"" DEFAULT_LOCKFILE "\"\n");
-#endif
-
 #ifdef DEFAULT_ERRORLOG
     printf(" -D DEFAULT_ERRORLOG=\"" DEFAULT_ERRORLOG "\"\n");
 #endif

Modified: httpd/httpd/trunk/server/mpm/prefork/mpm_default.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/prefork/mpm_default.h?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/mpm_default.h (original)
+++ httpd/httpd/trunk/server/mpm/prefork/mpm_default.h Mon Nov 23 23:17:51 2009
@@ -46,11 +46,6 @@
 #define DEFAULT_MIN_FREE_DAEMON 5
 #endif
 
-/* File used for accept locking, when we use a file */
-#ifndef DEFAULT_LOCKFILE
-#define DEFAULT_LOCKFILE DEFAULT_REL_RUNTIMEDIR "/accept.lock"
-#endif
-
 /* Where the main/parent process's pid is logged */
 #ifndef DEFAULT_PIDLOG
 #define DEFAULT_PIDLOG DEFAULT_REL_RUNTIMEDIR "/httpd.pid"

Modified: httpd/httpd/trunk/server/mpm/prefork/prefork.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/prefork/prefork.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/prefork/prefork.c (original)
+++ httpd/httpd/trunk/server/mpm/prefork/prefork.c Mon Nov 23 23:17:51 2009
@@ -41,6 +41,7 @@
 #include "http_connection.h"
 #include "scoreboard.h"
 #include "ap_mpm.h"
+#include "util_mutex.h"
 #include "unixd.h"
 #include "mpm_common.h"
 #include "ap_listen.h"
@@ -457,6 +458,7 @@
     ap_sb_handle_t *sbh;
     apr_bucket_alloc_t *bucket_alloc;
     int last_poll_idx = 0;
+    const char *lockfile;
 
     mpm_state = AP_MPMQ_STARTING; /* for benefit of any hooks that run as this
                                    * child initializes
@@ -487,11 +489,16 @@
 
     /* needs to be done before we switch UIDs so we have permissions */
     ap_reopen_scoreboard(pchild, NULL, 0);
-    status = apr_proc_mutex_child_init(&accept_mutex, ap_lock_fname, pchild);
+    lockfile = apr_proc_mutex_lockfile(accept_mutex);
+    status = apr_proc_mutex_child_init(&accept_mutex,
+                                       lockfile,
+                                       pchild);
     if (status != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_EMERG, status, ap_server_conf,
                      "Couldn't initialize cross-process lock in child "
-                     "(%s) (%d)", ap_lock_fname, ap_accept_lock_mech);
+                     "(%s) (%s)",
+                     lockfile ? lockfile : "none",
+                     apr_proc_mutex_name(accept_mutex));
         clean_child_exit(APEXIT_CHILDFATAL);
     }
 
@@ -908,36 +915,13 @@
     ap_log_pid(pconf, ap_pid_fname);
 
     /* Initialize cross-process accept lock */
-    ap_lock_fname = apr_psprintf(_pconf, "%s.%" APR_PID_T_FMT,
-                                 ap_server_root_relative(_pconf, ap_lock_fname),
-                                 ap_my_pid);
-
-    rv = apr_proc_mutex_create(&accept_mutex, ap_lock_fname,
-                               ap_accept_lock_mech, _pconf);
+    rv = ap_proc_mutex_create(&accept_mutex, ap_accept_mutex_type, NULL, s,
+                              _pconf, 0);
     if (rv != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
-                     "Couldn't create accept lock (%s) (%d)",
-                     ap_lock_fname, ap_accept_lock_mech);
         mpm_state = AP_MPMQ_STOPPING;
         return DONE;
     }
 
-#if APR_USE_SYSVSEM_SERIALIZE
-    if (ap_accept_lock_mech == APR_LOCK_DEFAULT ||
-        ap_accept_lock_mech == APR_LOCK_SYSVSEM) {
-#else
-    if (ap_accept_lock_mech == APR_LOCK_SYSVSEM) {
-#endif
-        rv = ap_unixd_set_proc_mutex_perms(accept_mutex);
-        if (rv != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
-                         "Couldn't set permissions on cross-process lock; "
-                         "check User and Group directives");
-            mpm_state = AP_MPMQ_STOPPING;
-            return DONE;
-        }
-    }
-
     if (!is_graceful) {
         if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
             mpm_state = AP_MPMQ_STOPPING;
@@ -988,7 +972,7 @@
     ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
                 "Server built: %s", ap_get_server_built());
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
-                "AcceptMutex: %s (default: %s)",
+                "Accept mutex: %s (default: %s)",
                 apr_proc_mutex_name(accept_mutex),
                 apr_proc_mutex_defname());
     restart_pending = shutdown_pending = 0;
@@ -1284,6 +1268,8 @@
         foreground = ap_exists_config_define("FOREGROUND");
     }
 
+    ap_mutex_register(p, ap_accept_mutex_type, NULL, APR_LOCK_DEFAULT, 0);
+
     /* sigh, want this only the second time around */
     retained = ap_retained_data_get(userdata_key);
     if (!retained) {
@@ -1313,7 +1299,6 @@
     server_limit = DEFAULT_SERVER_LIMIT;
     ap_daemons_limit = server_limit;
     ap_pid_fname = DEFAULT_PIDLOG;
-    ap_lock_fname = DEFAULT_LOCKFILE;
     ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
     ap_extended_status = 0;
     ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;

Modified: httpd/httpd/trunk/server/mpm/worker/mpm_default.h
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/worker/mpm_default.h?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/worker/mpm_default.h (original)
+++ httpd/httpd/trunk/server/mpm/worker/mpm_default.h Mon Nov 23 23:17:51 2009
@@ -50,11 +50,6 @@
 #define DEFAULT_THREADS_PER_CHILD 25
 #endif
 
-/* File used for accept locking, when we use a file */
-#ifndef DEFAULT_LOCKFILE
-#define DEFAULT_LOCKFILE DEFAULT_REL_RUNTIMEDIR "/accept.lock"
-#endif
-
 /* Where the main/parent process's pid is logged */
 #ifndef DEFAULT_PIDLOG
 #define DEFAULT_PIDLOG DEFAULT_REL_RUNTIMEDIR "/httpd.pid"

Modified: httpd/httpd/trunk/server/mpm/worker/worker.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm/worker/worker.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm/worker/worker.c (original)
+++ httpd/httpd/trunk/server/mpm/worker/worker.c Mon Nov 23 23:17:51 2009
@@ -64,6 +64,7 @@
 #include "scoreboard.h"
 #include "fdqueue.h"
 #include "mpm_default.h"
+#include "util_mutex.h"
 #include "unixd.h"
 
 #include <signal.h>
@@ -1172,7 +1173,8 @@
     /*stuff to do before we switch id's, so we have permissions.*/
     ap_reopen_scoreboard(pchild, NULL, 0);
 
-    rv = SAFE_ACCEPT(apr_proc_mutex_child_init(&accept_mutex, ap_lock_fname,
+    rv = SAFE_ACCEPT(apr_proc_mutex_child_init(&accept_mutex,
+                                               apr_proc_mutex_lockfile(accept_mutex),
                                                pchild));
     if (rv != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_EMERG, rv, ap_server_conf,
@@ -1692,35 +1694,13 @@
     ap_log_pid(pconf, ap_pid_fname);
 
     /* Initialize cross-process accept lock */
-    ap_lock_fname = apr_psprintf(_pconf, "%s.%" APR_PID_T_FMT,
-                                 ap_server_root_relative(_pconf, ap_lock_fname),
-                                 ap_my_pid);
-
-    rv = apr_proc_mutex_create(&accept_mutex, ap_lock_fname,
-                               ap_accept_lock_mech, _pconf);
+    rv = ap_proc_mutex_create(&accept_mutex, ap_accept_mutex_type, NULL, s,
+                              _pconf, 0);
     if (rv != APR_SUCCESS) {
-        ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
-                     "Couldn't create accept lock");
         mpm_state = AP_MPMQ_STOPPING;
         return DONE;
     }
 
-#if APR_USE_SYSVSEM_SERIALIZE
-    if (ap_accept_lock_mech == APR_LOCK_DEFAULT ||
-        ap_accept_lock_mech == APR_LOCK_SYSVSEM) {
-#else
-    if (ap_accept_lock_mech == APR_LOCK_SYSVSEM) {
-#endif
-        rv = ap_unixd_set_proc_mutex_perms(accept_mutex);
-        if (rv != APR_SUCCESS) {
-            ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
-                         "Couldn't set permissions on cross-process lock; "
-                         "check User and Group directives");
-            mpm_state = AP_MPMQ_STOPPING;
-            return DONE;
-        }
-    }
-
     if (!is_graceful) {
         if (ap_run_pre_mpm(s->process->pool, SB_SHARED) != OK) {
             mpm_state = AP_MPMQ_STOPPING;
@@ -1766,7 +1746,7 @@
     ap_log_error(APLOG_MARK, APLOG_INFO, 0, ap_server_conf,
                 "Server built: %s", ap_get_server_built());
     ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, ap_server_conf,
-                "AcceptMutex: %s (default: %s)",
+                "Accept mutex: %s (default: %s)",
                 apr_proc_mutex_name(accept_mutex),
                 apr_proc_mutex_defname());
     restart_pending = shutdown_pending = 0;
@@ -1957,6 +1937,8 @@
         foreground = ap_exists_config_define("FOREGROUND");
     }
 
+    ap_mutex_register(pconf, ap_accept_mutex_type, NULL, APR_LOCK_DEFAULT, 0);
+
     /* sigh, want this only the second time around */
     retained = ap_retained_data_get(userdata_key);
     if (!retained) {
@@ -1988,7 +1970,6 @@
     threads_per_child = DEFAULT_THREADS_PER_CHILD;
     max_clients = ap_daemons_limit * threads_per_child;
     ap_pid_fname = DEFAULT_PIDLOG;
-    ap_lock_fname = DEFAULT_LOCKFILE;
     ap_max_requests_per_child = DEFAULT_MAX_REQUESTS_PER_CHILD;
     ap_extended_status = 0;
     ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;

Modified: httpd/httpd/trunk/server/mpm_common.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/mpm_common.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/server/mpm_common.c (original)
+++ httpd/httpd/trunk/server/mpm_common.c Mon Nov 23 23:17:51 2009
@@ -253,20 +253,6 @@
     return NULL;
 }
 
-const char *ap_lock_fname = NULL;
-
-const char *ap_mpm_set_lockfile(cmd_parms *cmd, void *dummy,
-                                const char *arg)
-{
-    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
-    if (err != NULL) {
-        return err;
-    }
-
-    ap_lock_fname = arg;
-    return NULL;
-}
-
 int ap_max_requests_per_child = 0;
 
 const char *ap_mpm_set_max_requests(cmd_parms *cmd, void *dummy,
@@ -327,35 +313,6 @@
     return NULL;
 }
 
-apr_lockmech_e ap_accept_lock_mech = APR_LOCK_DEFAULT;
-
-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;
-    }
-
-    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);
-    }
-
-    if (lockfile && !ap_lock_fname)
-        ap_lock_fname = lockfile;
-    return NULL;
-}
-
 apr_uint32_t ap_max_mem_free = APR_ALLOCATOR_MAX_FREE_UNLIMITED;
 
 const char *ap_mpm_set_max_mem_free(cmd_parms *cmd, void *dummy,

Modified: httpd/httpd/trunk/server/util_mutex.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_mutex.c?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_mutex.c (original)
+++ httpd/httpd/trunk/server/util_mutex.c Mon Nov 23 23:17:51 2009
@@ -21,6 +21,7 @@
 
 
 #include "apr.h"
+#include "apr_hash.h"
 #include "apr_strings.h"
 #include "apr_lib.h"
 
@@ -31,7 +32,12 @@
 #include "httpd.h"
 #include "http_main.h"
 #include "http_config.h"
+#include "http_log.h"
 #include "util_mutex.h"
+#include "unixd.h"
+#ifdef HAVE_UNISTD_H
+#include <unistd.h> /* getpid() */
+#endif
 
 AP_DECLARE(apr_status_t) ap_parse_mutex(const char *arg, apr_pool_t *pool,
                                         apr_lockmech_e *mutexmech,
@@ -47,16 +53,16 @@
         }
     }
 
-    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;
 
+    if (!strcasecmp(meth, "none") || !strcasecmp(meth, "no")) {
+        return APR_ENOLOCK;
+    }
+
     /* NOTE: previously, 'yes' implied 'sem' */
     if (!strcasecmp(meth, "default") || !strcasecmp(meth, "yes")) {
         *mutexmech = APR_LOCK_DEFAULT;
@@ -112,3 +118,330 @@
 
     return APR_SUCCESS;
 }
+
+typedef struct {
+    apr_int32_t options;
+    int set;
+    int none;
+    apr_lockmech_e mech;
+    const char *dir;
+} mutex_cfg_t;
+
+/* hash is created the first time a module calls ap_mutex_register(),
+ * rather than attempting to be the REALLY_REALLY_FIRST pre-config
+ * hook; it is cleaned up when the associated pool goes away; assume
+ * pconf is the pool passed to ap_mutex_register()
+ */
+static apr_hash_t *mxcfg_by_type;
+
+static apr_status_t cleanup_mx_hash(void *dummy)
+{
+    mxcfg_by_type = NULL;
+    return APR_SUCCESS;
+}
+
+static void mx_hash_init(apr_pool_t *p)
+{
+    mutex_cfg_t *def;
+
+    if (mxcfg_by_type) {
+        return;
+    }
+
+    mxcfg_by_type = apr_hash_make(p);
+    apr_pool_cleanup_register(p, NULL, cleanup_mx_hash, apr_pool_cleanup_null);
+
+    /* initialize default mutex configuration */
+    def = apr_pcalloc(p, sizeof *def);
+    def->mech = APR_LOCK_DEFAULT;
+    def->dir = DEFAULT_REL_RUNTIMEDIR;
+    apr_hash_set(mxcfg_by_type, "default", APR_HASH_KEY_STRING, def);
+}
+
+AP_DECLARE(const char *) ap_set_mutex(cmd_parms *cmd, void *dummy,
+                                      const char *type, const char *mechdir)
+{
+    apr_pool_t *p = cmd->pool;
+    apr_lockmech_e mech;
+    apr_status_t rv;
+    const char *mutexdir;
+    mutex_cfg_t *mxcfg = apr_hash_get(mxcfg_by_type, type,
+                                      APR_HASH_KEY_STRING);
+    const char *err = ap_check_cmd_context(cmd, GLOBAL_ONLY);
+
+    if (err != NULL) {
+        return err;
+    }
+
+    if (!mxcfg) {
+        return apr_psprintf(p, "Mutex type %s is not valid", type);
+    }
+
+    mxcfg->none = 0; /* in case that was the default */
+
+    rv = ap_parse_mutex(mechdir, p, &mech, &mutexdir);
+    if (rv == APR_ENOTIMPL) {
+        return apr_pstrcat(p, "Invalid Mutex argument ", mechdir,
+                           " (" AP_ALL_AVAILABLE_MUTEXES_STRING ")", NULL);
+    }
+    else if (rv == APR_BADARG
+             || (mutexdir && !ap_is_directory(p, mutexdir))) {
+        return apr_pstrcat(p, "Invalid Mutex directory in argument ",
+                           mechdir, NULL);
+    }
+
+    mxcfg->set = 1;
+    if (rv == APR_ENOLOCK) { /* "none" */
+        if (!(mxcfg->options & AP_MUTEX_ALLOW_NONE)) {
+            return apr_psprintf(p,
+                                "None is not allowed for mutex type %s",
+                                type);
+        }
+        mxcfg->none = 1;
+    }
+    else {
+        mxcfg->mech = mech;
+        if (mutexdir) { /* retain mutex default if not configured */
+            mxcfg->dir = mutexdir;
+        }
+    }
+
+    return NULL;
+}
+
+AP_DECLARE(apr_status_t) ap_mutex_register(apr_pool_t *pconf,
+                                           const char *type,
+                                           const char *default_dir,
+                                           apr_lockmech_e default_mech,
+                                           apr_int32_t options)
+{
+    mutex_cfg_t *mxcfg = apr_pcalloc(pconf, sizeof *mxcfg);
+
+    if ((options & ~(AP_MUTEX_ALLOW_NONE | AP_MUTEX_DEFAULT_NONE))) {
+        return APR_EINVAL;
+    }
+
+    mx_hash_init(pconf);
+
+    mxcfg->options = options;
+    if (options & AP_MUTEX_DEFAULT_NONE) {
+        mxcfg->none = 1;
+    }
+    mxcfg->dir = default_dir; /* usually NULL */
+    mxcfg->mech = default_mech; /* usually APR_LOCK_DEFAULT */
+    apr_hash_set(mxcfg_by_type, type, APR_HASH_KEY_STRING, mxcfg);
+
+    return APR_SUCCESS;
+}
+
+static int mutex_needs_file(apr_lockmech_e mech)
+{
+    if (mech != APR_LOCK_FLOCK
+        && mech != APR_LOCK_FCNTL
+#if APR_USE_FLOCK_SERIALIZE || APR_USE_FCNTL_SERIALIZE
+        && mech != APR_LOCK_DEFAULT
+#endif
+        ) {
+        return 0;
+    }
+    return 1;
+}
+
+static const char *get_mutex_filename(apr_pool_t *p, mutex_cfg_t *mxcfg,
+                                      const char *type,
+                                      const char *instance_id)
+{
+    const char *pid_suffix = "";
+
+    if (!mutex_needs_file(mxcfg->mech)) {
+        return NULL;
+    }
+
+#if HAVE_UNISTD_H
+    pid_suffix = apr_psprintf(p, ".%" APR_PID_T_FMT, getpid());
+#endif
+
+    return ap_server_root_relative(p,
+                                   apr_pstrcat(p,
+                                               mxcfg->dir,
+                                               "/",
+                                               type,
+                                               instance_id ? "-" : "",
+                                               instance_id ? instance_id : "",
+                                               pid_suffix,
+                                               NULL));
+}
+
+static mutex_cfg_t *mxcfg_lookup(apr_pool_t *p, const char *type)
+{
+    mutex_cfg_t *defcfg, *mxcfg, *newcfg;
+
+    defcfg = apr_hash_get(mxcfg_by_type, "default", APR_HASH_KEY_STRING);
+
+    /* MUST exist in table, or wasn't registered */
+    mxcfg = apr_hash_get(mxcfg_by_type, type, APR_HASH_KEY_STRING);
+    if (!mxcfg) {
+        return NULL;
+    }
+
+    /* order of precedence:
+     * 1. Mutex directive for this mutex
+     * 2. Mutex directive for "default"
+     * 3. Defaults for this mutex from ap_mutex_register()
+     * 4. Global defaults
+     */
+
+    if (mxcfg->set) {
+        newcfg = mxcfg;
+    }
+    else if (defcfg->set) {
+        newcfg = defcfg;
+    }
+    else if (mxcfg->none || mxcfg->mech != APR_LOCK_DEFAULT) {
+        newcfg = mxcfg;
+    }
+    else {
+        newcfg = defcfg;
+    }
+
+    if (!newcfg->none && mutex_needs_file(newcfg->mech) && !newcfg->dir) {
+        /* a file-based mutex mechanism was configured, but
+         * without a mutex file directory; go back through
+         * the chain to find the directory, store in new
+         * mutex cfg structure
+         */
+        newcfg = apr_pmemdup(p, newcfg, sizeof *newcfg);
+
+        /* !true if dir not already set: mxcfg->set && defcfg->dir */
+        if (defcfg->set && defcfg->dir) {
+            newcfg->dir = defcfg->dir;
+        }
+        else if (mxcfg->dir) {
+            newcfg->dir = mxcfg->dir;
+        }
+        else {
+            newcfg->dir = defcfg->dir;
+        }
+    }
+
+    return newcfg;
+}
+
+static void log_bad_create_options(server_rec *s, const char *type)
+{
+    ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s,
+                 "Invalid options were specified when creating the %s mutex",
+                 type);
+}
+
+static void log_unknown_type(server_rec *s, const char *type)
+{
+    ap_log_error(APLOG_MARK, APLOG_EMERG, 0, s,
+                 "Can't create mutex of unknown type %s", type);
+}
+
+static void log_create_failure(apr_status_t rv, server_rec *s, const char *type,
+                               const char *fname)
+{
+    ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
+                 "Couldn't create the %s mutex %s%s%s", type,
+                 fname ? "(file " : "",
+                 fname ? fname : "",
+                 fname ? ")" : "");
+}
+
+static void log_perms_failure(apr_status_t rv, server_rec *s, const char *type)
+{
+    ap_log_error(APLOG_MARK, APLOG_EMERG, rv, s,
+                 "Couldn't set permissions on the %s mutex; "
+                 "check User and Group directives",
+                 type);
+}
+
+AP_DECLARE(apr_status_t) ap_global_mutex_create(apr_global_mutex_t **mutex,
+                                                const char *type,
+                                                const char *instance_id,
+                                                server_rec *s, apr_pool_t *p,
+                                                apr_int32_t options)
+{
+    apr_status_t rv;
+    const char *fname;
+    mutex_cfg_t *mxcfg = mxcfg_lookup(p, type);
+
+    if (options) {
+        log_bad_create_options(s, type);
+        return APR_EINVAL;
+    }
+
+    if (!mxcfg) {
+        log_unknown_type(s, type);
+        return APR_EINVAL;
+    }
+
+    if (mxcfg->none) {
+        *mutex = NULL;
+        return APR_SUCCESS;
+    }
+
+    fname = get_mutex_filename(p, mxcfg, type, instance_id);
+
+    rv = apr_global_mutex_create(mutex, fname, mxcfg->mech, p);
+    if (rv != APR_SUCCESS) {
+        log_create_failure(rv, s, type, fname);
+        return rv;
+    }
+
+#ifdef AP_NEED_SET_MUTEX_PERMS
+    rv = ap_unixd_set_global_mutex_perms(*mutex);
+    if (rv != APR_SUCCESS) {
+        log_perms_failure(rv, s, type);
+        return rv;
+    }
+#endif
+
+    return APR_SUCCESS;
+}
+
+AP_DECLARE(apr_status_t) ap_proc_mutex_create(apr_proc_mutex_t **mutex,
+                                              const char *type,
+                                              const char *instance_id,
+                                              server_rec *s, apr_pool_t *p,
+                                              apr_int32_t options)
+{
+    apr_status_t rv;
+    const char *fname;
+    mutex_cfg_t *mxcfg = mxcfg_lookup(p, type);
+
+    if (options) {
+        log_bad_create_options(s, type);
+        return APR_EINVAL;
+    }
+
+    if (!mxcfg) {
+        log_unknown_type(s, type);
+        return APR_EINVAL;
+    }
+
+    if (mxcfg->none) {
+        *mutex = NULL;
+        return APR_SUCCESS;
+    }
+
+    fname = get_mutex_filename(p, mxcfg, type, instance_id);
+
+    rv = apr_proc_mutex_create(mutex, fname, mxcfg->mech, p);
+    if (rv != APR_SUCCESS) {
+        log_create_failure(rv, s, type, fname);
+        return rv;
+    }
+
+#ifdef AP_NEED_SET_MUTEX_PERMS
+    rv = ap_unixd_set_proc_mutex_perms(*mutex);
+    if (rv != APR_SUCCESS) {
+        log_perms_failure(rv, s, type);
+        return rv;
+    }
+#endif
+
+    return APR_SUCCESS;
+}

Modified: httpd/httpd/trunk/test/make_sni.sh
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/test/make_sni.sh?rev=883540&r1=883539&r2=883540&view=diff
==============================================================================
--- httpd/httpd/trunk/test/make_sni.sh (original)
+++ httpd/httpd/trunk/test/make_sni.sh Mon Nov 23 23:17:51 2009
@@ -209,8 +209,8 @@
 
 # Note that this SSL configuration is far
 # from complete - you propably will want
-# to configure SSLMutex-es and SSLSession
-# Caches at the very least.
+# to configure SSLSession Caches at the 
+# very least.
 
 <Directory />
     Options None



Mime
View raw message