apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William A. Rowe, Jr." <wr...@rowe-clan.net>
Subject Re: flock() does not work in Apache2 module.
Date Thu, 08 May 2003 17:39:35 GMT
At 12:14 PM 5/8/2003, Dmitri Tikhonov wrote:

>I've run into an interesting problem: my module needs to read
>configuration from a file that is occasionally changed by another process.
>I've created a test C program that reads configuration if it can obtain a
>lock using flock(2) function:
>    if (-1 == flock(fd, LOCK_SH|LOCK_NB)) {

Why not apr_file_lock?  If not - why would you be asking here {dev@apr}?

>However, when I put the function into my module, flock() always gets the
>lock, no matter what.  Question: has anyone seen this before?  is there
>a side-effect of Apache environment that I'm not aware of?

Ok, the answer (this applies to unix apr_file_lock too) ... unix flock is
an advisory lock - it isn't enforced except between processes that choose
to use it.

So unless the other application that modifies that file chooses to use
flock, you can't use flock to sync updates between two apps.

>My set-up: Linux 2.4.21pre5, Apache 2.0.45, Perl 5.6.1, glibc 2.2.4.

View raw message