Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: acfda7793f90e8f70ed660b9e371ec9cb1e7c3c6
Ticket: 2901998fffffffffffffffffffffffffffffffff
Inconsistent buffered I/O
User & Date: andreas_kupries on 2009-12-01 01:12:23
Changes

  1. icomment:
    Quoting Kevin Kenny from his mail on clt, this seems to be our best writeup so far of what we have to do:
    
    [...] the proposed solution entirely.  It's more or less:
    
      - Prior to a [read] (equivalently, a [gets]), check if there
        are buffered data to write. If there are, write them before
        reading the file. (Obviously, any data in read buffers may
        be retained.)
    
      - Prior to a [seek], check if there are buffered data to
        write. If there are, write them before seeking.
    
        There's an obvious performance tweak to bypass this flushing
        behaviour if the [seek] is not actually moving the cursor,
        and further performance might be obtainable if the library
        can determine that the new cursor is inside the current
        buffer. For now, I propose to ignore those optimizations,
        which represent an unusual case that requires a fair bit
        of bookkeeping to maintain consistency.
    
        As far as input buffers go, I'd propose flushing them on
        [seek] as well, but it wouldn't be a tremendous amount of
        bookkeeping to detect the case where the new cursor lies
        within the buffer and adjust accordingly. This issue might
        be worth doing, because there's a plausible case where a
        program will read data from a file, use the data just read
        to infer the file's encoding, seek back to the beginning,
        configure a new encoding and read again.
    
      - Prior to a [puts], spoil any buffered input data, which will
        be incoherent after the write.  If the current cursor lies
        within an input buffer, it might be possible to retain the
        buffer by overwriting the data therein with the newly-written
        data. Again, I propose simply to ignore the case.
    
      - Prior to a [truncate], flush write buffers and discard read
        buffers.
    
    
  2. login: "andreas_kupries"
  3. mimetype: "text/plain"
  4. username: "andreas_kupries"