dougm       01/03/14 00:22:51

  Modified:    src/modules/perl mod_perl.c modperl_config.c
                        modperl_config.h modperl_interp.c modperl_types.h
  Log:
  allow PerlInterpLifetime to be per-dir for subrequest and request lifetime
  
  Revision  Changes    Path
  1.32      +3 -3      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.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- mod_perl.c        2001/03/14 05:22:49     1.31
  +++ mod_perl.c        2001/03/14 08:22:47     1.32
  @@ -129,7 +129,7 @@
           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);
  +                   modperl_interp_lifetime_desc(scfg->interp_lifetime), name);
   #endif /* MP_TRACE */
   
           if (scfg->mip->tipool->idle) {
  @@ -220,8 +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)"),
  +    MP_DIR_CMD_TAKE1("PerlInterpLifetime", interp_lifetime,
  +                     "Lifetime of a Perl interpreter"),
   #endif
       MP_CMD_ENTRIES,
       { NULL }, 
  
  
  
  1.20      +32 -7     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.19
  retrieving revision 1.20
  diff -u -r1.19 -r1.20
  --- modperl_config.c  2001/03/14 05:22:49     1.19
  +++ modperl_config.c  2001/03/14 08:22:48     1.20
  @@ -21,6 +21,12 @@
   void *modperl_create_dir_config(apr_pool_t *p, char *dir)
   {
       modperl_dir_config_t *dcfg = modperl_dir_config_new(p);
  +
  +#ifdef USE_ITHREADS
  +    /* defaults to per-server lifetime */
  +    dcfg->interp_lifetime = MP_INTERP_LIFETIME_UNDEF;
  +#endif
  +
       return dcfg;
   }
   
  @@ -226,31 +232,50 @@
   #ifdef USE_ITHREADS
   
   static const char *MP_interp_lifetime_desc[] = {
  -    "none", "request", "connection",
  +    "undef", "subrequest", "request", "connection",
   };
   
  -const char *modperl_interp_lifetime_desc(modperl_srv_config_t *scfg)
  +const char *modperl_interp_lifetime_desc(modperl_interp_lifetime_e lifetime)
   {
  -    return MP_interp_lifetime_desc[scfg->interp_lifetime];
  +    return MP_interp_lifetime_desc[lifetime];
   }
   
  +#define MP_INTERP_LIFETIME_OPTS "PerlInterpLifetime must be one of "
  +
  +#define MP_INTERP_LIFETIME_DIR_OPTS \
  +MP_INTERP_LIFETIME_OPTS "subrequest or request"
  +
  +#define MP_INTERP_LIFETIME_SRV_OPTS \
  +MP_INTERP_LIFETIME_OPTS "subrequest, request or connection"
  +
   MP_DECLARE_SRV_CMD(interp_lifetime)
   {
  +    modperl_interp_lifetime_e *lifetime;
  +    modperl_dir_config_t *dcfg = (modperl_dir_config_t *)dummy;
       MP_dSCFG(parms->server);
  +    int is_per_dir = parms->path ? 1 : 0;
  +
  +    lifetime = is_per_dir ? &dcfg->interp_lifetime : &scfg->interp_lifetime;
   
       switch (toLOWER(*arg)) {
  +      case 's':
  +        if (strcaseEQ(arg, "subrequest")) {
  +            *lifetime = MP_INTERP_LIFETIME_SUBREQUEST;
  +            break;
  +        }
         case 'r':
           if (strcaseEQ(arg, "request")) {
  -            scfg->interp_lifetime = MP_INTERP_LIFETIME_REQUEST;
  +            *lifetime = MP_INTERP_LIFETIME_REQUEST;
               break;
           }
         case 'c':
  -        if (strcaseEQ(arg, "connection")) {
  -            scfg->interp_lifetime = MP_INTERP_LIFETIME_CONNECTION;
  +        if (!is_per_dir && strcaseEQ(arg, "connection")) {
  +            *lifetime = MP_INTERP_LIFETIME_CONNECTION;
               break;
           }
         default:
  -        return "PerlInterpLifetime must be one of connection or request";
  +        return is_per_dir ?
  +            MP_INTERP_LIFETIME_DIR_OPTS : MP_INTERP_LIFETIME_SRV_OPTS;
       };
   
       return NULL;
  
  
  
  1.19      +13 -3     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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- modperl_config.h  2001/03/14 05:22:49     1.18
  +++ modperl_config.h  2001/03/14 08:22:48     1.19
  @@ -35,14 +35,20 @@
   MP_DECLARE_SRV_CMD(interp_max_requests);
   MP_DECLARE_SRV_CMD(interp_lifetime);
   
  -const char *modperl_interp_lifetime_desc(modperl_srv_config_t *scfg);
  +const char *modperl_interp_lifetime_desc(modperl_interp_lifetime_e lifetime);
   
  -#define modperl_interp_lifetime_connection(scfg) \
  -(scfg->interp_lifetime == MP_INTERP_LIFETIME_CONNECTION)
  +#define modperl_interp_lifetime_undef(dcfg) \
  +(dcfg->interp_lifetime == MP_INTERP_LIFETIME_UNDEF)
   
  +#define modperl_interp_lifetime_subrequest(dcfg) \
  +(dcfg->interp_lifetime == MP_INTERP_LIFETIME_SUBREQUEST)
  +
   #define modperl_interp_lifetime_request(scfg) \
   (scfg->interp_lifetime == MP_INTERP_LIFETIME_REQUEST)
   
  +#define modperl_interp_lifetime_connection(scfg) \
  +(scfg->interp_lifetime == MP_INTERP_LIFETIME_CONNECTION)
  +
   #endif
   
   #define MP_SRV_CMD_TAKE1(name, item, desc) \
  @@ -52,6 +58,10 @@
   #define MP_SRV_CMD_ITERATE(name, item, desc) \
      AP_INIT_ITERATE( name, modperl_cmd_##item, NULL, \
         RSRC_CONF, desc )
  +
  +#define MP_DIR_CMD_TAKE1(name, item, desc) \
  +    AP_INIT_TAKE1( name, modperl_cmd_##item, NULL, \
  +      OR_ALL, desc )
   
   #define modperl_request_config_init(r, rcfg) \
       if (!rcfg) { \
  
  
  
  1.22      +22 -5     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.21
  retrieving revision 1.22
  diff -u -r1.21 -r1.22
  --- modperl_interp.c  2001/03/14 06:57:43     1.21
  +++ modperl_interp.c  2001/03/14 08:22:48     1.22
  @@ -206,15 +206,32 @@
                                           server_rec *s)
   {
       MP_dSCFG(s);
  +    modperl_dir_config_t *dcfg = modperl_dir_config_get(rr);
  +    const char *desc = NULL;
       modperl_interp_t *interp;
       apr_pool_t *p = NULL;
  +    request_rec *r = rr;
       int is_subrequest = (rr && rr->main) ? 1 : 0;
  -    request_rec *r = is_subrequest ? rr->main : rr;
  -    const char *desc = NULL;
  -    int lifetime_connection = 
  -        (modperl_interp_lifetime_connection(scfg) || !r);
  +
  +    /*
  +     * if a per-dir PerlInterpLifetime is specified, use it.
  +     * else if r != NULL use per-server PerlInterpLifetime
  +     * else lifetime must be per-connection
  +     */
  +    modperl_interp_lifetime_e lifetime = 
  +        (dcfg && !modperl_interp_lifetime_undef(dcfg)) ? 
  +        dcfg->interp_lifetime :
  +        (r ? scfg->interp_lifetime : MP_INTERP_LIFETIME_CONNECTION);
  +
  +    MP_TRACE_i(MP_FUNC, "lifetime is per-%s\n",
  +               modperl_interp_lifetime_desc(lifetime));
  +
  +    if (is_subrequest && (lifetime == MP_INTERP_LIFETIME_REQUEST)) {
  +        /* share 1 interpreter across sub-requests */
  +        r = r->main;
  +    }
   
  -    if (c && lifetime_connection) {
  +    if (c && (lifetime == MP_INTERP_LIFETIME_CONNECTION)) {
           desc = "conn_rec pool";
           (void)apr_pool_userdata_get((void **)&interp, MP_INTERP_KEY, c->pool);
   
  
  
  
  1.24      +5 -1      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.23
  retrieving revision 1.24
  diff -u -r1.23 -r1.24
  --- modperl_types.h   2001/03/14 05:22:50     1.23
  +++ modperl_types.h   2001/03/14 08:22:48     1.24
  @@ -110,7 +110,8 @@
   } modperl_options_t;
   
   typedef enum {
  -    MP_INTERP_LIFETIME_NONE,
  +    MP_INTERP_LIFETIME_UNDEF,
  +    MP_INTERP_LIFETIME_SUBREQUEST,
       MP_INTERP_LIFETIME_REQUEST,
       MP_INTERP_LIFETIME_CONNECTION,
   } modperl_interp_lifetime_e;
  @@ -144,6 +145,9 @@
       MpHV *SetEnv;
       MpHV *SetVars;
       U8 flags;
  +#ifdef USE_ITHREADS
  +    modperl_interp_lifetime_e interp_lifetime;
  +#endif
   } modperl_dir_config_t;
   
   typedef struct modperl_mgv_t modperl_mgv_t;
  
  
  

Reply via email to