Artifacts Associated With Ticket 1749581
Ticket change [93b3bd781f] (rid 105861) by mpc_janssen on 2007-07-07 12:39:41:
- assignee initialized to: "andreas_kupries"
- cmimetype initialized to: "text/plain"
- 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 - foundin initialized to: "None"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "mpc_janssen"
- subsystem initialized to: "24. Channel Commands"
- title initialized to: "chan pending not updated without a gets"
- type initialized to: "Bug"
Ticket change [ab5ede410f] (rid 101093) by mpc_janssen on 2007-08-15 06:50:06:
- closedate changed to: "2007-08-14T23:50:06"
- closer changed to: "mpc_janssen"
- 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.
- login: "mpc_janssen"
- mimetype: "text/plain"
- status changed to: "Closed"
- username: "mpc_janssen"