Artifacts Associated With Ticket 3059220fffffffff
Ticket change [1a50187ea0] (rid 122961) by apnadkarni on 2010-09-04 05:18:51:
- assignee initialized to: "andreas_kupries"
- cmimetype initialized to: "text/plain"
- comment initialized to:
After writing consecutive newlines on a line buffered non-blocking channel pipe to a child process, the parent tclsh process seems to stop flushing further writes unless event loop is run. Windows XP, both 8.6 CVS head and 8.5.8 See sample session: % set fd [open {| ./tclsh85.exe} r+] file9cfd08 % fconfigure $fd -buffering line -blocking 0 % puts $fd {puts foo} ;# Ask child process to echo foo % gets $fd ; # Read back response foo % puts $fd {puts foo} ; # Once more just to verify % gets $fd foo % puts $fd { } % gets $fd ; # Fine, non-blocking, empty string returned as child was not asked to send back a response % puts $fd {puts foo} ; # Now retry previous command % gets $fd ; # Unlike before, no response, expected "foo" as before % flush $fd ; # SHould not be necessary, but just in case % gets $fd ; # flush no use % update ; # Run event loop % gets $fd ; Ah now channel gets flushed, and child returns response foo Not clear if above is a bug, or my understanding (that non-blocking I/O does not need the event loop if filevents are not being used) is incorrect. I don't see why the behaviour in echoing "foo" changes after writing the empty line Tracing indicates the following: - the data is not being flushed from the parent process output buffer - exiting the parent before the update results in all pending data being flushed (as expected). The child then sees that data (not shown above, but verified through logging) - Removing the -buffering line gets rid of the issue, at least for this particular sequence - if instead of writing puts { } you write puts "" on consecutive command lines, the problem does not show. /Ashok - foundin initialized to: "obsolete: 8.6b1.1"
- is_private initialized to: "0"
- priority initialized to: "5 Medium"
- resolution initialized to: "None"
- status initialized to: "Open"
- submitter initialized to: "apnadkarni"
- subsystem initialized to: "25. Channel System"
- title initialized to: "On Windows non-blocking pipe does not flush"
- type initialized to: "Bug"
Ticket change [910a7d8dc9] (rid 120563) by ferrieux on 2010-09-04 15:24:11:
- icomment:
Weird indeed :/ Not reproducible in Linux (too bad since we have strace). Just one minor comment about "non-blocking I/O does not need the event loop if filevents are not being used": The truth is that a nonblocking write that has been only partially done, because of a full pipe buffer for example, creates an internal "fileevent writable" to resubmit the rest when the channels unlocks. So this secondary IO needs the event loop. But in your example, the tiny strings you write to the child cannot be blamed for filling a pipe buffer (typically 4k)... Hence you are right that all these writes should be done immediately and completely. Random shots to probe the ugly internals of Windows IO: - try unbuffered - play with the crlf/binary translation - replace [puts \n] with [puts -nonewline \n\n]
- login: "ferrieux"
- mimetype: "text/plain"
- username: "ferrieux"
- icomment:
Ticket change [59220a6fac] (rid 139124) by apnadkarni on 2014-08-02 09:13:16:
- assignee changed to: "aku"
- closedate changed to: "2456871.88421294"
- closer changed to: "apnadkarni"
- comment changed to:
After writing consecutive newlines on a line buffered non-blocking channel pipe to a child process, the parent tclsh process seems to stop flushing further writes unless event loop is run. Windows XP, both 8.6 CVS head and 8.5.8 See sample session: % set fd [open {| ./tclsh85.exe} r+] file9cfd08 % fconfigure $fd -buffering line -blocking 0 % puts $fd {puts foo} ;# Ask child process to echo foo % gets $fd ; # Read back response foo % puts $fd {puts foo} ; # Once more just to verify % gets $fd foo % puts $fd { } % gets $fd ; # Fine, non-blocking, empty string returned as child was not asked to send back a response % puts $fd {puts foo} ; # Now retry previous command % gets $fd ; # Unlike before, no response, expected "foo" as before % flush $fd ; # SHould not be necessary, but just in case % gets $fd ; # flush no use % update ; # Run event loop % gets $fd ; Ah now channel gets flushed, and child returns response foo Not clear if above is a bug, or my understanding (that non-blocking I/O does not need the event loop if filevents are not being used) is incorrect. I don't see why the behaviour in echoing "foo" changes after writing the empty line Tracing indicates the following: - the data is not being flushed from the parent process output buffer - exiting the parent before the update results in all pending data being flushed (as expected). The child then sees that data (not shown above, but verified through logging) - Removing the -buffering line gets rid of the issue, at least for this particular sequence - if instead of writing puts { } you write puts "" on consecutive command lines, the problem does not show. /Ashok - icomment:
Closed my bug because fconfigure documentation states clearly (at least in the current version) that the event loop is required for non-blocking i/o to flush.
- login: "apnadkarni"
- mimetype: "text/plain"
- severity changed to: "Minor"
- status changed to: "Closed"