Hi monks,
I'm working on some code that needs to do file locking over NFS using fcntl(). Flock won't work because of Red Hat deciding to remove flock() support from their NFS client in Red Hat Enterprise Linux 3 (see
this recent thread). One thing I'm seeing different between fcntl() and flock() is the way they handle multiple locks on the same file. For instance:
Say I open a filehandle and get a F_RDLCK on it to prevent anyone else from writing to the file. I later call up a subroutine which also opens the file and puts a F_RDLCK on it, does something, then closes it's handle. With flock(), the original file handle still has a lock on the file. With fcntl(), closing the second filehandle clears both of the locks, so the file is now completely unlocked.
Is there a good way of making fcntl behave more like flock()? In other words, is there a way to do file locking over NFS with fcntl() in which when multiple handles are opened on the same file, closing one handle doesn't clear everyone else's locks?
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.