summaryrefslogtreecommitdiffstats
path: root/generic/tclIO.c
diff options
context:
space:
mode:
authorwelch <welch>1998-10-30 00:38:28 (GMT)
committerwelch <welch>1998-10-30 00:38:28 (GMT)
commit87056a32f65f4451dea20f209b70ca64277453ad (patch)
treef812290afe768219222e9256236b5169d9ba5820 /generic/tclIO.c
parent4cc4398f8553944112e0594446a0b88c3fa96e7a (diff)
downloadtcl-87056a32f65f4451dea20f209b70ca64277453ad.zip
tcl-87056a32f65f4451dea20f209b70ca64277453ad.tar.gz
tcl-87056a32f65f4451dea20f209b70ca64277453ad.tar.bz2
Fixed the Tcl_NotifyChannel bug, plus added a test case for it.
Simply replaced Tcl_RegisterChannel/UnregisterChannel with Tcl_Preserve/Tcl_Release was all it took. Chanels are already "eventually freed"
Diffstat (limited to 'generic/tclIO.c')
-rw-r--r--generic/tclIO.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/generic/tclIO.c b/generic/tclIO.c
index 6de1151..9725902 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.4 1998/09/14 18:39:59 stanton Exp $
+ * RCS: @(#) $Id: tclIO.c,v 1.5 1998/10/30 00:38:38 welch Exp $
*/
#include "tclInt.h"
@@ -4520,13 +4520,10 @@ Tcl_NotifyChannel(channel, mask)
NextChannelHandler nh;
/*
- * Prevent the event handler from deleting the channel by incrementing
- * the channel's ref count. Case in point: ChannelEventScriptInvoker()
- * was evaling a script (owned by the channel) which caused the channel
- * to be closed and then the byte codes no longer existed.
+ * Preserve the channel struct in case the script closes it.
*/
- Tcl_RegisterChannel((Tcl_Interp *) NULL, channel);
+ Tcl_Preserve((ClientData) channel);
/*
* If we are flushing in the background, be sure to call FlushChannel
@@ -4574,12 +4571,7 @@ Tcl_NotifyChannel(channel, mask)
UpdateInterest(chanPtr);
}
- /*
- * No longer need to protect the channel from being deleted.
- * After this point it is unsafe to use the value of "channel".
- */
-
- Tcl_UnregisterChannel((Tcl_Interp *) NULL, channel);
+ Tcl_Release((ClientData) channel);
nestedHandlerPtr = nh.nestedHandlerPtr;
}