summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authorpooryorick <com.digitalsmarties@pooryorick.com>2022-12-29 22:59:10 (GMT)
committerpooryorick <com.digitalsmarties@pooryorick.com>2022-12-29 22:59:10 (GMT)
commit3b45005127de0885251471d5591ecb58c5b3e286 (patch)
tree4238093e3a8693f627e9bb49280fce41366cf5b2 /generic
parent0f0fc59c9f5baa2fa6841ad31a4064b4ac16a553 (diff)
downloadtcl-3b45005127de0885251471d5591ecb58c5b3e286.zip
tcl-3b45005127de0885251471d5591ecb58c5b3e286.tar.gz
tcl-3b45005127de0885251471d5591ecb58c5b3e286.tar.bz2
Arrange new code in DoReadChars to ensure that final steps are always taken.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIO.c28
1 files changed, 15 insertions, 13 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 63b9a7d..9ae8fb5 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -6024,8 +6024,9 @@ DoReadChars(
}
if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR)) {
- /* TODO: We don't need this call? */
+ /* TODO: UpdateInterest not needed here? */
UpdateInterest(chanPtr);
+
Tcl_SetErrno(EILSEQ);
return -1;
}
@@ -6041,7 +6042,7 @@ DoReadChars(
assert(statePtr->inputEncodingFlags & TCL_ENCODING_END);
assert(!GotFlag(statePtr, CHANNEL_BLOCKED|INPUT_SAW_CR));
- /* TODO: UpdateInterest isn't needed here? */
+ /* TODO: UpdateInterest not needed here? */
UpdateInterest(chanPtr);
return 0;
}
@@ -6055,7 +6056,7 @@ DoReadChars(
}
ResetFlag(statePtr, CHANNEL_BLOCKED|CHANNEL_EOF);
statePtr->inputEncodingFlags &= ~TCL_ENCODING_END;
- /* TODO: UpdateInterest isn't needed here? */
+ /* TODO: UpdateInterest not needed here? */
UpdateInterest(chanPtr);
return 0;
}
@@ -6084,18 +6085,9 @@ DoReadChars(
} else {
copiedNow = ReadChars(statePtr, objPtr, toRead, &factor);
}
- if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR) && !GotFlag(statePtr, CHANNEL_NONBLOCKING)) {
- /* Channel is Synchronous. Return an error so that [read] and
- * friends can return an error
- */
- TclChannelRelease((Tcl_Channel)chanPtr);
- UpdateInterest(chanPtr);
- Tcl_SetErrno(EILSEQ);
- return -1;
- }
/*
- * If the current buffer is empty recycle it.
+ * Recycle current buffer if empty.
*/
bufPtr = statePtr->inQueueHead;
@@ -6108,6 +6100,15 @@ DoReadChars(
statePtr->inQueueTail = NULL;
}
}
+
+ if (GotFlag(statePtr, CHANNEL_ENCODING_ERROR) && !GotFlag(statePtr, CHANNEL_NONBLOCKING)) {
+ /* Channel is synchronous. Return an error so that callers
+ * like [read] can return an error.
+ */
+ Tcl_SetErrno(EILSEQ);
+ copied = -1;
+ goto finish;
+ }
}
if (copiedNow < 0) {
@@ -6136,6 +6137,7 @@ DoReadChars(
}
}
+finish:
/*
* Failure to fill a channel buffer may have left channel reporting a
* "blocked" state, but so long as we fulfilled the request here, the