diff options
author | dgp <dgp@noemail.net> | 2014-10-10 18:28:31 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2014-10-10 18:28:31 (GMT) |
commit | 7e962e561842f4590b89f665fbe30a010b420663 (patch) | |
tree | 2672197f64cbc03364e31cadfe5d7e2329df7f8d /generic | |
parent | 8559e3c72317c9e44e71caf24805ef1643dcc074 (diff) | |
parent | a1cf35d69047b7e6c66bc26dfd17fd1d2a8bdd9e (diff) | |
download | tcl-7e962e561842f4590b89f665fbe30a010b420663.zip tcl-7e962e561842f4590b89f665fbe30a010b420663.tar.gz tcl-7e962e561842f4590b89f665fbe30a010b420663.tar.bz2 |
[ed29c4da21] Merge patch from 8.5, still not a complete fix.
FossilOrigin-Name: 009cbc8def602d59b072c49eb236241ea401b122
Diffstat (limited to 'generic')
-rw-r--r-- | generic/tclIO.c | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index aea633c..3d36d45 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -9502,21 +9502,39 @@ DoRead( } /* - * If there is not enough data in the buffers to possibly - * complete the read, then go get more. + * Don't read more data if we have what we need. */ - if (bufPtr == NULL || BytesLeft(bufPtr) < bytesToRead) { + while (!bufPtr || /* We got no buffer! OR */ + (!IsBufferFull(bufPtr) && /* Our buffer has room AND */ + (BytesLeft(bufPtr) < bytesToRead) ) ) { + /* Not enough bytes in it + * yet to fill the dst */ + int code; + moreData: - if (GetInput(chanPtr)) { + code = GetInput(chanPtr); + bufPtr = statePtr->inQueueHead; + + assert (bufPtr != NULL); + + if (GotFlag(statePtr, CHANNEL_EOF|CHANNEL_BLOCKED)) { + /* Further reads cannot do any more */ + break; + } + + if (code) { /* Read error */ UpdateInterest(chanPtr); TclChannelRelease((Tcl_Channel)chanPtr); return -1; } - bufPtr = statePtr->inQueueHead; + + assert (IsBufferFull(bufPtr)); } + assert (bufPtr != NULL); + bytesRead = BytesLeft(bufPtr); bytesWritten = bytesToRead; |