[svn:mod_parrot] r303 - in mod_parrot/trunk: include src

[email protected]
Newsgroups perl.cvs.mod_parrot
Message-ID <[email protected]>
Author: jhorwitz
Date: Fri Dec 28 12:23:34 2007
New Revision: 303

Modified:
   mod_parrot/trunk/include/modparrot_config.h
   mod_parrot/trunk/src/mod_parrot.c
   mod_parrot/trunk/src/modparrot_config.c

Log:
add Enable option to turn mod_parrot on or off for a virtual host


Modified: mod_parrot/trunk/include/modparrot_config.h
==============================================================================
--- mod_parrot/trunk/include/modparrot_config.h	(original)
+++ mod_parrot/trunk/include/modparrot_config.h	Fri Dec 28 12:23:34 2007
@@ -18,7 +18,8 @@
 #include "apr_tables.h"
 
 /* per-server options */
-#define MP_OPT_PARENT 1
+#define MP_OPT_ENABLE 1
+#define MP_OPT_PARENT 2
 
 /* configuration */
 struct modparrot_handler_info

Modified: mod_parrot/trunk/src/mod_parrot.c
==============================================================================
--- mod_parrot/trunk/src/mod_parrot.c	(original)
+++ mod_parrot/trunk/src/mod_parrot.c	Fri Dec 28 12:23:34 2007
@@ -195,6 +195,8 @@
     dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
     cfg = ap_get_module_config(r->server->module_config, &parrot_module);
 
