You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Greg Lazar <gr...@hotmail.com> on 2013/04/03 21:03:52 UTC

Building the apr runtime library appropriately for the worker MPM

The apr_file_lock routine, in the version of apr runtime library that I've currently built uses fnctl which does not appear to be thread safe. I need to use the worker MPM, so is it recommended that I build the apr runtime library to use flock instead. NFS file systems aren't a concern in this case. I didn't know how extensively the apr_file_lock was used through the rest of apache and if I'd be introducing any regressions by switching the apr runtime library to use flock.

Thank you.

Re: Building the apr runtime library appropriately for the worker MPM

Posted by Greg Lazar <gr...@hotmail.com>.
In my case I'm only interested in SLES11, where it seems to exhibit the behavior I'm looking for.. I'm just trying to make sure building the apr runtime to use flock doesn't have some negative/unforeseen impact on the modules I'm using. It sounds like Apache itself doesn't use apr_file_lock from the responses. So it's down to the modules that I'm using in my config. I can't see why (given no NFS), there would be a negative effect quite frankly,

Greg


From: thomas bonfort 
Sent: Thursday, April 04, 2013 3:13 AM
To: Greg Lazar 
Cc: dev@apr.apache.org 
Subject: Re: Building the apr runtime library appropriately for the worker MPM




On 3 April 2013 21:03, Greg Lazar <gr...@hotmail.com> wrote:

  The apr_file_lock routine, in the version of apr runtime library that I've currently built uses fnctl which does not appear to be thread safe. I need to use the worker MPM, so is it recommended that I build the apr runtime library to use flock instead. NFS file systems aren't a concern in this case. I didn't know how extensively the apr_file_lock was used through the rest of apache and if I'd be introducing any regressions by switching the apr runtime library to use flock.

  Thank you.


Hi Greg,
I had brought this question up on the modules-dev mailing list a few months ago:


http://mail-archives.apache.org/mod_mbox/httpd-modules-dev/201109.mbox/%3CCAOM3y2i3osynN3Rnuvoqyhm1NHBgZTxxnt%2BT0y7nPz9tEpu6AA%40mail.gmail.com%3E


 Note that it would seem flock falls back to fcntl on some platforms, so using flock will not fix the issue on those platforms.


regards,
thomas





Re: Building the apr runtime library appropriately for the worker MPM

Posted by thomas bonfort <th...@gmail.com>.
On 3 April 2013 21:03, Greg Lazar <gr...@hotmail.com> wrote:

> **
> The apr_file_lock routine, in the version of apr runtime library that I've
> currently built uses fnctl which does not appear to be thread safe. I need
> to use the worker MPM, so is it recommended that I build the apr runtime
> library to use flock instead. NFS file systems aren't a concern in this
> case. I didn't know how extensively the apr_file_lock was used through the
> rest of apache and if I'd be introducing any regressions by switching the
> apr runtime library to use flock.
>
> Thank you.
>

Hi Greg,
I had brought this question up on the modules-dev mailing list a few months
ago:

http://mail-archives.apache.org/mod_mbox/httpd-modules-dev/201109.mbox/%3CCAOM3y2i3osynN3Rnuvoqyhm1NHBgZTxxnt%2BT0y7nPz9tEpu6AA%40mail.gmail.com%3E

 Note that it would seem flock falls back to fcntl on some platforms, so
using flock will not fix the issue on those platforms.

regards,
thomas


>

Re: Building the apr runtime library appropriately for the worker MPM

Posted by Greg Lazar <gr...@hotmail.com>.
Thanks for getting back to me Jeff, appreciate it!

It's SLES11, SP2 I believe. I suppose I'd have to consider any other modules that I've included in my configuration as well any their usage of apr_file_lock. It does seem like though, if I'm using "worker", and NFS isn't in the mix, I'd want flock to be the underlying system call used in any module using apr_file_lock. Otherwise, the locks may not be honored across threads, within a given module?

Thanks again,

Greg

 
From: Jeff Trawick 
Sent: Wednesday, April 03, 2013 3:29 PM
To: Greg Lazar 
Cc: APR Developer List 
Subject: Re: Building the apr runtime library appropriately for the worker MPM


On Wed, Apr 3, 2013 at 3:03 PM, Greg Lazar <gr...@hotmail.com> wrote:

  The apr_file_lock routine, in the version of apr runtime library that I've currently built uses fnctl which does not appear to be thread safe. I need to use the worker MPM, so is it recommended that I build the apr runtime library to use flock instead. NFS file systems aren't a concern in this case. I didn't know how extensively the apr_file_lock was used through the rest of apache and if I'd be introducing any regressions by switching the apr runtime library to use flock.


