Author: rjung
Date: Fri Nov  2 16:19:11 2007
New Revision: 591510

URL: http://svn.apache.org/viewvc?rev=591510&view=rev
Log:
Fix configuration initialization behaviour for virtual hosts,
which contain no JK directive.
HTTPD does not call create_jk_config or merge_jk_config for those hosts.
It simply uses the same config structure as for the surrounding host.
We don't want that, because by default we don't inherit JkMounts between vhosts.
So we need to create a new configuration structure for such vhosts.
We detect this situation by checking the server_rec we put into our
configuration structure against the server_rec of the vhost. Igf they don't 
match,
we found a shared configuration structure and replace it by a new one created 
with
create_jk_config and merged via merge_jk_config.

The function clone_jk_config introduced some weeks ago is not used any more
(less code duplication).

In case JkMountCopyAll was set, we actually don't need the configuration
structure created by ourselves for empty vhost, because then all config items 
are
really shared.

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

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?rev=591510&r1=591509&r2=591510&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c (original)
+++ tomcat/connectors/trunk/jk/native/apache-1.3/mod_jk.c Fri Nov  2 16:19:11 
2007
@@ -2254,31 +2254,6 @@
 
 
 /*
- *  Clone jk config.
- */
-static void *clone_jk_config(ap_pool * p, server_rec *s)
-{
-    jk_server_conf_t *src =
-        (jk_server_conf_t *)ap_get_module_config(s->module_config, &jk_module);
-    jk_server_conf_t *dst =
-        (jk_server_conf_t *) ap_pcalloc(p, sizeof(jk_server_conf_t));
-
-    memcpy(dst, src, sizeof(jk_server_conf_t));
-    dst->was_initialized = JK_TRUE;
-    dst->s = s;
-    dst->mountcopy = 0;
-    dst->mount_file = NULL;
-    dst->alias_dir = NULL;
-    dst->uri_to_context = NULL;
-    if (!uri_worker_map_alloc(&(dst->uw_map), NULL, dst->log)) {
-        jk_error_exit(APLOG_MARK, APLOG_EMERG, s, p, "Memory error");
-    }
-
-    return dst;
-}
-
-
-/*
  * Utility - copy items from apr table src to dst,
  * for keys that exist in src but not in dst.
  */
@@ -2511,11 +2486,21 @@
     for (; srv; srv = srv->next) {
         jk_server_conf_t *sconf = (jk_server_conf_t 
*)ap_get_module_config(srv->module_config,
                                                                            
&jk_module);
-        if (sconf && sconf->was_initialized == JK_TRUE && jk_mount_copy_all == 
JK_FALSE) {
-            ap_set_module_config(srv->module_config, &jk_module,
-                                 clone_jk_config(p, srv));
+
+/*
+ * If a virtual server contains no JK directive, httpd shares
+ * the config structure. But we don't want to share some settings
+ * by default, especially the JkMount rules.
+ * Therefore we check, if this config structure really belongs to this
+ * vhost, otherwise we create a new one and merge.
+ */
+        if (sconf && sconf->s != srv && jk_mount_copy_all == JK_FALSE) {
+            jk_server_conf_t *srvconf = (jk_server_conf_t 
*)create_jk_config(p, srv);
+            srvconf = (jk_server_conf_t *)merge_jk_config(p, sconf, srvconf);
+            ap_set_module_config(srv->module_config, &jk_module, srvconf);
         }
-        else if (sconf && sconf->was_initialized == JK_FALSE) {
+
+        if (sconf && sconf->was_initialized == JK_FALSE) {
             sconf->was_initialized = JK_TRUE;
             open_jk_log(srv, p);
             sconf->options &= ~sconf->exclude_options;

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=591510&r1=591509&r2=591510&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 Fri Nov  2 16:19:11 
2007
@@ -2373,31 +2373,6 @@
 }
 
 
-/** Clone jk config.
- */
-static void *clone_jk_config(apr_pool_t * p, server_rec *s)
-{
-    jk_server_conf_t *src =
-        (jk_server_conf_t *)ap_get_module_config(s->module_config, &jk_module);
-    jk_server_conf_t *dst =
-        (jk_server_conf_t *) apr_pcalloc(p, sizeof(jk_server_conf_t));
-
-    memcpy(dst, src, sizeof(jk_server_conf_t));
-    dst->was_initialized = JK_TRUE;
-    dst->s = s;
-    dst->mountcopy = 0;
-    dst->mount_file = NULL;
-    dst->alias_dir = NULL;
-    dst->uri_to_context = NULL;
-    if (!uri_worker_map_alloc(&(dst->uw_map), NULL, dst->log)) {
-        jk_error_exit(APLOG_MARK, APLOG_EMERG, s,
-                      s->process->pool, "Memory error");
-    }
-
-    return dst;
-}
-
-
 /*
  * Utility - copy items from apr table src to dst,
  * for keys that exist in src but not in dst.
@@ -2799,11 +2774,21 @@
             for (; srv; srv = srv->next) {
                 jk_server_conf_t *sconf = (jk_server_conf_t 
*)ap_get_module_config(srv->module_config,
                                                                                
    &jk_module);
-                if (sconf && sconf->was_initialized == JK_TRUE && 
jk_mount_copy_all == JK_FALSE) {
-                    ap_set_module_config(srv->module_config, &jk_module,
-                                         clone_jk_config(pconf, srv));
+
+/*
+ * If a virtual server contains no JK directive, httpd shares
+ * the config structure. But we don't want to share some settings
+ * by default, especially the JkMount rules.
+ * Therefore we check, if this config structure really belongs to this
+ * vhost, otherwise we create a new one and merge.
+ */
+                if (sconf && sconf->s != srv && jk_mount_copy_all == JK_FALSE) 
{
+                    jk_server_conf_t *srvconf = (jk_server_conf_t 
*)create_jk_config(pconf, srv);
+                    srvconf = (jk_server_conf_t *)merge_jk_config(pconf, 
sconf, srvconf);
+                    ap_set_module_config(srv->module_config, &jk_module, 
srvconf);
                 }
-                else if (sconf && sconf->was_initialized == JK_FALSE) {
+
+                if (sconf && sconf->was_initialized == JK_FALSE) {
                     sconf->was_initialized = JK_TRUE;
                     if (open_jklog(srv, pconf))
                         return HTTP_INTERNAL_SERVER_ERROR;



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

Reply via email to