Stas Bekman <[EMAIL PROTECTED]> writes: > Joe Schaefer wrote: > > Stas Bekman <[EMAIL PROTECTED]> writes:
[...] > >>Anti-Example 1: parent interpreter compiles the anon-sub, which > >>interpreter are you going to stick to that anon-sub? > > A: As I stated, I expect the intepreter which invokes > > cleanup_register() to also be the one which executes the anonymous > > sub during $sp's pool cleanup. Are you saying that doesn't work if > > the interpreter is actually a clone, and not the parent? > > I think what happens is this: > > If the (very top) parent perl interpreter is attached to the cleanup hook > (which only makes sense for cleanup callbacks registered at the server > startup), there is no problem, since when those callbacks are called, > there are no more threads and all the calls will be serialized and > that interpreter will never be used at the same time by two threads > (since there are no threads on shutdown). > > but you can't stick that very top parent perl interpreter to an anon-sub, > because it's not thread safe. Agreed, in the abstract. So on to the next question- when does the parent interpreter have to deal with such anon-subs? Certainly during server config, when it encounters things like PerlResponseHandler 'sub { print "foo\n"; return OK }' Anywhere else besides the Perl*Handlers? Do the <Perl> sections a similar problem? If not, then a simple way to address this would be to have the parent interpreter not compile such strings, which might avoid the deparse overhead. > If you did, several threads may try to use the same interpreter at the > same time at run time. Moreover you aren't even allowed to use that > very top parent interpreter, nowhere but at the startup and shutdown. > > I hope that answers the question. I'm not sure why you are asking > about the clone, when there is already a problem with the top-level > perl, in the simplest case where there are no clones. I thought there was always at least one clone, and that the parent interpreter was reserved for just doing startup/shutdown/cloning: http://perl.apache.org/docs/2.0/user/design/design.html#Interpreter_Management When the server is started, a Perl interpreter is constructed, compiling any code specified in the configuration, just as 1.0 does. This interpreter is referred to as the "parent" interpreter. Then, for the number of PerlInterpStart configured, a (thread-safe) clone of the parent interpreter is made (via perl_clone()) and added to the pool of interpreters. This clone copies any writeable data (e.g. the symbol table) and shares the compiled syntax tree. -- Joe Schaefer --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]