perl-modperl-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From do...@apache.org
Subject cvs commit: modperl-2.0/src/modules/perl mod_perl.c mod_perl.h modperl_cmd.c modperl_config.c modperl_types.h
Date Sun, 15 Sep 2002 23:30:06 GMT
dougm       2002/09/15 16:30:06

  Modified:    src/modules/perl mod_perl.c mod_perl.h modperl_cmd.c
                        modperl_config.c modperl_types.h
  Log:
  break some logic out of modperl_init into modperl_init_vhost so it can
  after modperl_init.
  
  if modperl is already running then call modperl_init_vhost during
  server config merge and <Perl>, Perl{Module,Require} directive handlers.
  
  Revision  Changes    Path
  1.139     +102 -53   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.138
  retrieving revision 1.139
  diff -u -r1.138 -r1.139
  --- mod_perl.c	4 Sep 2002 18:00:55 -0000	1.138
  +++ mod_perl.c	15 Sep 2002 23:30:06 -0000	1.139
  @@ -179,6 +179,106 @@
       return perl;
   }
   
  +int modperl_init_vhost(server_rec *s, apr_pool_t *p,
  +                       server_rec *base_server)
  +{
  +    MP_dSCFG(s);
  +    modperl_config_srv_t *base_scfg;
  +    PerlInterpreter *base_perl;
  +    PerlInterpreter *perl;
  +
  +#ifdef MP_TRACE
  +    const char *vhost = modperl_server_desc(s, p);
  +#endif
  +
  +    if (base_server == NULL) {
  +        base_server = modperl_global_get_server_rec();
  +    }
  +
  +    if (base_server == s) {
  +        MP_TRACE_i(MP_FUNC, "skipping vhost init for base server %s\n",
  +                   vhost);
  +        return OK;
  +    }
  +
  +    base_scfg = modperl_config_srv_get(base_server);
  +
  +#ifdef USE_ITHREADS
  +    perl = base_perl = base_scfg->mip->parent->perl;
  +#else
  +    perl = base_perl = base_scfg->perl;
  +#endif /* USE_ITHREADS */
  +
  +    if (!scfg) {
  +        MP_TRACE_i(MP_FUNC, "server %s has no mod_perl config\n", vhost);
  +        return OK;
  +    }
  +
  +#ifdef USE_ITHREADS
  +
  +    if (scfg->mip) {
  +        MP_TRACE_i(MP_FUNC, "server %s already initialized\n", vhost);
  +        return OK;
  +    }
  +
  +    if (!MpSrvENABLE(scfg)) {
  +        MP_TRACE_i(MP_FUNC, "mod_perl disabled for server %s\n", vhost);
  +        scfg->mip = NULL;
  +        return OK;
  +    }
  +
  +    PERL_SET_CONTEXT(perl);
  +
  +#endif /* USE_ITHREADS */
  +
  +    MP_TRACE_d_do(MpSrv_dump_flags(scfg, s->server_hostname));
  +
  +    /* if alloc flags is On, virtual host gets its own parent perl */
  +    if (MpSrvPARENT(scfg)) {
  +        perl = modperl_startup(s, p);
  +        MP_TRACE_i(MP_FUNC,
  +                   "created parent interpreter for VirtualHost %s\n",
  +                   modperl_server_desc(s, p));
  +    }
  +    else {
  +        if (!modperl_config_apply_PerlModule(s, scfg, perl, p)) {
  +            return HTTP_INTERNAL_SERVER_ERROR;
  +        }
  +        if (!modperl_config_apply_PerlRequire(s, scfg, perl, p)) {
  +            return HTTP_INTERNAL_SERVER_ERROR;
  +        }
  +    }
  +
  +#ifdef USE_ITHREADS
  +
  +    /* if alloc flags is On or clone flag is On,
  +     *  virtual host gets its own mip
  +     */
  +    if (MpSrvPARENT(scfg) || MpSrvCLONE(scfg)) {
  +        MP_TRACE_i(MP_FUNC, "modperl_interp_init() server=%s\n",
  +                   modperl_server_desc(s, p));
  +        modperl_interp_init(s, p, perl);
  +    }
  +
  +    /* if we allocated a parent perl, mark it to be destroyed */
  +    if (MpSrvPARENT(scfg)) {
  +        MpInterpBASE_On(scfg->mip->parent);
  +    }
  +
  +    if (!scfg->mip) {
  +        /* since mips are created after merge_server_configs()
  +         * need to point to the base mip here if this vhost
  +         * doesn't have its own
  +         */
  +        MP_TRACE_i(MP_FUNC, "%s mip inherited from %s\n",
  +                   vhost, modperl_server_desc(base_server, p));
  +        scfg->mip = base_scfg->mip;
  +    }
  +#endif  /* USE_ITHREADS */
  +
  +    return OK;
  +}
  +
   void modperl_init(server_rec *base_server, apr_pool_t *p)
   {
       server_rec *s;
  @@ -209,60 +309,9 @@
   #endif
   
       for (s=base_server->next; s; s=s->next) {
  -        MP_dSCFG(s);
  -        PerlInterpreter *perl = base_perl;
  -
  -        PERL_SET_CONTEXT(perl);
  -
  -        MP_TRACE_d_do(MpSrv_dump_flags(scfg, s->server_hostname));
  -
  -        /* if alloc flags is On, virtual host gets its own parent perl */
  -        if (MpSrvPARENT(scfg)) {
  -            perl = modperl_startup(s, p);
  -            MP_TRACE_i(MP_FUNC,
  -                       "created parent interpreter for VirtualHost %s\n",
  -                       modperl_server_desc(s, p));
  -        }
  -        else {
  -            if (!modperl_config_apply_PerlModule(s, scfg, perl, p)) {
  -                exit(1);
  -            }
  -            if (!modperl_config_apply_PerlRequire(s, scfg, perl, p)) {
  -                exit(1);
  -            }
  +        if (modperl_init_vhost(s, p, base_server) != OK) {
  +            exit(1); /*XXX*/
           }
  -
  -#ifdef USE_ITHREADS
  -
  -        if (!MpSrvENABLE(scfg)) {
  -            scfg->mip = NULL;
  -            continue;
  -        }
  -
  -        /* if alloc flags is On or clone flag is On,
  -         *  virtual host gets its own mip
  -         */
  -        if (MpSrvPARENT(scfg) || MpSrvCLONE(scfg)) {
  -            MP_TRACE_i(MP_FUNC, "modperl_interp_init() server=%s\n",
  -                       modperl_server_desc(s, p));
  -            modperl_interp_init(s, p, perl);
  -        }
  -
  -        /* if we allocated a parent perl, mark it to be destroyed */
  -        if (MpSrvPARENT(scfg)) {
  -            MpInterpBASE_On(scfg->mip->parent);
  -        }
  -
  -        if (!scfg->mip) {
  -            /* since mips are created after merge_server_configs()
  -             * need to point to the base mip here if this vhost
  -             * doesn't have its own
  -             */
  -            scfg->mip = base_scfg->mip;
  -        }
  -
  -#endif /* USE_ITHREADS */
  -
       }
   }
   
  
  
  
  1.54      +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.53
  retrieving revision 1.54
  diff -u -r1.53 -r1.54
  --- mod_perl.h	4 Sep 2002 17:10:15 -0000	1.53
  +++ mod_perl.h	15 Sep 2002 23:30:06 -0000	1.54
  @@ -71,6 +71,8 @@
   #include "modperl_svptr_table.h"
   #include "modperl_module.h"
   
  +int modperl_init_vhost(server_rec *s, apr_pool_t *p,
  +                       server_rec *base_server);
   void modperl_init(server_rec *s, apr_pool_t *p);
   int modperl_run(apr_pool_t *p, server_rec *s);
   int modperl_is_running(void);
  
  
  
  1.29      +36 -2     modperl-2.0/src/modules/perl/modperl_cmd.c
  
  Index: modperl_cmd.c
  ===================================================================
  RCS file: /home/cvs/modperl-2.0/src/modules/perl/modperl_cmd.c,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- modperl_cmd.c	5 Sep 2002 03:31:45 -0000	1.28
  +++ modperl_cmd.c	15 Sep 2002 23:30:06 -0000	1.29
  @@ -48,10 +48,28 @@
       return NULL;
   }
   
  +static int modperl_vhost_is_running(server_rec *s)
  +{
  +#ifdef USE_ITHREADS
  +    MP_dSCFG(s);
  +    int is_vhost = (s != modperl_global_get_server_rec());
  +
  +    if (is_vhost && scfg->mip) {
  +        return TRUE;
  +    }
  +    else {
  +        return FALSE;
  +    }
  +#else
  +    return TRUE;
  +#endif
  +}
  +
   MP_CMD_SRV_DECLARE(switches)
   {
  -    MP_dSCFG(parms->server);
  -    if (modperl_is_running()) {
  +    server_rec *s = parms->server;
  +    MP_dSCFG(s);
  +    if (modperl_is_running() && modperl_vhost_is_running(s)) {
           return modperl_cmd_too_late(parms);
       }
       MP_TRACE_d(MP_FUNC, "arg = %s\n", arg);
  @@ -63,6 +81,12 @@
   {
       MP_dSCFG(parms->server);
   
  +    if (modperl_is_running() &&
  +        modperl_init_vhost(parms->server, parms->pool, NULL) != OK)
  +    {
  +        return "init mod_perl vhost failed";
  +    }
  +
       if (modperl_is_running()) {
   #ifdef USE_ITHREADS
           /* XXX: .htaccess support cannot use this perl with threaded MPMs */
  @@ -86,6 +110,12 @@
   {
       MP_dSCFG(parms->server);
   
  +    if (modperl_is_running() &&
  +        modperl_init_vhost(parms->server, parms->pool, NULL) != OK)
  +    {
  +        return "init mod_perl vhost failed";
  +    }
  +
       if (modperl_is_running()) {
   #ifdef USE_ITHREADS
           /* XXX: .htaccess support cannot use this perl with threaded MPMs */
  @@ -262,6 +292,10 @@
   
       /* we must init earlier than normal */
       modperl_run(p, s);
  +
  +    if (modperl_init_vhost(s, p, NULL) != OK) {
  +        return "init mod_perl vhost failed";
  +    }
   
   #ifdef USE_ITHREADS
       /* XXX: .htaccess support cannot use this perl with threaded MPMs */
  
  
  
  1.57      +13 -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.56
  retrieving revision 1.57
  diff -u -r1.56 -r1.57
  --- modperl_config.c	5 Sep 2002 01:47:39 -0000	1.56
  +++ modperl_config.c	15 Sep 2002 23:30:06 -0000	1.57
  @@ -180,6 +180,8 @@
       scfg->interp_pool_cfg->max_requests = 2000;
   #endif /* USE_ITHREADS */
   
  +    scfg->server = s;
  +
       return scfg;
   }
   
  @@ -205,9 +207,9 @@
       merge_table_overlap_item(PassEnv);
    
       merge_item(threaded_mpm);
  +    merge_item(server);
   
   #ifdef USE_ITHREADS
  -    merge_item(mip);
       merge_item(interp_pool_cfg);
       merge_item(interp_scope);
   #else
  @@ -239,6 +241,16 @@
       for (i=0; i < MP_HANDLER_NUM_CONNECTION; i++) {
           merge_handlers(MpSrvMERGE_HANDLERS, handlers_connection[i]);
       }
  +
  +    if (modperl_is_running()) {
  +        if (modperl_init_vhost(mrg->server, p, NULL) != OK) {
  +            exit(1); /*XXX*/
  +        }
  +    }
  +
  +#ifdef USE_ITHREADS
  +    merge_item(mip);
  +#endif
   
       return mrg;
   }
  
  
  
  1.62      +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.61
  retrieving revision 1.62
  diff -u -r1.61 -r1.62
  --- modperl_types.h	27 Aug 2002 04:27:44 -0000	1.61
  +++ modperl_types.h	15 Sep 2002 23:30:06 -0000	1.62
  @@ -134,6 +134,7 @@
       MpAV *argv;
       modperl_options_t *flags;
       apr_hash_t *modules;
  +    server_rec *server;
   } modperl_config_srv_t;
   
   typedef struct {
  
  
  

Mime
View raw message