You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Tim Bray <Ti...@Sun.COM> on 2008/10/04 21:52:56 UTC

Maybe global_mutex breakage isn't a problem

On Oct 3, 2008, at 1:55 PM, Tim Bray wrote:

> 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

Um, maybe I'm an idiot.  There is after apr_file_lock(), which seems  
made to order.  Just because I was thinking "mutex" didn't mean I  
actually needed one.

  -Tim


Re: Maybe global_mutex breakage isn't a problem

Posted by Justin Erenkrantz <ju...@erenkrantz.com>.
On Sat, Oct 4, 2008 at 12:52 PM, Tim Bray <Ti...@sun.com> wrote:
> Um, maybe I'm an idiot.  There is after apr_file_lock(), which seems made to
> order.  Just because I was thinking "mutex" didn't mean I actually needed
> one.

Yup, plus apr_file_lock() has the benefit of anything else on the OS
doing file locking will also fail - with a 'global' mutex, in order
for it to work, it requires a process/thread-level relationship.
(APR, by default, will use SysV semaphores with IPC_PRIVATE, so they
aren't shared across two independent processes.)  -- justin