From 08a3195989ceab4f125251811949e85431265fec Mon Sep 17 00:00:00 2001 From: vasiljevic Date: Fri, 10 Mar 2006 14:18:54 +0000 Subject: Finalization of the pipes are now solely done in TclpFinalizePipes and not over the thread-exit handler, because the order of actions the Tcl generic core will impose may result in cores/hangs if the thread exit handler tearis down pipes too early (see Bug # 1437595). --- win/tclWinPipe.c | 45 +++++++++++---------------------------------- 1 file changed, 11 insertions(+), 34 deletions(-) diff --git a/win/tclWinPipe.c b/win/tclWinPipe.c index 8dc41d0..e599b50 100644 --- a/win/tclWinPipe.c +++ b/win/tclWinPipe.c @@ -9,7 +9,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclWinPipe.c,v 1.33.2.15 2005/11/04 18:33:35 patthoyts Exp $ + * RCS: @(#) $Id: tclWinPipe.c,v 1.33.2.16 2006/03/10 14:18:54 vasiljevic Exp $ */ #include "tclWinInt.h" @@ -189,7 +189,6 @@ static void PipeCheckProc(ClientData clientData, int flags); static int PipeClose2Proc(ClientData instanceData, Tcl_Interp *interp, int flags); static int PipeEventProc(Tcl_Event *evPtr, int flags); -static void PipeExitHandler(ClientData clientData); static int PipeGetHandleProc(ClientData instanceData, int direction, ClientData *handlePtr); static void PipeInit(void); @@ -271,57 +270,35 @@ PipeInit() tsdPtr = TCL_TSD_INIT(&dataKey); tsdPtr->firstPipePtr = NULL; Tcl_CreateEventSource(PipeSetupProc, PipeCheckProc, NULL); - Tcl_CreateThreadExitHandler(PipeExitHandler, NULL); } } /* *---------------------------------------------------------------------- * - * PipeExitHandler -- - * - * This function is called to cleanup the pipe module before - * Tcl is unloaded. - * - * Results: - * None. - * - * Side effects: - * Removes the pipe event source. - * - *---------------------------------------------------------------------- - */ - -static void -PipeExitHandler( - ClientData clientData) /* Old window proc */ -{ - Tcl_DeleteEventSource(PipeSetupProc, PipeCheckProc, NULL); -} - -/* - *---------------------------------------------------------------------- - * * TclpFinalizePipes -- * - * This function is called to cleanup the process list before - * Tcl is unloaded. + * This function is called from Tcl_FinalizeThread to finalize the + * platform specific pipe subsystem. * * Results: * None. * * Side effects: - * Resets the process list. + * Removes the pipe event source. * *---------------------------------------------------------------------- */ void TclpFinalizePipes() -{ - Tcl_MutexLock(&pipeMutex); - initialized = 0; - Tcl_MutexUnlock(&pipeMutex); +{ + ThreadSpecificData *tsdPtr; + + tsdPtr = (ThreadSpecificData *)TclThreadDataKeyGet(&dataKey); + if (tsdPtr != NULL) { + Tcl_DeleteEventSource(PipeSetupProc, PipeCheckProc, NULL); + } } /* -- cgit v0.12