summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorandreas_kupries <akupries@shaw.ca>2001-07-18 17:13:25 (GMT)
committerandreas_kupries <akupries@shaw.ca>2001-07-18 17:13:25 (GMT)
commit6cc38d5ff36cfbb941affae49796516273ec66a7 (patch)
tree75f253f099ade98f7839e25cc46fd31bd08f1c04
parent0b43f7ca80a834714b13d5566605c6060dd75eef (diff)
downloadtcl-6cc38d5ff36cfbb941affae49796516273ec66a7.zip
tcl-6cc38d5ff36cfbb941affae49796516273ec66a7.tar.gz
tcl-6cc38d5ff36cfbb941affae49796516273ec66a7.tar.bz2
2001-07-18 Andreas Kupries <andreas_kupries@users.sourceforge.net>
* generic/tclIO.c: Aftermath to [SF #427196]. Squash empty buffers if they are smaller than the requested buffersize, to prevent reusage of old buffers and to honor changes in the requested buffersize made by the user.
-rw-r--r--ChangeLog7
-rw-r--r--generic/tclIO.c26
2 files changed, 32 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index 079bd62..e0e03fd 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-07-18 Andreas Kupries <andreas_kupries@users.sourceforge.net>
+
+ * generic/tclIO.c: Aftermath to [SF #427196]. Squash empty buffers
+ if they are smaller than the requested buffersize, to prevent
+ reusage of old buffers and to honor changes in the requested
+ buffersize made by the user.
+
2001-07-17 Mo DeJong <mdejong@redhat.com>
* win/tclWinFile.c (TclpReadlink): Add Cygwin specific definition
diff --git a/generic/tclIO.c b/generic/tclIO.c
index fe233ad..7bd0938 100644
--- a/generic/tclIO.c
+++ b/generic/tclIO.c
@@ -10,7 +10,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclIO.c,v 1.31 2001/07/17 17:53:43 andreas_kupries Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.32 2001/07/18 17:13:25 andreas_kupries Exp $
*/
#include "tclInt.h"
@@ -1701,6 +1701,17 @@ RecycleBuffer(statePtr, bufPtr, mustDiscard)
}
/*
+ * Only save buffers which are at least as big as the requested
+ * buffersize for the channel. This is to honor dynamic changes
+ * of the buffersize made by the user.
+ */
+
+ if ((bufPtr->bufLength - BUFFER_PADDING) < statePtr->bufSize) {
+ ckfree((char *) bufPtr);
+ return;
+ }
+
+ /*
* Only save buffers for the input queue if the channel is readable.
*/
@@ -4994,6 +5005,19 @@ GetInput(chanPtr)
} else {
bufPtr = statePtr->saveInBufPtr;
statePtr->saveInBufPtr = NULL;
+
+ /*
+ * Check the actual buffersize against the requested
+ * buffersize. Buffers which are smaller than requested aare
+ * squashed. This is done to honor dynamic changes of the
+ * buffersize made by the user.
+ */
+
+ if ((bufPtr != NULL) && ((bufPtr->bufLength - BUFFER_PADDING) < statePtr->bufSize)) {
+ ckfree((char *) bufPtr);
+ bufPtr = NULL;
+ }
+
if (bufPtr == NULL) {
bufPtr = AllocChannelBuffer(statePtr->bufSize);
}