diff options
Diffstat (limited to 'generic/tclNotify.c')
-rw-r--r-- | generic/tclNotify.c | 25 |
1 files changed, 16 insertions, 9 deletions
diff --git a/generic/tclNotify.c b/generic/tclNotify.c index 3f62d1a..e5a438f 100644 --- a/generic/tclNotify.c +++ b/generic/tclNotify.c @@ -14,7 +14,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tclNotify.c,v 1.15 2004/07/15 21:17:03 vasiljevic Exp $ + * RCS: @(#) $Id: tclNotify.c,v 1.16 2004/11/30 19:34:49 dgp Exp $ */ #include "tclInt.h" @@ -81,7 +81,7 @@ static Tcl_ThreadDataKey dataKey; * be replaced with a hashtable. */ -static ThreadSpecificData *firstNotifierPtr; +static ThreadSpecificData *firstNotifierPtr = NULL; TCL_DECLARE_MUTEX(listLock) /* @@ -111,15 +111,22 @@ static void QueueEvent _ANSI_ARGS_((ThreadSpecificData *tsdPtr, void TclInitNotifier() { - ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); + ThreadSpecificData *tsdPtr; + Tcl_ThreadId threadId = Tcl_GetCurrentThread(); Tcl_MutexLock(&listLock); - - tsdPtr->threadId = Tcl_GetCurrentThread(); - tsdPtr->clientData = tclStubs.tcl_InitNotifier(); - tsdPtr->nextPtr = firstNotifierPtr; - firstNotifierPtr = tsdPtr; - + for (tsdPtr = firstNotifierPtr; tsdPtr && tsdPtr->threadId != threadId; + tsdPtr = tsdPtr->nextPtr) { + /* Empty loop body. */ + } + if (NULL == tsdPtr) { + /* Notifier not yet initialized in this thread */ + tsdPtr = TCL_TSD_INIT(&dataKey); + tsdPtr->threadId = threadId; + tsdPtr->clientData = tclStubs.tcl_InitNotifier(); + tsdPtr->nextPtr = firstNotifierPtr; + firstNotifierPtr = tsdPtr; + } Tcl_MutexUnlock(&listLock); } |