summaryrefslogtreecommitdiffstats
path: root/unix/tclUnixThrd.c
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2016-03-21 11:59:19 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2016-03-21 11:59:19 (GMT)
commit349c1fd2676793625cc0037a11d5989b0a591397 (patch)
tree0cda46a44d9942cfd39d10fb3008909c5b78847f /unix/tclUnixThrd.c
parent0aecb943f5d14659cbcee9ca6733c69744ffabe1 (diff)
parentc031c59ec3e4290d29f9c819b2640e90a176ad13 (diff)
downloadtcl-349c1fd2676793625cc0037a11d5989b0a591397.zip
tcl-349c1fd2676793625cc0037a11d5989b0a591397.tar.gz
tcl-349c1fd2676793625cc0037a11d5989b0a591397.tar.bz2
Fix [d3071887dbc7aeac]: Fix SEGV in Tcl_FinalizeNotifier(). Thanks to hirofumi for both the bug-report and the fix.
Use TclpMasterLock() in stead of MASTER_LOCK everywhere (in stead of in some files only, not in others). Use "static int initialized" variable consistantly. Fix some comments. No change of functionality.
Diffstat (limited to 'unix/tclUnixThrd.c')
-rw-r--r--unix/tclUnixThrd.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/unix/tclUnixThrd.c b/unix/tclUnixThrd.c
index ea03332..554a2dc 100644
--- a/unix/tclUnixThrd.c
+++ b/unix/tclUnixThrd.c
@@ -44,13 +44,6 @@ static pthread_mutex_t initLock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t allocLock = PTHREAD_MUTEX_INITIALIZER;
static pthread_mutex_t *allocLockPtr = &allocLock;
-/*
- * These are for the critical sections inside this file.
- */
-
-#define MASTER_LOCK pthread_mutex_lock(&masterLock)
-#define MASTER_UNLOCK pthread_mutex_unlock(&masterLock)
-
#endif /* TCL_THREADS */
/*
@@ -252,7 +245,7 @@ TclpInitLock(void)
/*
*----------------------------------------------------------------------
*
- * TclpFinalizeLock
+ * TclFinalizeLock
*
* This procedure is used to destroy all private resources used in this
* file.
@@ -421,7 +414,7 @@ Tcl_MutexLock(
pthread_mutex_t *pmutexPtr;
if (*mutexPtr == NULL) {
- MASTER_LOCK;
+ pthread_mutex_lock(&masterLock);
if (*mutexPtr == NULL) {
/*
* Double inside master lock check to avoid a race condition.
@@ -432,7 +425,7 @@ Tcl_MutexLock(
*mutexPtr = (Tcl_Mutex)pmutexPtr;
TclRememberMutex(mutexPtr);
}
- MASTER_UNLOCK;
+ pthread_mutex_unlock(&masterLock);
}
pmutexPtr = *((pthread_mutex_t **)mutexPtr);
pthread_mutex_lock(pmutexPtr);
@@ -529,7 +522,7 @@ Tcl_ConditionWait(
struct timespec ptime;
if (*condPtr == NULL) {
- MASTER_LOCK;
+ pthread_mutex_lock(&masterLock);
/*
* Double check inside mutex to avoid race, then initialize condition
@@ -542,7 +535,7 @@ Tcl_ConditionWait(
*condPtr = (Tcl_Condition) pcondPtr;
TclRememberCondition(condPtr);
}
- MASTER_UNLOCK;
+ pthread_mutex_unlock(&masterLock);
}
pmutexPtr = *((pthread_mutex_t **)mutexPtr);
pcondPtr = *((pthread_cond_t **)condPtr);