Author: mturk
Date: Mon Nov  5 05:15:12 2007
New Revision: 591985

URL: http://svn.apache.org/viewvc?rev=591985&view=rev
Log:
Make envvar tables created on demand. Only non virtual hosts have pre-allocated 
tables, other are allocated if JkEnvVar is specified inside vhost

Modified:
    tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c

Modified: tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c?rev=591985&r1=591984&r2=591985&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c (original)
+++ tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c Mon Nov  5 05:15:12 
2007
@@ -656,7 +656,7 @@
     s->ssl_session = NULL;
     s->ssl_key_size = -1;       /* required by Servlet 2.3 Api, added in jtc */
 
-    if (conf->ssl_enable || conf->envvars_in_use) {
+    if (conf->ssl_enable || conf->envvars) {
         ap_add_common_vars(r);
 
         if (conf->ssl_enable) {
@@ -716,7 +716,7 @@
             }
         }
 
-        if (conf->envvars_in_use) {
+        if (conf->envvars) {
             const apr_array_header_t *t = conf->envvar_items;
             if (t && t->nelts) {
                 int i;
@@ -1810,6 +1810,12 @@
                                                   &jk_module);
 
     conf->envvars_in_use = JK_TRUE;
+    if (!conf->envvars) {
+        conf->envvars      = apr_table_make(cmd->pool, 0);
+        conf->envvars_def  = apr_table_make(cmd->pool, 0);
+        conf->envvar_items = apr_array_make(cmd->pool, 0,
+                                            sizeof(envvar_item));        
+    }
 
     /* env_name is mandatory, default_value is optional.
      * No value means send the attribute only, if the env var is set during 
runtime.
@@ -2289,10 +2295,14 @@
                we can't guarantee what order pools get cleaned
                up between APR implementations. */
             wc_close(NULL);
-            if (conf->uri_to_context)
+            if (conf->uri_to_context) {
                 jk_map_free(&conf->uri_to_context);
-            if (conf->uw_map)
-                uri_worker_map_free(&conf->uw_map, NULL);
+                /* We cannot have allocated uw_map
+                 * unless we've allocated uri_to_context
+                 */
+                if (conf->uw_map)
+                    uri_worker_map_free(&conf->uw_map, NULL);
+            }
             conf->was_initialized = JK_FALSE;
         }
         s = s->next;
@@ -2363,9 +2373,11 @@
     c->uw_map = NULL;
 
     c->envvars_in_use = JK_FALSE;
-    c->envvars = apr_table_make(p, 0);
-    c->envvars_def = apr_table_make(p, 0);
-    c->envvar_items = apr_array_make(p, 0, sizeof(envvar_item));
+    if (!s->is_virtual) {
+        c->envvars = apr_table_make(p, 0);
+        c->envvars_def = apr_table_make(p, 0);
+        c->envvar_items = apr_array_make(p, 0, sizeof(envvar_item));
+    }
 
     c->s = s;
     apr_pool_cleanup_register(p, s, jk_apr_pool_cleanup, jk_apr_pool_cleanup);
@@ -2431,15 +2443,16 @@
 
     overrides->options |= (base->options & ~base->exclude_options);
 
-    if (base->envvars_in_use) {
-        if (apr_table_elts(base->envvars)) {
-            overrides->envvars_in_use = JK_TRUE;
+    if (base->envvars) {
+        if (overrides->envvars && overrides->envvars_in_use) {
             merge_apr_table(base->envvars, overrides->envvars);
-        }
-        if (apr_table_elts(base->envvars_def)) {
-            overrides->envvars_in_use = JK_TRUE;
             merge_apr_table(base->envvars_def, overrides->envvars_def);
         }
+        else {
+            overrides->envvars = base->envvars;
+            overrides->envvars_def = base->envvars_def;
+            overrides->envvar_items = base->envvar_items;
+        }
     }
 
     if (overrides->mount_file_reload == JK_UNSET)
@@ -2813,7 +2826,7 @@
                             ap_log_error(APLOG_MARK, APLOG_ERR, 0, s,
                                          "JkRequestLogFormat format array 
NULL");
                     }
-                    if (sconf->envvars_in_use) {
+                    if (sconf->envvars && sconf->envvars_in_use) {
                         int i;
                         const apr_array_header_t *arr;
                         const apr_table_entry_t *elts;



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to