summaryrefslogtreecommitdiffstats
path: root/generic
diff options
context:
space:
mode:
authordgp <dgp@users.sourceforge.net>2014-05-16 19:11:49 (GMT)
committerdgp <dgp@users.sourceforge.net>2014-05-16 19:11:49 (GMT)
commit8899c7cda9cd674018d4cc5a807cdaa5076f0f02 (patch)
treeaada931c77b04e7334e751fc17c044500618a3ea /generic
parent46b60b08860ef3c85c1dc0a9250fd1c499714a6a (diff)
downloadtcl-8899c7cda9cd674018d4cc5a807cdaa5076f0f02.zip
tcl-8899c7cda9cd674018d4cc5a807cdaa5076f0f02.tar.gz
tcl-8899c7cda9cd674018d4cc5a807cdaa5076f0f02.tar.bz2
Improved use of EOF state to avoid worthless allocations.
Diffstat (limited to 'generic')
-rw-r--r--generic/tclIO.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index a128d7c..09fa55e 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -6079,6 +6079,18 @@ GetInput(
return EINVAL;
}
+ /*
+ * For a channel at EOF do not bother allocating buffers; there's
+ * nothing more to read. Avoid calling the driver inputproc in
+ * case some of them do not react well to additional calls after
+ * they've reported an eof state..
+ * TODO: Candidate for a can't happen panic.
+ */
+
+ if (GotFlag(statePtr, CHANNEL_EOF)) {
+ return 0;
+ }
+
/*
* First check for more buffers in the pushback area of the topmost
* channel in the stack and use them. They can be the result of a
@@ -6143,16 +6155,6 @@ GetInput(
statePtr->inQueueTail = bufPtr;
}
- /*
- * TODO - consider escape before buffer alloc
- * If EOF is set, we should avoid calling the driver because on some
- * platforms it is impossible to read from a device after EOF.
- */
-
- if (GotFlag(statePtr, CHANNEL_EOF)) {
- return 0;
- }
-
PreserveChannelBuffer(bufPtr);
nread = ChanRead(chanPtr, InsertPoint(bufPtr), toRead);