+    if (!(cfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+
     /* we don't use SET_HLL_HANDLER here because it may still be appropriate
      * to run this handler without a corresponding ParrotHandler directive.
      * This is true for type maps and handler maps.
@@ -256,8 +258,10 @@
     /* get apache configs */
     cfg = ap_get_module_config(c->base_server->module_config, &parrot_module);
 
+    if (!(cfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+
     /* politely decline request if not our handler */
-    if (!cfg->pre_connection_handler) {
+    if (!(cfg->option_flags & MP_OPT_ENABLE) || !cfg->pre_connection_handler) {
         return DECLINED;
     }
 
@@ -300,8 +304,10 @@
     /* get apache configs */
     cfg = ap_get_module_config(r->server->module_config, &parrot_module);
 
+    if (!(cfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+
     /* politely decline request if not our handler */
-    if (!cfg->map_to_storage_handler) {
+    if (!(cfg->option_flags & MP_OPT_ENABLE) || !cfg->map_to_storage_handler) {
         return DECLINED;
     }
 
@@ -345,6 +351,8 @@
     dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
     cfg = ap_get_module_config(r->server->module_config, &parrot_module);
 
+    if (!(cfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+
     SET_HLL_HANDLER(header_parser_handler);
 
     /* initialize context */
@@ -382,8 +390,11 @@
     /* get apache configs */
     cfg = ap_get_module_config(r->server->module_config, &parrot_module);
 
+    if (!(cfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+
     /* politely decline request if not our handler */
-    if (!cfg->post_read_request_handler) {
+    if (!(cfg->option_flags & MP_OPT_ENABLE) ||
+        !cfg->post_read_request_handler) {
         return DECLINED;
     }
 
@@ -423,7 +434,8 @@
     cfg = ap_get_module_config(c->base_server->module_config, &parrot_module);
 
     /* politely decline request if not our handler */
-    if (!cfg->process_connection_handler) {
+    if (!(cfg->option_flags & MP_OPT_ENABLE) ||
+        !cfg->process_connection_handler) {
         return DECLINED;
     }
 
@@ -467,7 +479,7 @@
     cfg = ap_get_module_config(s->module_config, &parrot_module);
 
     /* politely decline request if not our handler */
-    if (!cfg->child_init_handler) {
+    if (!(cfg->option_flags & MP_OPT_ENABLE) || !cfg->child_init_handler) {
         return;
     }
 
@@ -509,7 +521,7 @@
     cfg = ap_get_module_config(r->server->module_config, &parrot_module);
 
     /* politely decline request if not our handler */
-    if (!cfg->child_init_handler) {
+    if (!(cfg->option_flags & MP_OPT_ENABLE) || !cfg->trans_handler) {
         return DECLINED;
     }
 
@@ -552,6 +564,8 @@
     dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
     cfg = ap_get_module_config(r->server->module_config, &parrot_module);
 
+    if (!(cfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+
     SET_HLL_HANDLER(fixup_handler);
 
     /* initialize context */
@@ -591,6 +605,8 @@
     dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
     cfg = ap_get_module_config(r->server->module_config, &parrot_module);
 
+    if (!(cfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+
     SET_HLL_HANDLER(type_handler);
 
     /* initialize context */
@@ -635,6 +651,8 @@
     dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
     cfg = ap_get_module_config(r->server->module_config, &parrot_module);
 
+    if (!(cfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+
     SET_HLL_HANDLER(log_handler);
 
     /* initialize context */
@@ -674,6 +692,8 @@
     dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
     cfg = ap_get_module_config(r->server->module_config, &parrot_module);
 
+    if (!(cfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+
     SET_HLL_HANDLER(access_handler);
 
     /* initialize context */
@@ -714,6 +734,8 @@
     dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
     cfg = ap_get_module_config(r->server->module_config, &parrot_module);
 
+    if (!(cfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+
     SET_HLL_HANDLER(authen_handler);
 
     /* initialize context */
@@ -754,6 +776,8 @@
     dircfg = (modparrot_dir_config *)ap_get_module_config(r->per_dir_config, &parrot_module);
     cfg = ap_get_module_config(r->server->module_config, &parrot_module);
 
+    if (!(cfg->option_flags & MP_OPT_ENABLE)) return DECLINED;
+
     SET_HLL_HANDLER(authz_handler);
 
     /* initialize context */
@@ -797,7 +821,7 @@
     cfg = ap_get_module_config(s->module_config, &parrot_module);
 
     /* if not our handler, return OK (post_config must return OK) */
-    if (!cfg->post_config_handler) {
+    if (!(cfg->option_flags & MP_OPT_ENABLE) || !cfg->post_config_handler) {
         return OK;
     }
 
@@ -839,18 +863,22 @@
     int handler_status;
     char *sub, *hll;
     server_rec *vs;
+    Parrot_Interp parent_interp = NULL;
 
     /* get apache configs */
     cfg = ap_get_module_config(s->module_config, &parrot_module);
 
-    /* ALWAYS INIT THE CONTEXT POOL AND START THE INTERPRETER HERE! */
-    if (!(cfg->ctx_pool = mp_ctx_pool_init(pconf, NULL, 1))) {
-        MPLOG_ERROR(s, "context pool creation failed");
-        return HTTP_INTERNAL_SERVER_ERROR;
-    }
-    if (!(ctxp = init_ctx(s))) {
-        MPLOG_ERROR(s, "context initialization failed");
-        return HTTP_INTERNAL_SERVER_ERROR;
+    if (cfg->option_flags & MP_OPT_ENABLE) {
+        /* ALWAYS INIT THE CONTEXT POOL AND START THE INTERPRETER HERE! */
+        if (!(cfg->ctx_pool = mp_ctx_pool_init(pconf, NULL, 1))) {
+            MPLOG_ERROR(s, "context pool creation failed");
+            return HTTP_INTERNAL_SERVER_ERROR;
+        }
+        if (!(ctxp = init_ctx(s))) {
+            MPLOG_ERROR(s, "context initialization failed");
+            return HTTP_INTERNAL_SERVER_ERROR;
+        }
+        parent_interp = ctxp->interp;
     }
 
     /* init per-server (MP_OPT_PARENT) or per-process (default) pools */
@@ -858,13 +886,15 @@
         modparrot_srv_config *vscfg;
         modparrot_context *vsctxp;
         vscfg = ap_get_module_config(vs->module_config, &parrot_module);
+        if (!(vscfg->option_flags & MP_OPT_ENABLE)) continue;
         if (vscfg->option_flags & MP_OPT_PARENT) {
             /* XXX this crashes if we don't specify parent context. we can't
              * create multiple interpreters in the same process, which is a
              * either a problem with parrot or a problem with my understanding
              * of the interpreter creation process.
              */
-            if (!(vscfg->ctx_pool = mp_ctx_pool_init(pconf, ctxp->interp, 1))) {
+            if (!(vscfg->ctx_pool =
+                mp_ctx_pool_init(pconf, parent_interp, 1))) {
                 MPLOG_ERROR(s, "context pool creation failed");
                 return HTTP_INTERNAL_SERVER_ERROR;
             }
@@ -874,7 +904,12 @@
             }
         }
         else {
-            vscfg->ctx_pool = cfg->ctx_pool;
+            if (cfg->option_flags & MP_OPT_ENABLE) {
+                vscfg->ctx_pool = cfg->ctx_pool;
+            }
+            else {
+                MPLOG_ERROR(vs, "must use +Parent if mod_parrot is disabled in main server");
+            }
         }
     }
 

Modified: mod_parrot/trunk/src/modparrot_config.c
==============================================================================
--- mod_parrot/trunk/src/modparrot_config.c	(original)
+++ mod_parrot/trunk/src/modparrot_config.c	Fri Dec 28 12:23:34 2007
@@ -33,6 +33,8 @@
  ((modparrot_srv_config *)ap_get_module_config(\
  x->server->module_config, &parrot_module))
 
+#define DEFAULT_OPTION_FLAGS (MP_OPT_ENABLE)
+
 extern module AP_MODULE_DECLARE_DATA parrot_module;
 
 static apr_status_t modparrot_cleanup(void *data)
@@ -57,7 +59,7 @@
     cfg->trace_flags = -1; /* -1 == unspecified */
     cfg->enable_option_flags = 0; /* only used during configuration merge */
     cfg->disable_option_flags = 0; /* only used during configuration merge */
-    cfg->option_flags = 0; /* use this after configuration is merged */
+    cfg->option_flags = DEFAULT_OPTION_FLAGS; /* set default options here */
     cfg->init_path = NULL;
     cfg->preload = apr_array_make(p, 2, sizeof(modparrot_handler_info));
     cfg->include_path = NULL;
@@ -239,6 +241,9 @@
     if (!strncasecmp(option, "Parent", 6)) {
         *flags |= MP_OPT_PARENT;
     }
+    else if (!strncasecmp(option, "Enable", 6)) {
+        *flags |= MP_OPT_ENABLE;
+    }
     else {
         return 0;
     }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.