diff options
author | andreas_kupries <akupries@shaw.ca> | 2009-01-22 00:05:13 (GMT) |
---|---|---|
committer | andreas_kupries <akupries@shaw.ca> | 2009-01-22 00:05:13 (GMT) |
commit | 9c026cec4e9775bcdcc7009b9866e4e570ba8b6e (patch) | |
tree | 8097c6a97e5860763fd734684b098838804ea789 | |
parent | 22ce7af7758444030a12394242057ab031c2c739 (diff) | |
download | tcl-9c026cec4e9775bcdcc7009b9866e4e570ba8b6e.zip tcl-9c026cec4e9775bcdcc7009b9866e4e570ba8b6e.tar.gz tcl-9c026cec4e9775bcdcc7009b9866e4e570ba8b6e.tar.bz2 |
* generic/tclIORChan.c (ReflectClose): Fix for [Bug 2458202].
Closing a channel may supply NULL for the 'interp'. Test for
finalization needs to be different, and one place has to pull the
interp out of the channel instead.
-rw-r--r-- | ChangeLog | 7 | ||||
-rw-r--r-- | generic/tclIORChan.c | 21 |
2 files changed, 20 insertions, 8 deletions
@@ -1,3 +1,10 @@ +2009-01-21 Andreas Kupries <andreask@activestate.com> + + * generic/tclIORChan.c (ReflectClose): Fix for [Bug 2458202]. + Closing a channel may supply NULL for the 'interp'. Test for + finalization needs to be different, and one place has to pull the + interp out of the channel instead. + 2009-01-19 Kevin B. Kenny <kennykb@acm.org> * unix/Makefile.in: Added a CONFIG_INSTALL_DIR parameter so that diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index d13b9aac..c9a294b 100644 --- a/generic/tclIORChan.c +++ b/generic/tclIORChan.c @@ -15,7 +15,7 @@ * See the file "license.terms" for information on usage and redistribution of * this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclIORChan.c,v 1.28.2.5 2008/07/03 17:38:18 andreas_kupries Exp $ + * RCS: @(#) $Id: tclIORChan.c,v 1.28.2.6 2009/01/22 00:05:14 andreas_kupries Exp $ */ #include <tclInt.h> @@ -1046,7 +1046,7 @@ ReflectClose( ReflectedChannelMap* rcmPtr; /* Map of reflected channels with handlers in this interp */ Tcl_HashEntry* hPtr; /* Entry in the above map */ - if (interp == NULL) { + if (TclInThreadExit()) { /* * This call comes from TclFinalizeIOSystem. There are no * interpreters, and therefore we cannot call upon the handler command @@ -1134,13 +1134,18 @@ ReflectClose( * NOTE: The channel may not be in the map. This is ok, that happens * when the channel was created in a different interpreter and/or * thread and then was moved here. + * + * NOTE: The channel may have been removed from the map already via + * the per-interp DeleteReflectedChannelMap exit-handler. */ - - rcmPtr = GetReflectedChannelMap (interp); - hPtr = Tcl_FindHashEntry (&rcmPtr->map, - Tcl_GetChannelName (rcPtr->chan)); - if (hPtr) { - Tcl_DeleteHashEntry (hPtr); + + if (rcPtr->interp) { + rcmPtr = GetReflectedChannelMap (rcPtr->interp); + hPtr = Tcl_FindHashEntry (&rcmPtr->map, + Tcl_GetChannelName (rcPtr->chan)); + if (hPtr) { + Tcl_DeleteHashEntry (hPtr); + } } #ifdef TCL_THREADS rcmPtr = GetThreadReflectedChannelMap(); |