
trawick at gmail
Nov 18, 2009, 10:18 AM
Post #1 of 7
(962 views)
Permalink
|
|
mutex method configuration cleanup for 2.4
|
|
A. simplistic goal: Just make it simple for modules with no special issues or love of complexity. Provide these directives to set global defaults for modules that have been modified to query them: use MutexMethod and MutexFileDir to configure method and lock location globally or for a specific mutex use MutexMethod method-keyword # "none" not supported as global default MutexFileDir /var/httpd/locks Modules call ap_global_mutex_method() and ap_global_mutex_file_dir() to retrieve that information and use in their APR calls. b. more complex goal: Try to meet requirements of more complex (or configurable) modules to get rid of some of the varying , complex mplementations we already have, as well as handle the simple use. A rough sketch is shown below: config time: use MutexMethod and MutexFileDir to configure method and lock location globally or for a specific mutex use; it can set a global default or configure a particular mutex # set global default with method keyword; "none" not supported as global default MutexMethod fcntl MutexFileDir /var/httpd/locks # whoops, overwrite method of particular mutex by abstract name MutexMethod rewrite-map sysvsem MutexMethod rewrite-map none or MutexFileDir rewrite-map /var/httpd/rewrite/locks module code: e.g., mod_rewrite: replace /* only operate if a lockfile is used */ if (lockname == NULL || *(lockname) == '\0') { return APR_SUCCESS; } 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); 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 with rc = ap_global_mutex_create(&rewrite_mapr_lock_acquire, "rewrite-map", server_rec, pool, 0 /* flags */); if (rc != APR_SUCCESS) { /* already logged; fail startup */ } if (rewrite_mapr_lock_acquire == NULL) { /* admin coded "MutexType rewrite-map none" */ } /* mutex perms already fixed if necessary */ Also, core should be able to handle the child-init. If the mutex mechanism uses a file, the mutex name (e.g., "rewrite-map") will be used as the basename of the file, perhaps with pid appended. We could require modules that use the API to make this call in pre-config so that the mutex name in the config file can be checked, as well as allow the module to indicate whether or not MutexMethod=none is supported for that mutex: ap_global_mutex_register(pconf, "rewrite-map", flags); --/-- This should be good enough to get rid of AcceptMutex, LockFile, and the directives for SSL's two global mutexes. (If it won't be, there's no use in going for the more complicated goal.)
|