On 6 February 2013 10:53, Mikhail T. <mi+t...@aldan.algebra.com> wrote:

>  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,
>

It is not for an exiting process that is the problem. It is the module
cleanup, unloading and then reloading that occurs of the module within the
same Apache parent process when an Apache restart/graceful is done. The
main Apache parent process isn't actually killed in this situation.

So the section of documentation you quote appears to support what I am
saying that Tcl_Finalize() still needs to be called. After the module is
loaded and initialised again, then Tcl_Init(), or whatever is used to
create it again, would be called to start over and allow new instance of
interpreter to be setup in parent process before new child processes are
forked.

As I asked before, is this being done in the Apache parent process or only
in the child processes? If it is all only going on in the child processes,
the point I am making is moot, but if the interpreter is being initialised
in the Apache parent process before the fork, then it would be relevant.

Graham

Reply via email to