From 5399cdf3b1ddf72ac37efa3b23117cd69836552a Mon Sep 17 00:00:00 2001 From: Joe Mistachkin Date: Mon, 28 Oct 2013 21:01:47 +0000 Subject: Attempt to make sure the notifier gets fully re-initialized. --- unix/tclUnixNotfy.c | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c index 505d205..4ce4840 100644 --- a/unix/tclUnixNotfy.c +++ b/unix/tclUnixNotfy.c @@ -1344,21 +1344,38 @@ AtForkChildProc(void) /* * Reset the notifier reference count to zero (i.e. not initialized). * This should force the notifier initialization code to be re-run the - * very next time Tcl_InitNotifier is called. - * - * For a plain [exec ...] this will not happen, and everything is fine. - * For a full fork of the interpreter (like apache Rivet) it is not clear - * to me (AK) where TIN would be called. + * very next time Tcl_InitNotifier is called, which will be at the end + * of this function. */ notifierCount = 0; /* - * Finally, release the notifier mutex (which has been held since the - * AtForkPrepareProc() was called via pthread_atfork()). + * Finalize and reset the condition variable. This should force it to + * be re-created during the next call to Tcl_ConditionWait(). + */ + + Tcl_ConditionFinalize(¬ifierCV); + notifierCV = NULL; + + /* + * Release, finalize, and reset the notifier mutex (which has been + * held since the AtForkPrepareProc() was called via pthread_atfork()). + * This should force it to be re-created during the next call to + * Tcl_MutexLock(). */ Tcl_MutexUnlock(¬ifierMutex); + Tcl_MutexFinalize(¬ifierMutex); + notifierMutex = NULL; + + /* + * Force the notifier subsystem to be initialized now. This should + * create the notifier thread in this process. Subsequently, that new + * thread will re-open the trigger pipe. + */ + + Tcl_InitNotifier(); } #endif /* HAVE_PTHREAD_ATFORK */ -- cgit v0.12