diff options
Diffstat (limited to 'generic/tclIORChan.c')
-rw-r--r-- | generic/tclIORChan.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/generic/tclIORChan.c b/generic/tclIORChan.c index d93df6b..66a65b8 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.36 2009/01/09 11:21:46 dkf Exp $ + * RCS: @(#) $Id: tclIORChan.c,v 1.37 2009/01/22 00:11:24 andreas_kupries Exp $ */ #include <tclInt.h> @@ -1049,7 +1049,7 @@ ReflectClose( * 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 @@ -1137,13 +1137,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(); |