apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ruediger Pluem <rpl...@apache.org>
Subject Re: Corrected: global_mutex on Solaris 10, does it actually work?
Date Fri, 03 Oct 2008 21:47:17 GMT

On 10/03/2008 10:55 PM, Tim Bray wrote:
> On Oct 3, 2008, at 1:16 PM, Ruediger Pluem wrote:
>> This maybe because the default locking mechanism on OS X is different
>> from the
>> one on Solaris. AFAICR Solaris has fcntl as default mechanism.
>> The question is: Why do you create this file beforehand? If a file
>> needs to be
>> created apr_global_mutex_create will do this for you.
> Good question.  Let me present the problem at a high level.  There's a
> file that is regularly refreshed, and I only want one request handler
> rebuilding it at a time, because otherwise there are lots of horrible
> race conditions.   I don't know whether I'm in worker or prefork mode. 
> So I simply want to serialize update of this file, and I thought
> apr_global_mutex_* was a good way to do this.  Is there a better way?  -Tim

It seems that you have found the correct way. It is just that the file
you want to refresh from one request handler and the file that is eventually
used for locking are two different things. Using the default method it is not
even clear if the filename is used depending on the platform you use. So consider
the filename as some sort of abstract name for your lock that needs to be
known to use the same lock in a different process. But I am no expert on this
and as Bill mentioned in the other mail the APR API might lack the needed operations,
if there is no parent / child relationship between them.
As you seem to work inside httpd I think you should use the post_config hook to create
the global mutex and the child_init hook to reattach to this lock in each
child via




View raw message