Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: baa7fc48f9be2b0cf06a3bf920ffffd8881a74f3
Ticket: 2827000fffffffffffffffffffffffffffffffff
tcl incorrectly reports eof to application
User & Date: coldstore on 2009-07-25 13:19:52
Changes

  1. assignee changed to: "andreas_kupries"
  2. cmimetype changed to: "text/plain"
  3. comment changed to:
    attached is an annotated narrative log of an observed sequence of interactions by the refchan subsystem and this code http://code.google.com/p/wub/source/browse/trunk/Wub/Chan.tcl?r=1798
    
    A connected socket is passed as the 'chan' argument of Chan construction, which is [chan create]d as a refchan.
    
    In the narrative, some data is [read] pursuant to a [readable] event on the underlying socket.  Less data is returned by [Chan read] than is requested.  A buffer-full of data is requested (4096 bytes) but only 1440 bytes are available.
    
    The data is processed by the application, which then attempts to [read] (in non-blocking mode?) more data.  The application uses [gets] to parse a prefix of the 1440 bytes which are available, but it certainly does not consume the entirety.  It attempts to [read] some 20Kb more.
    
    Tcl [Chan watch]es the refchan, and soon after calls [Chan read] again  to request another buffer-full of data.  There has been no readable event triggering, nor has [chan postevent] been called by Chan.  Despite this, Tcl attempts to read.
    
    When there is no data available, as indicated by the return value of "" from [Chan read] upon this second attempt, Tcl indicates [eof] on the refchan.
    
    I would have expected Tcl not to call [Chan read] until after a [chan postevent] had been signalled to it by Chan.
    
    Observations:  The behaviour is intermittent, insofar as sometimes an identical socket interaction succeeds (though rarely.)  I have attempted to reproduce the behaviour in a localhost-connected socket, and failed.  I believe this is because the second and subsequent [Chan read]s succeed.
    
    I think it's likely that Tcl refchan is calling the refchan's read method inappropriately, and then interpreting the 0-length result as end of file even though it has received no indication from the refchan by means of postevent that it can expect any data to be available to read.
    
    
  4. foundin changed to: "obsolete: 8.6b1.1"
  5. is_private changed to: "0"
  6. priority changed to: "7 High"
  7. resolution changed to: "None"
  8. status changed to: "Open"
  9. submitter changed to: "coldstore"
  10. subsystem changed to: "25. Channel System"
  11. title changed to: "tcl incorrectly reports eof to application"
  12. type changed to: "Bug"