in reply to Using flock() on files


One possible solution to your problem would be to have a DBF file with a list of all files that are currently locked. The files themselves would not be locked via flock() but access to the DBF file would be gated through flock().
Advantage: locks will be maintained even if your server/client crashes and is then restarted;
Disadvantage: having all processes use the same file may create a bottleneck. To minimize the probability of this happening, make sure the DBF file is locked only when necessary.

Hope this helps.

--perlplexer

Replies are listed 'Best First'.
Re: Re: Using flock() on files
by no_slogan (Deacon) on Apr 20, 2003 at 08:23 UTC
    locks will be maintained even if your server/client crashes and is then restarted

    This is not necessarily an advantage. You need a way to break old, stale locks that might be left behind after a crash.

      I view this as an advantage because I'd rather have the locks stay than have corrupt data. You can easily write a tool for cleaning up old locks; writing a tool for restoring corrupt data, however, may not even be possible depending on what kind of data you're dealing with.

      --perlplexer