I am worried about perl or the OS performing read-ahead buffering as a result of the sysopen call. I am aware that flock is advisory locking, not mandatory. And I am assuming a local file system.

Clearly read-ahead buffering is normally done (at least on linux), since this post, for example, discusses controlling linux's read-ahead buffer size, and this post discusses controlling the read-ahead buffer size from perl. Therefore, given that read-ahead buffering is normally done, how can the above code possibly be safe? I am fully prepared to believe that it is, but I have not been able to find any authoritative evidence to support that belief, and I want my code to be safe.

For example, if flock was guaranteed to invalidate the read-ahead buffer, or if the act of another process writing to the file was guaranteed to immediately invalidate the read-ahead buffer, or if the read-ahead buffer was guaranteed to not be filled until this process did a read on the file handle, then the above code would indeed be safe. Can anyone point me to any evidence that that any of these is true, or any other evidence that indicates why the above code is safe, given the fact that read-ahead buffering normally occurs when reading a file?


In reply to Re^2: flock and read-ahead buffering on input by dbooth
in thread flock and read-ahead buffering on input by dbooth

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.