You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by rj...@apache.org on 2006/12/03 14:57:51 UTC

svn commit: r481775 - in /tomcat/connectors/trunk/jk: native/apache-1.3/mod_jk.c native/apache-2.0/mod_jk.c xdocs/config/apache.xml xdocs/miscellaneous/changelog.xml xdocs/webserver_howto/apache.xml

Author: rjung
Date: Sun Dec  3 05:57:46 2006
New Revision: 481775

URL: http://svn.apache.org/viewvc?view=rev&rev=481775
Log:
Apache: Fix incorrect handling of JkEnvVar when Vars are set multiple times.
Allow omitting of default value (which means default is empty string).

Modified:
    tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c
    tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c
    tomcat/connectors/trunk/jk/xdocs/config/apache.xml
    tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
    tomcat/connectors/trunk/jk/xdocs/webserver_howto/apache.xml

Modified: tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c?view=diff&rev=481775&r1=481774&r2=481775
==============================================================================
--- tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c (original)
+++ tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c Sun Dec  3 05:57:46 2006
@@ -1681,7 +1681,10 @@
                                                   &jk_module);
 
 
-    ap_table_add(conf->envvars, env_name, default_value);
+    /* env_name is mandatory, default_value is optional.
+     * No value means set the variable to an empty string.
+     */
+    ap_table_setn(conf->envvars, env_name, default_value ? default_value : "");
 
     return NULL;
 }
@@ -1843,8 +1846,9 @@
      * JkEnvVar let user defines envs var passed from WebServer to
      * Servlet Engine
      */
-    {"JkEnvVar", jk_add_env_var, NULL, RSRC_CONF, TAKE2,
-     "Adds a name of environment variable that should be sent to servlet-engine"},
+    {"JkEnvVar", jk_add_env_var, NULL, RSRC_CONF, TAKE12,
+     "Adds a name of environment variable and an optional value "
+     "that should be sent to servlet-engine"},
 
     {"JkWorkerProperty", jk_set_worker_property, NULL, RSRC_CONF, RAW_ARGS,
      "Set workers.properties formated directive"},
@@ -2197,9 +2201,20 @@
     overrides->options |= (base->options & ~base->exclude_options);
 
     if (base->envvars_in_use) {
-        overrides->envvars_in_use = JK_TRUE;
-        overrides->envvars = ap_overlay_tables(p, overrides->envvars,
-                                               base->envvars);
+        int i;
+        const array_header *arr;
+        const table_entry *elts;
+
+        arr = ap_table_elts(base->envvars);
+        if (arr) {
+            overrides->envvars_in_use = JK_TRUE;
+            elts = (const table_entry *)arr->elts;
+            for (i = 0; i < arr->nelts; ++i) {
+                if (!ap_table_get(overrides->envvars, elts[i].key)) {
+                    ap_table_setn(overrides->envvars, elts[i].key, elts[i].val);
+                }
+            }
+        }
     }
 
     if (overrides->mount_file_reload == JK_UNSET)

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?view=diff&rev=481775&r1=481774&r2=481775
==============================================================================
--- tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c (original)
+++ tomcat/connectors/trunk/jk/native/apache-2.0/mod_jk.c Sun Dec  3 05:57:46 2006
@@ -1711,7 +1711,10 @@
 
     conf->envvars_in_use = JK_TRUE;
 
-    apr_table_add(conf->envvars, env_name, default_value);
+    /* env_name is mandatory, default_value is optional.
+     * No value means set the variable to an empty string.
+     */
+    apr_table_setn(conf->envvars, env_name, default_value ? default_value : "");
 
     return NULL;
 }
@@ -1885,9 +1888,9 @@
      * JkEnvVar let user defines envs var passed from WebServer to
      * Servlet Engine
      */
