summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--generic/tclIO.c7
-rw-r--r--tests/ioTrans.test20
2 files changed, 26 insertions, 1 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 673497b..0087526 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -2342,7 +2342,7 @@ RecycleBuffer(
* Do we have to free the buffer to the OS?
*/
- if (mustDiscard) {
+ if (1 || mustDiscard) {
ReleaseChannelBuffer(bufPtr);
return;
}
@@ -5612,6 +5612,11 @@ DoReadChars(
ResetFlag(statePtr, CHANNEL_BLOCKED);
}
result = GetInput(chanPtr);
+if (chanPtr != statePtr->topChanPtr) {
+Tcl_Release(chanPtr);
+chanPtr = statePtr->topChanPtr;
+Tcl_Preserve(chanPtr);
+}
if (result != 0) {
if (result == EAGAIN) {
break;
diff --git a/tests/ioTrans.test b/tests/ioTrans.test
index b21d894..3bbd170 100644
--- a/tests/ioTrans.test
+++ b/tests/ioTrans.test
@@ -559,6 +559,26 @@ test iortrans-4.8.1 {chan read, bug 721ec69271} -setup {
rename foo {}
} -result {{read rt* {test data
}} file*}
+test iortrans-4.8.2 {chan read, bug 721ec69271} -setup {
+ set res {}
+} -match glob -body {
+ proc foo {fd args} {
+ handle.initialize
+ handle.finalize
+ lappend ::res $args
+ # Kill and recreate transform while it is operating
+ chan pop $fd
+ chan push $fd [list foo $fd]
+ return x
+ }
+ set c [chan push [set c [tempchan]] [list foo $c]]
+ chan configure $c -buffersize 1
+ lappend res [read $c]
+} -cleanup {
+ tempdone
+ rename foo {}
+} -result {{read rt* {test data
+}} file*}
test iortrans-4.9 {chan read, gets, bug 2921116} -setup {
set res {}
} -match glob -body {