On 05.02.2013 18:25, Graham Dumpleton wrote:
If in the Apache parent process, you would still have to call Tcl_Finalize()
at some point wouldn't you to ensure that all memory is reclaimed?
I don't think so. If only because after calling Tcl_Finalize(), any other calls
into libtcl are "undefined" -- not supposed to happen. So, it can not be done on
graceful restart anyway. From Tcl's man-page:
Tcl_Finalize is similar to Tcl_Exit except that it does not exit from
the current process. It is useful for cleaning up when a process is
finished using Tcl but wishes to continue executing, and when Tcl is
used in a dynamically loaded extension that is about to be unloaded.
Your code should always invoke Tcl_Finalize when Tcl is being unloaded,
to ensure proper cleanup. Tcl_Finalize can be safely called more than
once.
One of the flaws early on in mod_python was that it didn't destroy the Python
interpreter. When an Apache restart was done, mod_python and the Python
library would be unloaded from memory. When the in process startup was done
after rereading the configuration Apache would load them again. Because it was
reloaded it was a completely clean set of static variables holding interpreter
state and so interpreter had to be reinitialised.
websh is already doing just the Tcl_DeleteInterpreter -- for the interpreter /it
created/. That seems like the right thing to do anyway.
If websh is wrong (and mod_rivet is right) in that an explicit call to
Tcl_Finalize is needed for an exiting process, then we are coming back to my
original question. Registering it as a clean-up call for the process' pool (as
wrowe@ suggested) seems like the best approach to that.
Yours,
-mi