perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@locus.apache.org
Subject cvs commit: modperl-2.0/src/modules/perl mod_perl.c mod_perl.h modperl_config.c modperl_config.h modperl_interp.c modperl_types.h
Date Sun, 16 Apr 2000 00:35:33 GMT
dougm       00/04/15 17:35:32

  Modified:    src/modules/perl mod_perl.c mod_perl.h modperl_config.c
                        modperl_config.h modperl_interp.c modperl_types.h
  Log:
  add PerlInterp* and PerlTrace config directives
  
  Revision  Changes    Path
  1.5       +20 -5     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- mod_perl.c	2000/04/15 23:00:46	1.4
  +++ mod_perl.c	2000/04/16 00:35:32	1.5
  @@ -26,13 +26,17 @@
       modperl_interp_pool_init(s, p, perl);
   }
   
  -void modperl_init(ap_pool_t *pconf, ap_pool_t *plog, 
  -                  ap_pool_t *ptemp, server_rec *s)
  +void modperl_init(server_rec *s, ap_pool_t *p)
   {
  -    modperl_trace_level_set("all"); /* XXX: all for now */
  -    modperl_startup(s, pconf);
  +    modperl_startup(s, p);
   }
   
  +void modperl_hook_init(ap_pool_t *pconf, ap_pool_t *plog, 
  +                       ap_pool_t *ptemp, server_rec *s)
  +{
  +    modperl_init(s, pconf);
  +}
  +
   void modperl_pre_config_handler(ap_pool_t *p, ap_pool_t *plog,
                                   ap_pool_t *ptemp)
   {
  @@ -41,7 +45,7 @@
   void modperl_register_hooks(void)
   {
       /* XXX: should be pre_config hook or 1.xx logic */
  -    ap_hook_open_logs(modperl_init, NULL, NULL, HOOK_MIDDLE);
  +    ap_hook_open_logs(modperl_hook_init, NULL, NULL, HOOK_MIDDLE);
   
       /* XXX: should only bother selecting an interpreter
        * if one is needed for the request
  @@ -50,6 +54,17 @@
   }
   
   static command_rec modperl_cmds[] = {  
  +#ifdef MP_TRACE
  +    MP_SRV_CMD_TAKE1("PerlTrace", trace, "Trace level"),
  +#endif
  +    MP_SRV_CMD_TAKE1("PerlInterpStart", interp_start,
  +                     "Number of Perl interpreters to start"),
  +    MP_SRV_CMD_TAKE1("PerlInterpMax", interp_max,
  +                     "Max number of running Perl interpreters"),
  +    MP_SRV_CMD_TAKE1("PerlInterpMaxSpare", interp_max_spare,
  +                     "Max number of spare Perl interpreters"),
  +    MP_SRV_CMD_TAKE1("PerlInterpMinSpare", interp_min_spare,
  +                     "Min number of spare Perl interpreters"),
       { NULL }, 
   }; 
   
  
  
  
  1.5       +2 -0      modperl-2.0/src/modules/perl/mod_perl.h
  
  Index: mod_perl.h
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/mod_perl.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- mod_perl.h	2000/04/15 23:00:46	1.4
  +++ mod_perl.h	2000/04/16 00:35:32	1.5
  @@ -32,4 +32,6 @@
   
   #include "modperl_directives.h"
   
  +void modperl_init(server_rec *s, ap_pool_t *p);
  +
   #endif /*  MOD_PERL_H */
  
  
  
  1.2       +39 -1     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.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- modperl_config.c	2000/04/15 23:00:47	1.1
  +++ modperl_config.c	2000/04/16 00:35:32	1.2
  @@ -19,10 +19,22 @@
   void *modperl_create_srv_config(ap_pool_t *p, server_rec *s)
   {
       modperl_srv_config_t *scfg = modperl_srv_config_new(p);
  +    scfg->interp_pool_cfg = 
  +        (modperl_interp_pool_config_t *)
  +        ap_pcalloc(p, sizeof(*scfg->interp_pool_cfg));
   
  +    /* XXX: determine reasonable defaults */
  +    scfg->interp_pool_cfg->start = 3;
  +    scfg->interp_pool_cfg->max_spare = 3;
  +    scfg->interp_pool_cfg->min_spare = 3;
  +    scfg->interp_pool_cfg->max = 5;
  +
       return scfg;
   }
   
  +#define merge_item(item) \
  +mrg->item = add->item ? add->item : base->item
  +
   void *modperl_merge_srv_config(ap_pool_t *p, void *basev, void *addv)
   {
       modperl_srv_config_t
  @@ -30,7 +42,33 @@
           *add  = (modperl_srv_config_t *)addv,
           *mrg  = modperl_srv_config_new(p);
   
  -    mrg->mip = add->mip ? add->mip : base->mip;
  +    merge_item(mip);
   
       return mrg;
   }
  +
  +#define MP_CONFIG_BOOTSTRAP(parms) \
  +if (!scfg->mip) modperl_init(parms->server, parms->pool)
  +
  +MP_DECLARE_SRV_CMD(trace)
  +{
  +    modperl_trace_level_set(arg);
  +    return NULL;
  +}
  +
  +
  +#define MP_IMP_INTERP_POOL_CFG(item) \
  +const char *modperl_cmd_interp_##item(cmd_parms *parms, \
  +                                      void *dummy, char *arg) \
  +{ \
  +    MP_dSCFG(parms->server); \
  +    int item = atoi(arg); \
  +    scfg->interp_pool_cfg->##item = item; \
  +    MP_TRACE_d(MP_FUNC, "%s %d\n", parms->cmd->name, item); \
  +    return NULL; \
  +}
  +
  +MP_IMP_INTERP_POOL_CFG(start);
  +MP_IMP_INTERP_POOL_CFG(max);
  +MP_IMP_INTERP_POOL_CFG(max_spare);
  +MP_IMP_INTERP_POOL_CFG(min_spare);
  
  
  
  1.4       +14 -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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- modperl_config.h	2000/04/15 23:00:47	1.3
  +++ modperl_config.h	2000/04/16 00:35:32	1.4
  @@ -13,6 +13,20 @@
   
   char *modperl_cmd_push_handlers(MpAV *handlers, char *name, ap_pool_t *p);
   
  +#define MP_DECLARE_SRV_CMD(item) \
  +const char *modperl_cmd_##item(cmd_parms *parms, \
  +                               void *dummy, char *arg)
  +MP_DECLARE_SRV_CMD(trace);
  +
  +MP_DECLARE_SRV_CMD(interp_start);
  +MP_DECLARE_SRV_CMD(interp_max);
  +MP_DECLARE_SRV_CMD(interp_max_spare);
  +MP_DECLARE_SRV_CMD(interp_min_spare);
  +
  +#define MP_SRV_CMD_TAKE1(name, item, desc) \
  +    { name, modperl_cmd_##item, NULL, \
  +      RSRC_CONF, TAKE1, desc }
  +
   #define MP_dRCFG \
      modperl_request_config_t *rcfg = \
         (modperl_request_config_t *) \
  
  
  
  1.5       +8 -10     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.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- modperl_interp.c	2000/04/15 22:43:10	1.4
  +++ modperl_interp.c	2000/04/16 00:35:32	1.5
  @@ -67,7 +67,7 @@
       MUTEX_LOCK(&mip->mip_lock);
   
       if (mip->size == mip->in_use) {
  -        if (mip->size < mip->max) {
  +        if (mip->size < mip->cfg->max) {
               interp = modperl_interp_new(mip->ap_pool, mip, 
                                           mip->parent->perl);
               MUTEX_UNLOCK(&mip->mip_lock);
  @@ -211,6 +211,7 @@
       int i;
   
       mip->ap_pool = p;
  +    mip->cfg = scfg->interp_pool_cfg;
       mip->parent = modperl_interp_new(p, mip, NULL);
       aTHX = mip->parent->perl = perl;
       
  @@ -218,11 +219,7 @@
       COND_INIT(&mip->available);
   
   #ifdef USE_ITHREADS
  -    mip->start = 3; /*XXX*/
  -    mip->max = 4;
  -    mip->max_spare = 3;
  -
  -    for (i=0; i<mip->start; i++) {
  +    for (i=0; i<mip->cfg->start; i++) {
           modperl_interp_t *interp = modperl_interp_new(p, mip, perl);
   
           modperl_interp_pool_add(mip, interp);
  @@ -232,7 +229,8 @@
       MP_TRACE_i(MP_FUNC, "parent == 0x%lx "
                  "start=%d, max=%d, min_spare=%d, max_spare=%d\n",
                  (unsigned long)mip->parent, 
  -               mip->max, mip->start, mip->min_spare, mip->max_spare);
  +               mip->cfg->start, mip->cfg->max,
  +               mip->cfg->min_spare, mip->cfg->max_spare);
   
       ap_register_cleanup(p, (void*)mip,
                           modperl_interp_pool_destroy, ap_null_cleanup);
  @@ -254,13 +252,13 @@
       MP_TRACE_i(MP_FUNC, "0x%lx now available (%d in use, %d running)\n",
                  (unsigned long)interp, mip->in_use, mip->size);
   
  -    if (mip->in_use == (mip->max - 1)) {
  +    if (mip->in_use == (mip->cfg->max - 1)) {
           MP_TRACE_i(MP_FUNC, "broadcast available\n");
           COND_SIGNAL(&mip->available);
       }
  -    else if (mip->size > mip->max_spare) {
  +    else if (mip->size > mip->cfg->max_spare) {
           MP_TRACE_i(MP_FUNC, "throttle down (max_spare=%d, %d running)\n",
  -                   mip->max_spare, mip->size);
  +                   mip->cfg->max_spare, mip->size);
           MUTEX_UNLOCK(&mip->mip_lock);
           modperl_interp_pool_remove(mip, interp);
           modperl_interp_destroy(interp);
  
  
  
  1.4       +10 -5     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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- modperl_types.h	2000/04/15 22:43:10	1.3
  +++ modperl_types.h	2000/04/16 00:35:32	1.4
  @@ -26,6 +26,13 @@
   typedef struct modperl_interp_t modperl_interp_t;
   typedef struct modperl_interp_pool_t modperl_interp_pool_t;
   
  +typedef struct {
  +    int start; /* number of Perl intepreters to start (clone) */
  +    int min_spare; /* minimum number of spare Perl interpreters */
  +    int max_spare; /* maximum number of spare Perl interpreters */
  +    int max; /* maximum number of Perl interpreters */
  +} modperl_interp_pool_config_t;
  +
   struct modperl_interp_t {
       modperl_interp_pool_t *mip;
       PerlInterpreter *perl;
  @@ -37,12 +44,9 @@
       ap_pool_t *ap_pool;
       perl_mutex mip_lock;
       perl_cond available;
  -    int start; /* number of Perl intepreters to start (clone) */
  -    int min_spare; /* minimum number of spare Perl interpreters */
  -    int max_spare; /* maximum number of spare Perl interpreters */
  -    int size; /* current number of Perl interpreters */
  -    int max; /* maximum number of Perl interpreters */
  +    modperl_interp_pool_config_t *cfg;
       int in_use; /* number of Perl interpreters currrently in use */
  +    int size; /* current number of Perl interpreters */
       modperl_interp_t *parent; /* from which to perl_clone() */
       modperl_interp_t *head, *tail;
   };
  @@ -67,6 +71,7 @@
       modperl_process_config_t *process_cfg;
       modperl_connection_config_t *connection_cfg;
       modperl_interp_pool_t *mip;
  +    modperl_interp_pool_config_t *interp_pool_cfg;
       int flags;
   } modperl_srv_config_t;
   
  
  
  

Mime
View raw message