I'm not aware of any apr_file_lock() use within httpd, so you wouldn't regress anything (unless you're using third-party modules that use apr_file_lock).  But I guess you've introduced a third-party module that uses apr_file_lock() or you wouldn't be asking about this?


I guess the apr_file_lock() use of fcntl() needs to get a thread mutex too.


What OS is this?


-- 
Born in Roswell... married an alien...
http://emptyhammock.com/

Re: Building the apr runtime library appropriately for the worker MPM

Posted by Jeff Trawick <tr...@gmail.com>.
On Wednesday, April 3, 2013, Philip Martin wrote:

> Ben Reser <ben@reser.org <javascript:;>> writes:
>
> > On Wed, Apr 3, 2013 at 12:29 PM, Jeff Trawick <trawick@gmail.com<javascript:;>>
> wrote:
> >> I'm not aware of any apr_file_lock() use within httpd, so you wouldn't
> >> regress anything (unless you're using third-party modules that use
> >> apr_file_lock).  But I guess you've introduced a third-party module that
> >> uses apr_file_lock() or you wouldn't be asking about this?
> >
> > Subversion uses apr_file_lock() and by extension so does mod_dav_svn.
>
> The main place we use this is in the FSFS backend.  On multi-threaded
> Unix systems we also use a mutex to ensure that only a single thread in
> each process locks the file.  So the use of fcntl() should be OK here as
> far as Subversion is concerned.


Cool, but APR needs a fix...

I didn't get a chance to check where if anywhere APR  uses a pthread mutex
in conjunction with fcntl for mutexes...


> There is also a lock for the BDB backend that is only used for certain
> admin operations and those operations have a restriction that the caller
> is responsible for calling the functions in a single-threaded context.
> These functions are used by the single-threaded svnadmin program.
>
> --
> Philip
>


-- 
Born in Roswell... married an alien...
http://emptyhammock.com/

Re: Building the apr runtime library appropriately for the worker MPM

Posted by Philip Martin <ph...@codematters.co.uk>.
Ben Reser <be...@reser.org> writes:

> On Wed, Apr 3, 2013 at 12:29 PM, Jeff Trawick <tr...@gmail.com> wrote:
>> I'm not aware of any apr_file_lock() use within httpd, so you wouldn't
>> regress anything (unless you're using third-party modules that use
>> apr_file_lock).  But I guess you've introduced a third-party module that
>> uses apr_file_lock() or you wouldn't be asking about this?
>
> Subversion uses apr_file_lock() and by extension so does mod_dav_svn.

The main place we use this is in the FSFS backend.  On multi-threaded
Unix systems we also use a mutex to ensure that only a single thread in
each process locks the file.  So the use of fcntl() should be OK here as
far as Subversion is concerned.

There is also a lock for the BDB backend that is only used for certain
admin operations and those operations have a restriction that the caller
is responsible for calling the functions in a single-threaded context.
These functions are used by the single-threaded svnadmin program.

-- 
Philip

Re: Building the apr runtime library appropriately for the worker MPM

Posted by Ben Reser <be...@reser.org>.
On Wed, Apr 3, 2013 at 12:29 PM, Jeff Trawick <tr...@gmail.com> wrote:
> I'm not aware of any apr_file_lock() use within httpd, so you wouldn't
> regress anything (unless you're using third-party modules that use
> apr_file_lock).  But I guess you've introduced a third-party module that
> uses apr_file_lock() or you wouldn't be asking about this?

Subversion uses apr_file_lock() and by extension so does mod_dav_svn.

Re: Building the apr runtime library appropriately for the worker MPM

Posted by Jeff Trawick <tr...@gmail.com>.
On Wed, Apr 3, 2013 at 3:03 PM, Greg Lazar <gr...@hotmail.com> wrote:

> **
> The apr_file_lock routine, in the version of apr runtime library that I've
> currently built uses fnctl which does not appear to be thread safe. I need
> to use the worker MPM, so is it recommended that I build the apr runtime
> library to use flock instead. NFS file systems aren't a concern in this
> case. I didn't know how extensively the apr_file_lock was used through the
> rest of apache and if I'd be introducing any regressions by switching the
> apr runtime library to use flock.
>

I'm not aware of any apr_file_lock() use within httpd, so you wouldn't
regress anything (unless you're using third-party modules that use
apr_file_lock).  But I guess you've introduced a third-party module that
uses apr_file_lock() or you wouldn't be asking about this?

I guess the apr_file_lock() use of fcntl() needs to get a thread mutex too.

What OS is this?

-- 
Born in Roswell... married an alien...
http://emptyhammock.com/