tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rj...@apache.org
Subject svn commit: r580800 - in /tomcat/connectors/trunk/jk/native: apache-1.3/mod_jk.c apache-2.0/mod_jk.c
Date Sun, 30 Sep 2007 22:17:49 GMT
Author: rjung
Date: Sun Sep 30 15:17:48 2007
New Revision: 580800

URL: http://svn.apache.org/viewvc?rev=580800&view=rev
Log:
Clone server config in case a servers share their
config.
Because by default we (unfortunately)
don't inherit mounts between servers, a vhost with
no JK directive needs to become it's own server
config with an empty uw_map.
In this case Apache httpd itself will not call our
config create function and we need to clone the
config ourselves.
The old code simply overwrote uw_map with a new one
and the old one never got freed leading to a memory
leak of 8KB per vhost with no JK directoves.

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=580800&r1=580799&r2=580800&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 Sun Sep 30 15:17:48 2007
@@ -2243,6 +2243,31 @@
 }
 
 
+/*
+ *  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;
+}
+
+
 static void copy_jk_map(ap_pool * p, server_rec * s, jk_map_t *src,
                         jk_map_t *dst)
 {
@@ -2486,7 +2511,11 @@
     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_FALSE) {
+        if (sconf && sconf->was_initialized == JK_TRUE) {
+            ap_set_module_config(srv->module_config, &jk_module,
+                                 clone_jk_config(p, srv));
+        }
+        else 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=580800&r1=580799&r2=580800&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 Sun Sep 30 15:17:48 2007
@@ -2358,6 +2358,31 @@
 }
 
 
+/** 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 a map . XXX Should move to jk_map, it's generic code.
  */
 static void copy_jk_map(apr_pool_t * p, server_rec * s, jk_map_t *src,
@@ -2773,7 +2798,11 @@
             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_FALSE) {
+                if (sconf && sconf->was_initialized == JK_TRUE) {
+                    ap_set_module_config(srv->module_config, &jk_module,
+                                         clone_jk_config(pconf, srv));
+                }
+                else 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: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message