From 275aef21ecc230467a7849b792c43881b58557ff Mon Sep 17 00:00:00 2001 From: Joe Mistachkin Date: Mon, 28 Oct 2013 22:40:14 +0000 Subject: Another attempt to cleanup stale remnants of the notifier subsystem. --- unix/tclUnixNotfy.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/unix/tclUnixNotfy.c b/unix/tclUnixNotfy.c index 2440b01..69ef7f2 100644 --- a/unix/tclUnixNotfy.c +++ b/unix/tclUnixNotfy.c @@ -1320,6 +1320,8 @@ AtForkParentProc(void) static void AtForkChildProc(void) { + struct ThreadSpecificData *tsdPtr; + /* * Close the trigger pipe and reset it to the default value. This * should cause it to be re-opened when the notifier is subsequently @@ -1359,6 +1361,24 @@ AtForkChildProc(void) notifierCV = NULL; /* + * Free all the thread specific data for the notifier now. Since the + * child has no other threads, this data should be completely useless + * at this point. Unfortunately, there is currently no clean way to + * free the thread specific data structures themselves. + */ + + for (tsdPtr = waitingListPtr; tsdPtr; tsdPtr = tsdPtr->nextPtr) { + FileHandler *filePtr; + for (filePtr = tsdPtr->firstFileHandlerPtr; filePtr != NULL; + /* NO LOOP UPDATE */) { + FileHandler *nextFilePtr = filePtr->nextPtr; + ckfree((char *) filePtr); + filePtr = nextFilePtr; + } + } + waitingListPtr = 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 @@ -1378,6 +1398,13 @@ AtForkChildProc(void) 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. + */ + + dataKey = (Tcl_ThreadDataKey) 0; + + /* * 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. -- cgit v0.12