Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: pesky lockfile stays locked

by TilRMan (Friar)
on May 17, 2004 at 13:18 UTC ( #353954=note: print w/ replies, xml ) Need Help??


in reply to pesky lockfile stays locked

Don't you need to unlink() the lockfile when you're done? And why not just flock() the database file itself instead?

Update: Don't mind me, I was confusing O_CREAT with O_EXCL.


Comment on Re: pesky lockfile stays locked
Select or Download Code
Re: Re: pesky lockfile stays locked
by tilly (Archbishop) on May 17, 2004 at 18:49 UTC
    Do not rely on locking database files if you're relying on an external library to manipulate them.

    It used to be very common advice to lock database files - it was even in the Cookbook as a recipe. The ultimate source of this advice seems to have been Berkeley DB documentation circa version 1.65.

    However since then at least some dbm applications (Berkely DB among them) in multi-user situations will sometimes close and then re-open the database behind the scenes. Because of how flock works, any close to the file, even if you have another handle to that file open (such as the one holding a lock), will lose your flock. Then you're in the worst of all possible worlds. You don't actually have a lock, but you think that you do.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://353954]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (11)
As of 2014-09-17 15:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (90 votes), past polls