Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Apache: Dev

mutex method configuration cleanup for 2.4

 

 

Apache dev RSS feed   Index | Next | Previous | View Threaded


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.)


trawick at gmail

Nov 18, 2009, 12:50 PM

Post #2 of 7 (920 views)
Permalink
Re: mutex method configuration cleanup for 2.4 [In reply to]

On Wed, Nov 18, 2009 at 1:18 PM, Jeff Trawick <trawick [at] gmail> wrote:

> 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.)
>

Speaking of mod_ssl's mutexes, it looks like mod_ssl's
{file|flock|fcntl}:/path/to/lock syntax has been promoted to a new
ap_parse_mutex() API in trunk.

Is it important for the admin to code the entire path name mutex file
instead of just the containing directory? The latter lends itself to
a directive that in one swoop locates all mutexes in an appropriate
directory, leaving it to the individual modules to provide a
reasonable basename.


jorton at redhat

Nov 19, 2009, 1:23 AM

Post #3 of 7 (914 views)
Permalink
Re: mutex method configuration cleanup for 2.4 [In reply to]

On Wed, Nov 18, 2009 at 01:18:55PM -0500, Jeff Trawick wrote:
> 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:

Yes! I've looked into doing something like this before and I thought a
single "Mutex" directive would suffice:

Mutex {default,rewrite-map,...} {none,sysvsem,fcntl:/blah}

where the 3rd arg is parsed by ap_parse_mutex().

> 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);

Yes, definitely a good idea.

>
> --/--
>
> 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.)

Yup, definitely.

Regards, Joe


trawick at gmail

Nov 19, 2009, 3:47 AM

Post #4 of 7 (914 views)
Permalink
Re: mutex method configuration cleanup for 2.4 [In reply to]

On Thu, Nov 19, 2009 at 4:23 AM, Joe Orton <jorton [at] redhat> wrote:
> On Wed, Nov 18, 2009 at 01:18:55PM -0500, Jeff Trawick wrote:
>> 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:
>
> Yes!  I've looked into doing something like this before and I thought a
> single "Mutex" directive would suffice:
>
> Mutex {default,rewrite-map,...} {none,sysvsem,fcntl:/blah}
>
> where the 3rd arg is parsed by ap_parse_mutex().

"blah" always has to point to a dir, and the lock identifier is used
when constructing the basename.

--/--

I envisioned the conf (perhaps a vendor conf) declaring something like

MutexDir logs
or
MutexDir /var/apache2/2.2/locks

The admin can then adjust the mutex methods as necessary and not worry
about paths to locks. Or change MutexDir as necessary and not affect
the mutex methods at all. MutexDir can be used as a preventative
measure even if no file-based mutexes are currently configured.

With the single directive solution, I don't see a way to declare "if
lock files must be used, put them here."

The alternative is something like

# If fcntl-based mutexes are used by default in APR and the locks need to be
# moved to a local directory, uncomment the following and adjust the directory:
# Mutex default fcntl:logs

That works only if the characteristics of specific mutexes aren't
being adjusted by other Mutex directives (but those people deserve
what they get).

Reality check?


trawick at gmail

Nov 19, 2009, 4:03 AM

Post #5 of 7 (911 views)
Permalink
Re: mutex method configuration cleanup for 2.4 [In reply to]

On Thu, Nov 19, 2009 at 6:47 AM, Jeff Trawick <trawick [at] gmail> wrote:
> On Thu, Nov 19, 2009 at 4:23 AM, Joe Orton <jorton [at] redhat> wrote:
>> On Wed, Nov 18, 2009 at 01:18:55PM -0500, Jeff Trawick wrote:
>>> 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:
>>
>> Yes!  I've looked into doing something like this before and I thought a
>> single "Mutex" directive would suffice:
>>
>> Mutex {default,rewrite-map,...} {none,sysvsem,fcntl:/blah}
>>
>> where the 3rd arg is parsed by ap_parse_mutex().
>
> "blah" always has to point to a dir, and the lock identifier is used
> when constructing the basename.
>
> --/--
>
> I envisioned the conf (perhaps a vendor conf) declaring something like
>
> MutexDir logs
> or
> MutexDir /var/apache2/2.2/locks
>
> The admin can then adjust the mutex methods as necessary and not worry
> about paths to locks.  Or change MutexDir as necessary and not affect
> the mutex methods at all.  MutexDir can be used as a preventative
> measure even if no file-based mutexes are currently configured.
>
> With the single directive solution, I don't see a way to declare "if
> lock files must be used, put them here."

I sure hope there's no reason to put different mutexes on different
filesystems...


jorton at redhat

Nov 19, 2009, 8:09 AM

Post #6 of 7 (911 views)
Permalink
Re: mutex method configuration cleanup for 2.4 [In reply to]

On Thu, Nov 19, 2009 at 06:47:56AM -0500, Jeff Trawick wrote:
> I envisioned the conf (perhaps a vendor conf) declaring something like
>
> MutexDir logs
> or
> MutexDir /var/apache2/2.2/locks
>
> The admin can then adjust the mutex methods as necessary and not worry
> about paths to locks. Or change MutexDir as necessary and not affect
> the mutex methods at all. MutexDir can be used as a preventative
> measure even if no file-based mutexes are currently configured.
>
> With the single directive solution, I don't see a way to declare "if
> lock files must be used, put them here."

I guess that makes sense. I didn't see any need to configure that
separately; i.e. in a vendor build having the locks dir default to
DEFAULT_REL_RUNTIMEDIR would be sufficient. Joe


trawick at gmail

Nov 19, 2009, 12:52 PM

Post #7 of 7 (898 views)
Permalink
Re: mutex method configuration cleanup for 2.4 [In reply to]

On Thu, Nov 19, 2009 at 11:09 AM, Joe Orton <jorton [at] redhat> wrote:
> On Thu, Nov 19, 2009 at 06:47:56AM -0500, Jeff Trawick wrote:
>> I envisioned the conf (perhaps a vendor conf) declaring something like
>>
>> MutexDir logs
>> or
>> MutexDir /var/apache2/2.2/locks
>>
>> The admin can then adjust the mutex methods as necessary and not worry
>> about paths to locks.  Or change MutexDir as necessary and not affect
>> the mutex methods at all.  MutexDir can be used as a preventative
>> measure even if no file-based mutexes are currently configured.
>>
>> With the single directive solution, I don't see a way to declare "if
>> lock files must be used, put them here."
>
> I guess that makes sense.  I didn't see any need to configure that
> separately; i.e. in a vendor build having the locks dir default to
> DEFAULT_REL_RUNTIMEDIR would be sufficient.   Joe

Right, the vendor config isn't a good example of when any Mutex
configuration is needed, as they hopefully have set the default mutex
type and locks dir default appropriate for almost all users.

I'll try to get some working code, and meanwhile maybe somebody else
will speak up.

Apache dev RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.