-    AP_INIT_TAKE2("JkEnvVar", jk_add_env_var, NULL, RSRC_CONF,
-                  "Adds a name of environment variable that should be sent "
-                  "to servlet-engine"),
+    AP_INIT_TAKE12("JkEnvVar", jk_add_env_var, NULL, RSRC_CONF,
+                  "Adds a name of environment variable and an optional value "
+                  "that should be sent to servlet-engine"),
 
     AP_INIT_RAW_ARGS("JkWorkerProperty", jk_set_worker_property,
                      NULL, RSRC_CONF,
@@ -2323,9 +2326,20 @@
     overrides->options |= (base->options & ~base->exclude_options);
 
     if (base->envvars_in_use) {
-        overrides->envvars_in_use = JK_TRUE;
-        overrides->envvars = apr_table_overlay(p, overrides->envvars,
-                                               base->envvars);
+        int i;
+        const apr_array_header_t *arr;
+        const apr_table_entry_t *elts;
+
+        arr = apr_table_elts(base->envvars);
+        if (arr) {
+            overrides->envvars_in_use = JK_TRUE;
+            elts = (const apr_table_entry_t *)arr->elts;
+            for (i = 0; i < arr->nelts; ++i) {
+                if (!apr_table_get(overrides->envvars, elts[i].key)) {
+                    apr_table_setn(overrides->envvars, elts[i].key, elts[i].val);
+                }
+            }
+        }
     }
 
     if (overrides->mount_file_reload == JK_UNSET)

Modified: tomcat/connectors/trunk/jk/xdocs/config/apache.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/config/apache.xml?view=diff&rev=481775&r1=481774&r2=481775
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/config/apache.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/config/apache.xml Sun Dec  3 05:57:46 2006
@@ -206,8 +206,10 @@
 The default value is "ForwardURICompat".
 </p></attribute>
 <attribute name="JkEnvVar" required="false"><p>
-Adds a name and default value of environment variable that should be sent to servlet-engine
-as a request attribute.
+Adds a name and an optional default value of environment variable
+that should be sent to servlet-engine as a request attribute.
+If the default value is not given explicitely, the empty string
+will be used as a default.
 <br/>
 This directive can be used multiple times per virtual server.
 <br/>
@@ -567,7 +569,9 @@
 <p>
 The directive <b>JkEnvVar</b> allows you to forward environment variables from Apache server to Tomcat engine.
 The variables can be retrieved on the Tomcat side as request attributes.
-You must add a default value as a second parameter to the directive.
+You can add a default value as a second parameter to the directive.
+If the default value is not given explicitely, the empty string
+will be used as a default.
 <br/>
 <br/>
 The variables are inherited from the global server to virtual hosts.

Modified: tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml?view=diff&rev=481775&r1=481774&r2=481775
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/miscellaneous/changelog.xml Sun Dec  3 05:57:46 2006
@@ -26,6 +26,9 @@
   <br />
   <subsection name="Native">
     <changelog>
+      <fix>
+      Apache: Fix incorrect handling of JkEnvVar when Vars are set multiple times. (rjung)
+      </fix>
       <update>
       Renamed jvm_route to route. Deprecated jvm_route, but still use it as fallback
       when parsing the worker configuration. (rjung)

Modified: tomcat/connectors/trunk/jk/xdocs/webserver_howto/apache.xml
URL: http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/xdocs/webserver_howto/apache.xml?view=diff&rev=481775&r1=481774&r2=481775
==============================================================================
--- tomcat/connectors/trunk/jk/xdocs/webserver_howto/apache.xml (original)
+++ tomcat/connectors/trunk/jk/xdocs/webserver_howto/apache.xml Sun Dec  3 05:57:46 2006
@@ -625,7 +625,9 @@
 <p>
 The directive <b>JkEnvVar</b> allows you to forward environment variables from Apache server to Tomcat engine.
 The variables can be retrieved on the Tomcat side as request attributes.
-You must add a default value as a second parameter to the directive.
+You can add a default value as a second parameter to the directive.
+If the default value is not given explicitely, the empty string
+will be used as a default.
 <br/>
 <br/>
 The variables are inherited from the global server to virtual hosts.



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org