diff options
author | dgp <dgp@users.sourceforge.net> | 2014-06-03 17:32:33 (GMT) |
---|---|---|
committer | dgp <dgp@users.sourceforge.net> | 2014-06-03 17:32:33 (GMT) |
commit | 2925ec375b371070e4955cfa6503a8dc4de45f68 (patch) | |
tree | 48debe3a1e9df42db2e038d0180766f3b4d9c154 /generic/tclIO.c | |
parent | 255135d8edbce030f8090509d96551730d551add (diff) | |
parent | 531a58872c0aaacf53b20fb75d45687d144ec6e8 (diff) | |
download | tcl-2925ec375b371070e4955cfa6503a8dc4de45f68.zip tcl-2925ec375b371070e4955cfa6503a8dc4de45f68.tar.gz tcl-2925ec375b371070e4955cfa6503a8dc4de45f68.tar.bz2 |
Backport I/O core fixes made known by async socket work on trunk.
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r-- | generic/tclIO.c | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 0716074..ed94bfe 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -3205,11 +3205,18 @@ Tcl_Close( stickyError = 0; - if ((statePtr->encoding != NULL) - && !(statePtr->outputEncodingFlags & TCL_ENCODING_START) - && (CheckChannelErrors(statePtr, TCL_WRITABLE) == 0)) { - statePtr->outputEncodingFlags |= TCL_ENCODING_END; - if (WriteChars(chanPtr, "", 0) < 0) { + if (GotFlag(statePtr, TCL_WRITABLE) && (statePtr->encoding != NULL) + && !(statePtr->outputEncodingFlags & TCL_ENCODING_START)) { + + int code = CheckChannelErrors(statePtr, TCL_WRITABLE); + + if (code == 0) { + statePtr->outputEncodingFlags |= TCL_ENCODING_END; + code = WriteChars(chanPtr, "", 0); + statePtr->outputEncodingFlags &= ~TCL_ENCODING_END; + statePtr->outputEncodingFlags |= TCL_ENCODING_START; + } + if (code < 0) { stickyError = Tcl_GetErrno(); } @@ -7639,8 +7646,9 @@ Tcl_NotifyChannel( */ if (GotFlag(statePtr, BG_FLUSH_SCHEDULED) && (mask & TCL_WRITABLE)) { - FlushChannel(NULL, chanPtr, 1); - mask &= ~TCL_WRITABLE; + if (0 == FlushChannel(NULL, chanPtr, 1)) { + mask &= ~TCL_WRITABLE; + } } /* |