Skip to content
Tcl Source Code History Of Ticket 1749581
Login

History Of Ticket 1749581

Artifacts Associated With Ticket 1749581

  1. Ticket change [93b3bd781f] (rid 105861) by mpc_janssen on 2007-07-07 12:39:41:

    1. assignee initialized to: "andreas_kupries"
    2. cmimetype initialized to: "text/plain"
    3. comment initialized to:
      When a socket is configured non-blocking, chan pending is not updated if [gets] is not called.
      For example the following script, will:
      
      1) Always puts 0 to stdout
      2) Fire the event handler very rapidly.
      
      # -----
      socket -server test 80
      
      proc test {sock args} {
         fileevent $sock readable  [list pending $sock]
         fconfigure $sock -blocking 0
      }
      
      proc pending {sock} {
         puts [chan pending input $sock]
      }
      
      vwait forever
      # -----
      
      If a [gets $sock] is added in the pending proc, the chan pending result will be correct and the readable event will not continue to fire.
      
      This will limit the usefulness of chan pending in cases where the read data is not line based (and thus gets is not a good fit)
      
      Furthermore, the behaviour is not consistent with the manual page which states:
      
      returns the number of bytes of input or output (respectively) currently buffered internally for channelId
      
      Nowhere does it state that chan pending will only be updated after a unsuccesful input operation (which can only be achieved by [gets], because read always returns some data (in the unblocking case)). 
      
      Additional info:
      
      > tclsh
      % parray tcl_platform
      tcl_platform(byteOrder)   = littleEndian
      tcl_platform(machine)     = intel
      tcl_platform(os)          = Windows NT
      tcl_platform(osVersion)   = 5.1
      tcl_platform(platform)    = windows
      tcl_platform(pointerSize) = 4
      tcl_platform(user)        = mjanssen
      tcl_platform(wordSize)    = 4
      % info patch
      8.5a7
       
      
    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: "mpc_janssen"
    10. subsystem initialized to: "24. Channel Commands"
    11. title initialized to: "chan pending not updated without a gets"
    12. type initialized to: "Bug"
  2. Ticket change [ab5ede410f] (rid 101093) by mpc_janssen on 2007-08-15 06:50:06:

    1. closedate changed to: "2007-08-14T23:50:06"
    2. closer changed to: "mpc_janssen"
    3. icomment:
      Logged In: YES 
      user_id=1463011
      Originator: YES
      
      The behaviour as observed is correct, because chan pending only is useful after an input command. I was really barking up against the wrong tree here. The real issue was that read and gets behave fundamentally different in non-blocking mode. Gets will only return a full line. read will return whatever it has regardless of what you asked for.
      If read's behaviour would be made the same as gets, chan pending and fblocked would make sense for read also and lessen the bookkeeping burden on the programmer as well.
      
      
    4. login: "mpc_janssen"
    5. mimetype: "text/plain"
    6. status changed to: "Closed"
    7. username: "mpc_janssen"