Skip to content
Tcl Source Code History Of Ticket 3096275
Login

History Of Ticket 3096275

Artifacts Associated With Ticket 3096275

  1. Ticket change [2359aa3691] (rid 130910) by ferrieux on 2010-10-27 08:32:25:

    1. assignee initialized to: "andreas_kupries"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      The following script:
      
       fconfigure stdin -translation binary -blocking 0
       fconfigure stdout -buffering none -translation binary
       fcopy stdin stdout
      
      when fed by typing lines to stdin, will not output anything until either 4k have been typed or eof, despite the nonblocking mode on stdin.
      The same using an async fcopy, will work in a more responsive manner:
      
       fcopy stdin stdout -command done
       vwait forever
      
      This is a consequence of the following credo, in a comment in TclCopyChannel:
      
          /*
           * Set up the blocking mode appropriately. Background copies need
           * non-blocking channels. Foreground copies need blocking channels. If
           * there is an error, restore the old blocking mode.
           */
      
      As a consequence, while GetInput happily returns short reads, DoRead insists on filling up its 4k buffer.
      
      That is, sync fcopy will never pass short reads on to the output channel. Hence, sync fcopy is not adapted to live streams, while async fcopy is.
      
      This it at least surprising for the developer, since the sync/async fcopy decision is rather based on external considerations like "do I need to interleave it with other IO" or "do I need to keep a GUI responsive". The fact that chosing sync implies buffering by 4k is nowhere in the docs.
      
      Low prio because it's a Day-1 issue :/
      
      
    4. foundin initialized to: "None"
    5. is_private initialized to: "0"
    6. priority initialized to: "5 Medium"
    7. resolution initialized to: "None"
    8. status initialized to: "Open"
    9. submitter initialized to: "ferrieux"
    10. subsystem initialized to: "25. Channel System"
    11. title initialized to: "Sync fcopy buffers input"
    12. type initialized to: "Bug"
  2. Ticket change [a6d871f212] (rid 98674) by ferrieux on 2010-10-27 17:12:32:

    1. icomment:
      Attached tiny patch fixes the issue, by adding an allowShortReads flag to DoRead, for use only inside CopyData when the input channel is blocking. This allows to exploit the "half-blocking" semantics of pipes and sockets, which can do short reads in blocking mode, thus keeping the overall spirit of sync fcopy (ie don't use the event loop).
      
      Checked against the test suite.
      Again, this removes a day-1, but undocumented, limitation.
      Raising prio to ask for permission to commit.
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  3. Ticket change [4c8306ce41] (rid 126904) by ferrieux on 2010-10-27 17:12:33:

    1. priority changed to: "8"
  4. Add attachment "fcopysync.patch" [e92b8d0dba] (rid 104768) by ferrieux on 2010-10-27 17:13:15.

  5. Ticket change [2b2cba19fb] (rid 118696) by ferrieux on 2010-10-27 17:13:16:

    1. icomment:
      
      
      File Added - 391352: fcopysync.patch
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  6. Ticket change [bf2f24cee0] (rid 102215) by andreas_kupries on 2010-10-28 02:33:32:

    1. icomment:
      I can't see anything bad with this, except, maybe, that the sync fcopy go into a tight loop consuming lots of cpu because of a  continuous series of 0-char reads until  something is typed in.
      
      Would like to get a second opinion, assigning to Jeff.
      
      
      
    2. login: "andreas_kupries"
    3. mimetype: "text/plain"
    4. username: "andreas_kupries"
  7. Ticket change [4c95a9252d] (rid 126916) by andreas_kupries on 2010-10-28 02:33:33:

    1. assignee changed to: "hobbs"
  8. Ticket change [02bdaa0ec6] (rid 119697) by ferrieux on 2010-10-28 03:40:32:

    1. icomment:
      That can no more occur than before: the new behavior, allowShortReads, is only ever activated when 
      
                                    !GotFlag(inStatePtr, CHANNEL_NONBLOCKING)
      
      that is, only for a blocking channel, ie in sync fcopy.
      If you know of another situation yielding a busyloop, please elaborate.
      
      
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  9. Ticket change [e83ddea40c] (rid 104617) by dgp on 2010-11-04 20:47:51:

    1. assignee changed to: "dgp"
    2. priority changed to: "9 Immediate"
  10. Ticket change [4a6d215335] (rid 126534) by ferrieux on 2010-11-05 04:45:05:

    1. icomment:
      Also ran tclbench: no slowdown.
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  11. Ticket change [61bfd25895] (rid 92298) by ferrieux on 2010-12-13 20:30:44:

    1. resolution changed to: "Fixed"
  12. Ticket change [7f3a4f23ee] (rid 97537) by ferrieux on 2011-07-19 22:42:07:

    1. icomment:
      Any hope to review for 8.6.0 ?
      
      
    2. login: "ferrieux"
    3. mimetype: "text/plain"
    4. username: "ferrieux"
  13. Ticket change [e93262cdf7] (rid 104772) by ferrieux on 2011-08-19 03:24:24:

    1. closedate changed to: "2011-08-18T20:24:24"
    2. closer changed to: "ferrieux"
    3. icomment:
      Committed.
      
      
    4. login: "ferrieux"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "ferrieux"
  14. Ticket change [a1e8dc4f04] (rid 211820) by pooryorick on 2023-04-03 18:16:19:

    1. closedate changed to: "2460038.26133465"
    2. closer changed to: "pooryorick"
    3. comment changed to:
      The following script:
      
       fconfigure stdin -translation binary -blocking 0
       fconfigure stdout -buffering none -translation binary
       fcopy stdin stdout
      
      when fed by typing lines to stdin, will not output anything until either 4k have been typed or eof, despite the nonblocking mode on stdin.
      The same using an async fcopy, will work in a more responsive manner:
      
       fcopy stdin stdout -command done
       vwait forever
      
      This is a consequence of the following credo, in a comment in TclCopyChannel:
      
          /*
           * Set up the blocking mode appropriately. Background copies need
           * non-blocking channels. Foreground copies need blocking channels. If
           * there is an error, restore the old blocking mode.
           */
      
      As a consequence, while GetInput happily returns short reads, DoRead insists on filling up its 4k buffer.
      
      That is, sync fcopy will never pass short reads on to the output channel. Hence, sync fcopy is not adapted to live streams, while async fcopy is.
      
      This it at least surprising for the developer, since the sync/async fcopy decision is rather based on external considerations like "do I need to interleave it with other IO" or "do I need to keep a GUI responsive". The fact that chosing sync implies buffering by 4k is nowhere in the docs.
      
      Low prio because it's a Day-1 issue :/
      
    4. icomment:
      This report dealt with ReadBytes().  See also [9ca87e6286] for the same issue with ReadChars().
      
    5. login: "pooryorick"
    6. mimetype: "text/x-fossil-wiki"
    7. severity changed to: "Minor"