diff options
author | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-03-25 14:41:26 (GMT) |
---|---|---|
committer | jan.nijtmans <nijtmans@users.sourceforge.net> | 2016-03-25 14:41:26 (GMT) |
commit | 6cf1f7bacfe7e787c6468eed2b41194dd1c6e333 (patch) | |
tree | 3e0aa363fe324f88ce36cf4860d0eb3c0f5bfb19 /unix/tclUnixNotfy.c | |
parent | a4933e22d0b56bf07cf35cb90eb1f6fd6c9e48cb (diff) | |
parent | 77cc7b40aa68fe4c7ef545f76495ba18c4ace487 (diff) | |
download | tcl-6cf1f7bacfe7e787c6468eed2b41194dd1c6e333.zip tcl-6cf1f7bacfe7e787c6468eed2b41194dd1c6e333.tar.gz tcl-6cf1f7bacfe7e787c6468eed2b41194dd1c6e333.tar.bz2 |
- Undo unix notifier changes: too risky at this moment.
- Merge trunk
- (cherry-pick from dhr-micro-optimization): Micro-optimization: remove double checked lock from TclGetAllocCache in favour of initialization in TclInitSubsystems
Diffstat (limited to 'unix/tclUnixNotfy.c')
-rw-r--r-- | unix/tclUnixNotfy.c | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c index ca6a7ef..1457890 100644 --- a/unix/tclUnixNotfy.c +++ b/unix/tclUnixNotfy.c @@ -152,6 +152,7 @@ static int triggerPipe = -1; * The notifierMutex locks access to all of the global notifier state. */ +pthread_mutex_t notifierInitMutex = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t notifierMutex = PTHREAD_MUTEX_INITIALIZER; /* * The following static indicates if the notifier thread is running. @@ -280,7 +281,7 @@ static void StartNotifierThread(const char *proc) { if (!notifierThreadRunning) { - TclpMasterLock(); + pthread_mutex_lock(¬ifierInitMutex); if (!notifierThreadRunning) { if (TclpThreadCreate(¬ifierThread, NotifierThreadProc, NULL, TCL_THREAD_STACK_DEFAULT, TCL_THREAD_JOINABLE) != TCL_OK) { @@ -299,7 +300,7 @@ StartNotifierThread(const char *proc) notifierThreadRunning = 1; } - TclpMasterUnlock(); + pthread_mutex_unlock(¬ifierInitMutex); } } #endif /* TCL_THREADS */ @@ -361,7 +362,7 @@ Tcl_InitNotifier(void) tsdPtr->waitCVinitialized = 1; } - TclpMasterLock(); + pthread_mutex_lock(¬ifierInitMutex); #if defined(HAVE_PTHREAD_ATFORK) /* * Install pthread_atfork handlers to clean up the notifier in the @@ -380,7 +381,7 @@ Tcl_InitNotifier(void) notifierCount++; - TclpMasterUnlock(); + pthread_mutex_unlock(¬ifierInitMutex); #endif /* TCL_THREADS */ return tsdPtr; @@ -416,7 +417,7 @@ Tcl_FinalizeNotifier( #ifdef TCL_THREADS ThreadSpecificData *tsdPtr = TCL_TSD_INIT(&dataKey); - TclpMasterLock(); + pthread_mutex_lock(¬ifierInitMutex); notifierCount--; /* @@ -461,7 +462,7 @@ Tcl_FinalizeNotifier( #endif /* __CYGWIN__ */ tsdPtr->waitCVinitialized = 0; - TclpMasterUnlock(); + pthread_mutex_unlock(¬ifierInitMutex); #endif /* TCL_THREADS */ } } @@ -1367,7 +1368,7 @@ static void AtForkPrepare(void) { #if RESET_ATFORK_MUTEX == 0 - TclpMasterLock(); + pthread_mutex_lock(¬ifierInitMutex); #endif } @@ -1391,7 +1392,7 @@ static void AtForkParent(void) { #if RESET_ATFORK_MUTEX == 0 - TclpMasterUnlock(); + pthread_mutex_unlock(¬ifierInitMutex); #endif } @@ -1418,9 +1419,9 @@ AtForkChild(void) pthread_cond_destroy(¬ifierCV); } #if RESET_ATFORK_MUTEX == 0 - TclpMasterUnlock(); + pthread_mutex_unlock(¬ifierInitMutex); #else - TclpMasterReset(); + pthread_mutex_init(¬ifierInitMutex, NULL); pthread_mutex_init(¬ifierMutex, NULL); #endif pthread_cond_init(¬ifierCV, NULL); |