diff options
author | hobbs <hobbs> | 2004-07-21 01:30:56 (GMT) |
---|---|---|
committer | hobbs <hobbs> | 2004-07-21 01:30:56 (GMT) |
commit | 1421351399efa280f6108d55bc38c5bc90051dcc (patch) | |
tree | 485b0b4f6b33aad1eb86cc5ec0ddf7c71966fd7c /win | |
parent | 3d2e7995dd6ea56840a0c4a2c00466ae914251db (diff) | |
download | tcl-1421351399efa280f6108d55bc38c5bc90051dcc.zip tcl-1421351399efa280f6108d55bc38c5bc90051dcc.tar.gz tcl-1421351399efa280f6108d55bc38c5bc90051dcc.tar.bz2 |
* generic/tclEvent.c: Correct threaded obj allocator to
* generic/tclInt.h: fully cleanup on exit and allow for
* generic/tclThreadAlloc.c: reinitialization. [Bug #736426]
* unix/tclUnixThrd.c: (mistachkin, kenny)
* win/tclWinThrd.c:
Diffstat (limited to 'win')
-rw-r--r-- | win/tclWinThrd.c | 35 |
1 files changed, 28 insertions, 7 deletions
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c index 4f0caac..c99f27b 100644 --- a/win/tclWinThrd.c +++ b/win/tclWinThrd.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: tclWinThrd.c,v 1.24.2.7 2004/07/19 19:23:03 vasiljevic Exp $ + * RCS: @(#) $Id: tclWinThrd.c,v 1.24.2.8 2004/07/21 01:30:58 hobbs Exp $ */ #include "tclWinInt.h" @@ -1038,17 +1038,20 @@ TclpFinalizeCondition(condPtr) * Additions by AOL for specialized thread memory allocator. */ #ifdef USE_THREAD_ALLOC +static int once; static DWORD key; +typedef struct allocMutex { + Tcl_Mutex tlock; + CRITICAL_SECTION wlock; +} allocMutex; + Tcl_Mutex * TclpNewAllocMutex(void) { - struct lock { - Tcl_Mutex tlock; - CRITICAL_SECTION wlock; - } *lockPtr; + struct allocMutex *lockPtr; - lockPtr = malloc(sizeof(struct lock)); + lockPtr = malloc(sizeof(struct allocMutex)); if (lockPtr == NULL) { panic("could not allocate lock"); } @@ -1057,10 +1060,19 @@ TclpNewAllocMutex(void) return &lockPtr->tlock; } +void +TclpFreeAllocMutex(mutex) + Tcl_Mutex *mutex; /* The alloc mutex to free. */ +{ + allocMutex* lockPtr = (allocMutex*) mutex; + if (!lockPtr) return; + DeleteCriticalSection(&lockPtr->wlock); + free(lockPtr); +} + void * TclpGetAllocCache(void) { - static int once = 0; VOID *result; if (!once) { @@ -1111,6 +1123,15 @@ TclWinFreeAllocCache(void) panic("TlsGetValue failed from TclWinFreeAllocCache!"); } } + + if (once) { + success = TlsFree(key); + if (!success) { + Tcl_Panic("TlsFree failed from TclWinFreeAllocCache!"); + } + + once = 0; /* reset for next time. */ + } } #endif /* USE_THREAD_ALLOC */ |