diff options
author | dgp <dgp@noemail.net> | 2014-08-22 13:23:04 (GMT) |
---|---|---|
committer | dgp <dgp@noemail.net> | 2014-08-22 13:23:04 (GMT) |
commit | ac135263d9945f0e8fdc4604250963cd3ac5bcc8 (patch) | |
tree | 5ce08e6e9a603476f670e79665f63e7efb7e3eac | |
parent | 04f2990ccc01da9010bc9b8de9a1a71506508a35 (diff) | |
parent | 91cb8cb97965e3ed55cf370627c72ab983335103 (diff) | |
download | tcl-ac135263d9945f0e8fdc4604250963cd3ac5bcc8.zip tcl-ac135263d9945f0e8fdc4604250963cd3ac5bcc8.tar.gz tcl-ac135263d9945f0e8fdc4604250963cd3ac5bcc8.tar.bz2 |
Correct performance regression in a series of short binary reads from a
socket. Many thanks to Eric Boudaillier for the report and testing support.
FossilOrigin-Name: 70e97884f0a0517b5dc380b9560a8951c4ee1b20
-rw-r--r-- | generic/tclIO.c | 26 |
1 files changed, 7 insertions, 19 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c index 4452ae9..93ac937 100644 --- a/generic/tclIO.c +++ b/generic/tclIO.c @@ -8853,34 +8853,22 @@ DoRead( break; } - /* If there is no full buffer, attempt to create and/or fill one. */ - - while (!IsBufferFull(bufPtr)) { - int code; + /* + * If there is not enough data in the buffers to possibly + * complete the read, then go get more. + */ + if (bufPtr == NULL || BytesLeft(bufPtr) < bytesToRead) { moreData: - 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) { + if (GetInput(chanPtr)) { /* Read error */ UpdateInterest(chanPtr); TclChannelRelease((Tcl_Channel)chanPtr); return -1; } - - assert (IsBufferFull(bufPtr)); + bufPtr = statePtr->inQueueHead; } - assert (bufPtr != NULL); - bytesRead = BytesLeft(bufPtr); bytesWritten = bytesToRead; |