Hi,

in case of a threaded server modperl_response_handler runs this code:

#ifdef USE_ITHREADS
    interp = modperl_interp_select(r, r->connection, r->server);
    aTHX = interp->perl;
#endif

while modperl_response_handler_cgi runs this:

#ifdef USE_ITHREADS
    interp = modperl_interp_select(r, r->connection, r->server);
    aTHX = interp->perl;
    if (MpInterpPUTBACK(interp)) {
        rcfg->interp = interp;
    }
#endif

then both call via modperl_response_handler_run and modperl_callback_per_dir 
modperl_callback_run_handlers which does then:

#ifdef USE_ITHREADS
    if (r && !c && modperl_interp_scope_connection(scfg)) {
        c = r->connection;
    }
    if (r || c) {
        interp = modperl_interp_select(r, c, s);
        aTHX = interp->perl;
    }
    else {
        /* Child{Init,Exit}, OpenLogs */
        aTHX = scfg->mip->parent->perl;
        PERL_SET_CONTEXT(aTHX);
    }
#endif

This means in both cases modperl_interp_select is called twice but for the 
perl-script case rcfg->interp = interp is set.

modperl_interp_select first looks if rcfg->interp is set and returns it. Only 
if it's not it looks at other places for an interpreter.

This means a perl-script handler needs 1 interpreter to handle the response 
phase while a modperl handler needs 2.

I noticed that with "PerlTrace i". I had installed handlers for Trans, 
MapToStorage, Fixup and Response. 2 interpreters were configured.

With a modperl handler I got this:

After Fixup:
modperl_tipool_putback_base: all items idle:
interp_pool_dump: listp==0x9467668, interp==0x8277740, requests=3
interp_pool_dump: listp==0xb78f2a0, interp==0xa3385a0, requests=0

"requests=3" means modperl_interp_select was run 3 times, once for Trans, once 
for MapToStorage and once for Fixup.

After Response:
modperl_tipool_putback_base: all items idle:
interp_pool_dump: listp==0x9467668, interp==0x8277740, requests=4
interp_pool_dump: listp==0xb78f2a0, interp==0xa3385a0, requests=1

Now it shows requests=4 for the first interpreter but requests=1 for the 2nd. 
I would have expected requests=4 and requests=0.

After scrutinizing the code I tried a perl-script handler and got this output.

After Fixup:
modperl_tipool_putback_base: all items idle:
interp_pool_dump: listp==0xc1235e8, interp==0x87ef068, requests=3
interp_pool_dump: listp==0xa5315e8, interp==0xc7ee558, requests=0

After Response:
modperl_tipool_putback_base: all items idle:
interp_pool_dump: listp==0xc1235e8, interp==0x87ef068, requests=4
interp_pool_dump: listp==0xa5315e8, interp==0xc7ee558, requests=0

This is what I'd have expected.

Torsten

Attachment: pgpoYCfg6yR64.pgp
Description: PGP signature

Reply via email to