apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitri Tikhonov <dmi...@netilla.com>
Subject flock() does not work in Apache2 module.
Date Thu, 08 May 2003 17:14:28 GMT

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)) {
        /* Could not lock... go with old config. */
        return -4;
    }

I tested it by locking the file using perl script:

    perl -we 'use Fcntl qw(:flock); \
	open(F, "/tmp/cnf"); \
	flock(F, LOCK_EX); \
	print "Locked.\n"; \
	sleep(20);'

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?

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

  - Dmitri.



Mime
View raw message