summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Mistachkin <joe@mistachkin.com>2013-10-29 00:19:22 (GMT)
committerJoe Mistachkin <joe@mistachkin.com>2013-10-29 00:19:22 (GMT)
commit9f9c9a2bc48662116c0a24f9e96ec85c081e500f (patch)
treeaebe3edf528bf2cfd5064ac0241700ab7533019d
parent6c8ec5a8fe406cf53341424e1529c9b0794b03ee (diff)
downloadtcl-9f9c9a2bc48662116c0a24f9e96ec85c081e500f.zip
tcl-9f9c9a2bc48662116c0a24f9e96ec85c081e500f.tar.gz
tcl-9f9c9a2bc48662116c0a24f9e96ec85c081e500f.tar.bz2
Some cleanup of the previous assumptions.
-rw-r--r--unix/tclUnixNotfy.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c
index 96b9636..abe371b 100644
--- a/unix/tclUnixNotfy.c
+++ b/unix/tclUnixNotfy.c
@@ -1320,6 +1320,7 @@ AtForkParentProc(void)
static void
AtForkChildProc(void)
{
+ int shouldInitNotifier = (notifierCount > 0); /* Only when in use? */
struct ThreadSpecificData *tsdPtr;
/*
@@ -1341,7 +1342,7 @@ AtForkChildProc(void)
* checked before it is re-created.
*/
- notifierThread = (Tcl_ThreadId) 0;
+ notifierThread = (Tcl_ThreadId)0;
/*
* Reset the notifier reference count to zero (i.e. not initialized).
@@ -1390,19 +1391,21 @@ AtForkChildProc(void)
/*
* Next, forcibly reset all the "one time" locks used by the threading
- * subsystem. This is necessary on some (all?) variants of Unix where
- * the pthread internal state does not survive a call to fork().
+ * subsystem. This may be necessary on some (all?) variants of Unix
+ * where the pthread internal state does not survive a call to fork().
*/
TclpResetLocks();
/*
- * Next, abandon the thread specific data for this file. There is no
- * clean way to free it; however, it can no longer be used.
+ * Next, attempt to free thread specific data for this module, if that
+ * is necessary.
*/
- Tcl_UnsetThreadData(&dataKey, sizeof(ThreadSpecificData), 1 /*all */);
- dataKey = (Tcl_ThreadDataKey) 0;
+ if (dataKey != (Tcl_ThreadDataKey)0) {
+ Tcl_UnsetThreadData(&dataKey, sizeof(ThreadSpecificData), 1 /*all */);
+ dataKey = (Tcl_ThreadDataKey)0;
+ }
/*
* Force the notifier subsystem to be initialized now. This should
@@ -1410,7 +1413,9 @@ AtForkChildProc(void)
* thread will re-open the trigger pipe.
*/
- Tcl_InitNotifier();
+ if (shouldInitNotifier) {
+ Tcl_InitNotifier();
+ }
}
#endif /* HAVE_PTHREAD_ATFORK */