This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Never cache offset when the stream handle is not active (BZ #16680)


On Mon, Mar 10, 2014 at 05:53:06PM +0530, Siddhesh Poyarekar wrote:
> Hi,
> 
> The ftell implementation was made conservative to ensure that
> incorrectly cached offsets never affect it.  However, this causes
> problems for append mode when a file stream is rewound.
> 
> For a and a+ mode files in read mode, rewinding the stream should
> result in ftell returning 0 as the offset, but without caching, it
> just assumes that the file offset is the end of file (as opposed to
> SEEK_CUR, since rewind correctly sets it).  Now I couldn't find
> anything in POSIX that specifies the stream position after rewind()
> for a file opened in 'a' mode, but for 'a+' mode it should be set to
> 0.  For 'a' mode too, it probably makes sense to keep it set to 0 in
> the interest of retaining old behavior.
> 
> The best way to fix this would be to avoid caching the offset before
> the file handle is active.  With this change, the only time the offset
> cache is not reliable is when the file is writing in any of the append
> modes.

I'm confused. I thought we discussed before that caching the offset is
_always_ invalid when the file handle is not active. This is not
specific to append mode.

Rich


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]