dougm 01/03/13 21:22:51 Modified: src/modules/perl mod_perl.c modperl_callback.c modperl_config.c modperl_config.h modperl_interp.c modperl_types.h modperl_util.h Log: add PerlInterpLifetime directive default is request, when set to connection selected interpreter is held for lifetime of the connection Revision Changes Path 1.31 +5 -0 modperl-2.0/src/modules/perl/mod_perl.c Index: mod_perl.c =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.c,v retrieving revision 1.30 retrieving revision 1.31 diff -u -r1.30 -r1.31 --- mod_perl.c 2001/03/14 04:22:51 1.30 +++ mod_perl.c 2001/03/14 05:22:49 1.31 @@ -127,6 +127,9 @@ MP_dSCFG(s); #ifdef MP_TRACE char *name = modperl_server_desc(s, p); + + MP_TRACE_i(MP_FUNC, "PerlInterpLifetime set to %s for %s\n", + modperl_interp_lifetime_desc(scfg), name); #endif /* MP_TRACE */ if (scfg->mip->tipool->idle) { @@ -217,6 +220,8 @@ "Min number of spare Perl interpreters"), MP_SRV_CMD_TAKE1("PerlInterpMaxRequests", interp_max_requests, "Max number of requests per Perl interpreters"), + MP_SRV_CMD_TAKE1("PerlInterpLifetime", interp_lifetime, + "Lifetime of a Perl interpreter (connection or request)"), #endif MP_CMD_ENTRIES, { NULL }, 1.25 +3 -0 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.24 retrieving revision 1.25 diff -u -r1.24 -r1.25 --- modperl_callback.c 2001/03/14 00:37:52 1.24 +++ modperl_callback.c 2001/03/14 05:22:49 1.25 @@ -202,6 +202,9 @@ } #ifdef USE_ITHREADS + if (r && !c && modperl_interp_lifetime_connection(scfg)) { + c = r->connection; + } if (r || c) { p = c ? c->pool : r->pool; interp = modperl_interp_select(r, c, s); 1.19 +34 -0 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.18 retrieving revision 1.19 diff -u -r1.18 -r1.19 --- modperl_config.c 2001/03/09 23:46:35 1.18 +++ modperl_config.c 2001/03/14 05:22:49 1.19 @@ -127,6 +127,8 @@ (modperl_tipool_config_t *) apr_pcalloc(p, sizeof(*scfg->interp_pool_cfg)); + scfg->interp_lifetime = MP_INTERP_LIFETIME_REQUEST; + /* XXX: determine reasonable defaults */ scfg->interp_pool_cfg->start = 3; scfg->interp_pool_cfg->max_spare = 3; @@ -155,6 +157,7 @@ #ifdef USE_ITHREADS merge_item(mip); merge_item(interp_pool_cfg); + merge_item(interp_lifetime); #else merge_item(perl); #endif @@ -221,6 +224,37 @@ } #ifdef USE_ITHREADS + +static const char *MP_interp_lifetime_desc[] = { + "none", "request", "connection", +}; + +const char *modperl_interp_lifetime_desc(modperl_srv_config_t *scfg) +{ + return MP_interp_lifetime_desc[scfg->interp_lifetime]; +} + +MP_DECLARE_SRV_CMD(interp_lifetime) +{ + MP_dSCFG(parms->server); + + switch (toLOWER(*arg)) { + case 'r': + if (strcaseEQ(arg, "request")) { + scfg->interp_lifetime = MP_INTERP_LIFETIME_REQUEST; + break; + } + case 'c': + if (strcaseEQ(arg, "connection")) { + scfg->interp_lifetime = MP_INTERP_LIFETIME_CONNECTION; + break; + } + default: + return "PerlInterpLifetime must be one of connection or request"; + }; + + return NULL; +} #define MP_IMP_INTERP_POOL_CFG(xitem) \ const char *modperl_cmd_interp_##xitem(cmd_parms *parms, \ 1.18 +10 -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.17 retrieving revision 1.18 diff -u -r1.17 -r1.18 --- modperl_config.h 2001/03/09 23:46:35 1.17 +++ modperl_config.h 2001/03/14 05:22:49 1.18 @@ -33,6 +33,16 @@ MP_DECLARE_SRV_CMD(interp_max_spare); MP_DECLARE_SRV_CMD(interp_min_spare); MP_DECLARE_SRV_CMD(interp_max_requests); +MP_DECLARE_SRV_CMD(interp_lifetime); + +const char *modperl_interp_lifetime_desc(modperl_srv_config_t *scfg); + +#define modperl_interp_lifetime_connection(scfg) \ +(scfg->interp_lifetime == MP_INTERP_LIFETIME_CONNECTION) + +#define modperl_interp_lifetime_request(scfg) \ +(scfg->interp_lifetime == MP_INTERP_LIFETIME_REQUEST) + #endif #define MP_SRV_CMD_TAKE1(name, item, desc) \ 1.20 +4 -1 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.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- modperl_interp.c 2001/03/13 23:55:20 1.19 +++ modperl_interp.c 2001/03/14 05:22:49 1.20 @@ -205,11 +205,14 @@ modperl_interp_t *modperl_interp_select(request_rec *r, conn_rec *c, server_rec *s) { + MP_dSCFG(s); modperl_interp_t *interp; apr_pool_t *p = NULL; const char *desc = NULL; + int lifetime_connection = + (modperl_interp_lifetime_connection(scfg) || !r); - if (c) { + if (c && lifetime_connection) { desc = "conn_rec pool"; (void)apr_pool_userdata_get((void **)&interp, MP_INTERP_KEY, c->pool); 1.23 +7 -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.22 retrieving revision 1.23 diff -u -r1.22 -r1.23 --- modperl_types.h 2001/03/09 23:46:36 1.22 +++ modperl_types.h 2001/03/14 05:22:50 1.23 @@ -109,6 +109,12 @@ int unset; } modperl_options_t; +typedef enum { + MP_INTERP_LIFETIME_NONE, + MP_INTERP_LIFETIME_REQUEST, + MP_INTERP_LIFETIME_CONNECTION, +} modperl_interp_lifetime_e; + typedef struct { MpHV *SetVars; MpAV *PassEnv; @@ -120,6 +126,7 @@ #ifdef USE_ITHREADS modperl_interp_pool_t *mip; modperl_tipool_config_t *interp_pool_cfg; + modperl_interp_lifetime_e interp_lifetime; #else PerlInterpreter *perl; #endif 1.6 +7 -0 modperl-2.0/src/modules/perl/modperl_util.h Index: modperl_util.h =================================================================== RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_util.h,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- modperl_util.h 2001/03/14 04:22:51 1.5 +++ modperl_util.h 2001/03/14 05:22:50 1.6 @@ -7,6 +7,13 @@ #define MP_INLINE APR_INLINE #endif +#ifndef strcaseEQ +# define strcaseEQ(s1,s2) (!strcasecmp(s1,s2)) +#endif +#ifndef strncaseEQ +# define strncaseEQ(s1,s2,l) (!strncasecmp(s1,s2,l)) +#endif + MP_INLINE request_rec *modperl_sv2request_rec(pTHX_ SV *sv); MP_INLINE SV *modperl_ptr2obj(pTHX_ char *classname, void *ptr);