summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavygrvy <davygrvy@pobox.com>2004-05-06 01:02:58 (GMT)
committerdavygrvy <davygrvy@pobox.com>2004-05-06 01:02:58 (GMT)
commit84a75075141136a76e5f65c8e3c322704de6b830 (patch)
tree8be2eee4339ed42785159834b5069e9f59dc7f0f
parent67c13e8ce843ef9594171c0789af6bbce954ab5c (diff)
downloadtcl-84a75075141136a76e5f65c8e3c322704de6b830.zip
tcl-84a75075141136a76e5f65c8e3c322704de6b830.tar.gz
tcl-84a75075141136a76e5f65c8e3c322704de6b830.tar.bz2
* generic/tclInt.h:
* generic/tclThread.c: * generic/tclEvent.c: * unix/tclUnixThrd.c: * win/tclWinThrd.c: Provisions made so masterLock, initLock, allocLock and joinLock mutexes can be recovered during Tcl_Finalize.
-rw-r--r--generic/tclInt.h3
-rw-r--r--generic/tclThread.c8
-rw-r--r--unix/tclUnixThrd.c30
-rw-r--r--win/tclWinThrd.c41
4 files changed, 72 insertions, 10 deletions
diff --git a/generic/tclInt.h b/generic/tclInt.h
index 18438e2..7282343 100644
--- a/generic/tclInt.h
+++ b/generic/tclInt.h
@@ -12,7 +12,7 @@
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
- * RCS: @(#) $Id: tclInt.h,v 1.118.2.4 2004/03/29 18:49:36 hobbs Exp $
+ * RCS: @(#) $Id: tclInt.h,v 1.118.2.5 2004/05/06 01:02:58 davygrvy Exp $
*/
#ifndef _TCLINT
@@ -1635,6 +1635,7 @@ EXTERN void TclFinalizeMemorySubsystem _ANSI_ARGS_((void));
EXTERN void TclFinalizeNotifier _ANSI_ARGS_((void));
EXTERN void TclFinalizeAsync _ANSI_ARGS_((void));
EXTERN void TclFinalizeSynchronization _ANSI_ARGS_((void));
+EXTERN void TclFinalizeLock _ANSI_ARGS_((void));
EXTERN void TclFinalizeThreadData _ANSI_ARGS_((void));
EXTERN int TclGlob _ANSI_ARGS_((Tcl_Interp *interp,
char *pattern, Tcl_Obj *unquotedPrefix,
diff --git a/generic/tclThread.c b/generic/tclThread.c
index 5ddbb91..b0b2300 100644
--- a/generic/tclThread.c
+++ b/generic/tclThread.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: tclThread.c,v 1.6 2002/12/10 00:34:15 hobbs Exp $
+ * RCS: @(#) $Id: tclThread.c,v 1.6.2.1 2004/05/06 01:02:59 davygrvy Exp $
*/
#include "tclInt.h"
@@ -30,9 +30,9 @@ typedef struct {
char **list; /* List of pointers */
} SyncObjRecord;
-static SyncObjRecord keyRecord;
-static SyncObjRecord mutexRecord;
-static SyncObjRecord condRecord;
+static SyncObjRecord keyRecord = {0, 0, NULL};
+static SyncObjRecord mutexRecord = {0, 0, NULL};
+static SyncObjRecord condRecord = {0, 0, NULL};
/*
* Prototypes of functions used only in this file
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index 427a974..aa26c51 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -255,7 +255,37 @@ TclpInitLock()
pthread_mutex_lock(&initLock);
#endif
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclpFinalizeLock
+ *
+ * This procedure is used to destroy all private resources used in
+ * this file.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Destroys everything private. TclpInitLock must be held
+ * entering this function.
+ *
+ *----------------------------------------------------------------------
+ */
+void
+TclFinalizeLock ()
+{
+#ifdef TCL_THREADS
+ /*
+ * You do not need to destroy mutexes that were created with the
+ * PTHREAD_MUTEX_INITIALIZER macro. These mutexes do not need
+ * any destruction: masterLock, allocLock, and initLock.
+ */
+ pthread_mutex_unlock(&initLock);
+#endif
+}
/*
*----------------------------------------------------------------------
diff --git a/win/tclWinThrd.c b/win/tclWinThrd.c
index e09d327..558cee4 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.4 2004/04/23 07:17:39 davygrvy Exp $
+ * RCS: @(#) $Id: tclWinThrd.c,v 1.24.2.5 2004/05/06 01:03:14 davygrvy Exp $
*/
#include "tclWinInt.h"
@@ -44,6 +44,7 @@ static CRITICAL_SECTION initLock;
static CRITICAL_SECTION allocLock;
static Tcl_Mutex allocLockPtr = (Tcl_Mutex) &allocLock;
+static int allocOnce = 0;
#endif /* TCL_THREADS */
@@ -393,18 +394,48 @@ Tcl_Mutex *
Tcl_GetAllocMutex()
{
#ifdef TCL_THREADS
- static int once = 0;
-
- if (!once) {
+ if (!allocOnce) {
InitializeCriticalSection(&allocLock);
- once = 1;
+ allocOnce = 1;
}
return &allocLockPtr;
#else
return NULL;
#endif
}
+
+/*
+ *----------------------------------------------------------------------
+ *
+ * TclpFinalizeLock
+ *
+ * This procedure is used to destroy all private resources used in
+ * this file.
+ *
+ * Results:
+ * None.
+ *
+ * Side effects:
+ * Destroys everything private. TclpInitLock must be held
+ * entering this function.
+ *
+ *----------------------------------------------------------------------
+ */
+void
+TclFinalizeLock ()
+{
+ MASTER_LOCK;
+ DeleteCriticalSection(&joinLock);
+ DeleteCriticalSection(&masterLock);
+ init = 0;
+#ifdef TCL_THREADS
+ DeleteCriticalSection(&allocLock);
+ allocOnce = 0;
+#endif
+ /* Destroy the critical section that we are holding. */
+ DeleteCriticalSection(&initLock);
+}
#ifdef TCL_THREADS