| [reply] |
I did see that module, it seems like overkill (a little), and like I said using a module is not the best solution for my situation. You have my thanks Artist.
We are trying to play with fcntl in a test script, but can't get it do the right thing, we don't quite understand what parameters it needs.
So does anyone have experience using fcntl?
| [reply] |
AFAIK using fcntl to lock a file on an NFS partition either does not work at all, or is extremely iffy.
Personally I've used the technique described in Stevens' Unix Network Programming, which goes something like this:
Create a temp file on the NFS partition
Try to link this temp file to a lock file (using the link() call)
If the link fails with EEXIST someone else already has the lock, so sleep for a bit and try again
If the link succeeds you've got your lock, so delete the tempfile
Releasing a lock is simply a matter of deleting the lock file.
As lock files don't get automatically cleaned up you in case of abnormal termination you have to add some form of timeout and stale lock handling.
All in all I'd say that the NFSlock module suggested above is probably the best solution (unless you want to roll your own to work around new module installation issues...)
Michael
| [reply] |
We ended up downloading the NFSLock module and including it in the distribution. Seems to work in our tests. Thanks!!!
| [reply] |