summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-06-03 19:57:31 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-06-03 19:57:31 (GMT)
commit3c491801cbe73e305c0024a9b5bd80b7e474cabf (patch)
tree48debe3a1e9df42db2e038d0180766f3b4d9c154 /generic/tclIO.c
parentea994aa1957bd3faea8f4cdf2ae290d102ae1fe8 (diff)
parent2925ec375b371070e4955cfa6503a8dc4de45f68 (diff)
downloadtcl-3c491801cbe73e305c0024a9b5bd80b7e474cabf.zip
tcl-3c491801cbe73e305c0024a9b5bd80b7e474cabf.tar.gz
tcl-3c491801cbe73e305c0024a9b5bd80b7e474cabf.tar.bz2
merge fork of 8.5 branch
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c39
1 files changed, 20 insertions, 19 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 1c4a5b3..ed94bfe 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -2694,18 +2694,11 @@ FlushChannel(
(chanPtr->typePtr->watchProc)(chanPtr->instanceData,
statePtr->interestMask);
} else {
-
- /*
- * When we are calledFromAsyncFlush, that means a writable
- * state on the channel triggered the call, so we should be
- * able to write something. Either we did write something
- * and wroteSome should be set, or there was nothing left to
- * write in this call, and we've completed the BG flush.
- * These are the two cases above. If we get here, that means
- * there is some kind failure in the writable event machinery.
- */
-
- assert(!calledFromAsyncFlush);
+ /* TODO: If code reaches this point, it means a writable
+ * event is being handled on the channel, but the channel
+ * could not in fact be written to. This ought not happen,
+ * but Unix pipes appear to act this way (see io-53.4).
+ * Also can imagine broken reflected channels. */
}
}
@@ -3212,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();
}
@@ -7646,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;
+ }
}
/*