dougm 01/03/14 23:04:41 Modified: src/modules/perl modperl_callback.c modperl_config.c modperl_config.h modperl_interp.c modperl_types.h Log: support "PerlInterpLifetime handler" Revision Changes Path 1.29 +3 -5 modperl-2.0/src/modules/perl/modperl_callback.c Index: modperl_callback.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_callback.c,v retrieving revision 1.28 retrieving revision 1.29 diff -u -r1.28 -r1.29 --- modperl_callback.c 2001/03/15 05:42:15 1.28 +++ modperl_callback.c 2001/03/15 07:04:41 1.29 @@ -282,11 +282,9 @@ SvREFCNT_dec((SV*)av_args); #ifdef USE_ITHREADS - if (interp && MpInterpPUTBACK_On(interp)) { - /* XXX: might want to put interp back into available pool - * rather than have it marked as in_use for the lifetime of - * a request - */ + if (interp && MpInterpPUTBACK(interp)) { + /* PerlInterpLifetime handler */ + modperl_interp_unselect(interp); } #endif 1.22 +16 -5 modperl-2.0/src/modules/perl/modperl_config.c Index: modperl_config.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_config.c,v retrieving revision 1.21 retrieving revision 1.22 diff -u -r1.21 -r1.22 --- modperl_config.c 2001/03/15 02:17:35 1.21 +++ modperl_config.c 2001/03/15 07:04:41 1.22 @@ -234,7 +234,7 @@ #ifdef USE_ITHREADS static const char *MP_interp_lifetime_desc[] = { - "undef", "subrequest", "request", "connection", + "undef", "handler", "subrequest", "request", "connection", }; const char *modperl_interp_lifetime_desc(modperl_interp_lifetime_e lifetime) @@ -242,14 +242,20 @@ return MP_interp_lifetime_desc[lifetime]; } -#define MP_INTERP_LIFETIME_OPTS "PerlInterpLifetime must be one of " +#define MP_INTERP_LIFETIME_USAGE "PerlInterpLifetime must be one of " #define MP_INTERP_LIFETIME_DIR_OPTS \ -MP_INTERP_LIFETIME_OPTS "subrequest or request" +"handler, subrequest or request" +#define MP_INTERP_LIFETIME_DIR_USAGE \ +MP_INTERP_LIFETIME_USAGE MP_INTERP_LIFETIME_DIR_OPTS + #define MP_INTERP_LIFETIME_SRV_OPTS \ -MP_INTERP_LIFETIME_OPTS "subrequest, request or connection" +"connection, " MP_INTERP_LIFETIME_DIR_OPTS +#define MP_INTERP_LIFETIME_SRV_USAGE \ +MP_INTERP_LIFETIME_USAGE MP_INTERP_LIFETIME_SRV_OPTS + MP_DECLARE_SRV_CMD(interp_lifetime) { modperl_interp_lifetime_e *lifetime; @@ -260,6 +266,11 @@ lifetime = is_per_dir ? &dcfg->interp_lifetime : &scfg->interp_lifetime; switch (toLOWER(*arg)) { + case 'h': + if (strcaseEQ(arg, "handler")) { + *lifetime = MP_INTERP_LIFETIME_HANDLER; + break; + } case 's': if (strcaseEQ(arg, "subrequest")) { *lifetime = MP_INTERP_LIFETIME_SUBREQUEST; @@ -277,7 +288,7 @@ } default: return is_per_dir ? - MP_INTERP_LIFETIME_DIR_OPTS : MP_INTERP_LIFETIME_SRV_OPTS; + MP_INTERP_LIFETIME_DIR_USAGE : MP_INTERP_LIFETIME_SRV_USAGE; }; return NULL; 1.20 +3 -0 modperl-2.0/src/modules/perl/modperl_config.h Index: modperl_config.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_config.h,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- modperl_config.h 2001/03/14 08:22:48 1.19 +++ modperl_config.h 2001/03/15 07:04:41 1.20 @@ -40,6 +40,9 @@ #define modperl_interp_lifetime_undef(dcfg) \ (dcfg->interp_lifetime == MP_INTERP_LIFETIME_UNDEF) +#define modperl_interp_lifetime_handler(dcfg) \ +(dcfg->interp_lifetime == MP_INTERP_LIFETIME_HANDLER) + #define modperl_interp_lifetime_subrequest(dcfg) \ (dcfg->interp_lifetime == MP_INTERP_LIFETIME_SUBREQUEST) 1.25 +25 -14 modperl-2.0/src/modules/perl/modperl_interp.c Index: modperl_interp.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_interp.c,v retrieving revision 1.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- modperl_interp.c 2001/03/15 04:34:04 1.24 +++ modperl_interp.c 2001/03/15 07:04:41 1.25 @@ -189,6 +189,7 @@ modperl_interp_pool_t *mip = interp->mip; MpInterpIN_USE_Off(interp); + MpInterpPUTBACK_Off(interp); modperl_tipool_putback_data(mip->tipool, data, interp->num_requests); @@ -237,6 +238,9 @@ MP_TRACE_i(MP_FUNC, "lifetime is per-%s\n", modperl_interp_lifetime_desc(lifetime)); + /* + * XXX: goto modperl_interp_get() if lifetime == handler ? + */ if (is_subrequest && (lifetime == MP_INTERP_LIFETIME_REQUEST)) { /* share 1 interpreter across sub-requests */ r = r->main; @@ -282,26 +286,33 @@ p = r->pool; } - if (!p) { - /* should never happen */ - MP_TRACE_i(MP_FUNC, "no pool\n"); - return NULL; - } - interp = modperl_interp_get(s ? s : r->server); ++interp->num_requests; /* should only get here once per request */ - (void)apr_pool_userdata_set((void *)interp, MP_INTERP_KEY, - modperl_interp_unselect, - p); + if (lifetime == MP_INTERP_LIFETIME_HANDLER) { + /* caller is responsible for calling modperl_interp_unselect() */ + MpInterpPUTBACK_On(interp); + } + else { + if (!p) { + /* should never happen */ + MP_TRACE_i(MP_FUNC, "no pool\n"); + return NULL; + } + (void)apr_pool_userdata_set((void *)interp, MP_INTERP_KEY, + modperl_interp_unselect, + p); + + MP_TRACE_i(MP_FUNC, + "set interp 0x%lx in %s 0x%lx (%s request for %s)\n", + (unsigned long)interp, desc, (unsigned long)p, + (r ? (is_subrequest ? "sub" : "main") : "conn"), + (r ? rr->uri : c->remote_ip)); + } + /* set context (THX) for this thread */ PERL_SET_CONTEXT(interp->perl); - - MP_TRACE_i(MP_FUNC, "set interp 0x%lx in %s 0x%lx (%s request for %s)\n", - (unsigned long)interp, desc, (unsigned long)p, - (r ? (is_subrequest ? "sub" : "main") : "conn"), - (r ? rr->uri : c->remote_ip)); return interp; } 1.26 +1 -0 modperl-2.0/src/modules/perl/modperl_types.h Index: modperl_types.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_types.h,v retrieving revision 1.25 retrieving revision 1.26 diff -u -r1.25 -r1.26 --- modperl_types.h 2001/03/15 02:17:35 1.25 +++ modperl_types.h 2001/03/15 07:04:41 1.26 @@ -111,6 +111,7 @@ typedef enum { MP_INTERP_LIFETIME_UNDEF, + MP_INTERP_LIFETIME_HANDLER, MP_INTERP_LIFETIME_SUBREQUEST, MP_INTERP_LIFETIME_REQUEST, MP_INTERP_LIFETIME_CONNECTION,