diff options
| author | dgp <dgp@users.sourceforge.net> | 2014-05-16 19:11:49 (GMT) |
|---|---|---|
| committer | dgp <dgp@users.sourceforge.net> | 2014-05-16 19:11:49 (GMT) |
| commit | 5db8831fb0c3a4a23f76522925253fc64e07ff9d (patch) | |
| tree | aada931c77b04e7334e751fc17c044500618a3ea | |
| parent | 28721acb58b69d239e98cc2d8b852a56bc5ab27b (diff) | |
| download | tcl-5db8831fb0c3a4a23f76522925253fc64e07ff9d.zip tcl-5db8831fb0c3a4a23f76522925253fc64e07ff9d.tar.gz tcl-5db8831fb0c3a4a23f76522925253fc64e07ff9d.tar.bz2 | |
Improved use of EOF state to avoid worthless allocations.
| -rw-r--r-- | generic/tclIO.c | 22 |
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); |
