in reply to Re: How to apply flock
in thread How to apply flock

lock(); # do what ever you want with it unlock();

If "whatever you want" involves tieing a DB_File, you're in for trouble. Some versions of BerkeleyDB close the file and reopen it, which loses the lock for you. This took me a lot of pain and agony to discover, but fortunately not too much data was corrupted before I figured it out.

Using a separate lock file is good. The mod_perl guide is good. Heed the other monks.

Update: If you close the same file you lose the lock, even if you open it through a different filehandle and close that one. Locks exist at the inode level, not the filehandle level.

Replies are listed 'Best First'.
Re: Re: Re: How to apply flock
by Chief of Chaos (Friar) on Nov 25, 2002 at 07:48 UTC
    Sorry,
    flock works on filehandles, if you close the filehandle
    you're in trouble (the lock will be released). That's right.