Author: rjung
Date: Thu Oct 16 10:03:36 2008
New Revision: 705283

URL: http://svn.apache.org/viewvc?rev=705283&view=rev
Log:
Fix bug concerning handling the two generations of
uri worker maps.

If we have maps coming from JkMount and from uriworkermap,
the ones from JkMount get lost.

To make better understandable how uri worker map generations  work,
separate the generation switch from the extension parsing.

Also formally add extension parsing and generation switch to netscape,
though extensions won't yet work there.

Finally add a uri worker map dump function and use it for debug logging.
This makes analyzing similar problems easier in the future.

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/native/common/jk_uri_worker_map.c
    tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.h
    tomcat/connectors/trunk/jk/native/iis/jk_isapi_plugin.c
    tomcat/connectors/trunk/jk/native/netscape/jk_nsapi_plugin.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=705283&r1=705282&r2=705283&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 Thu Oct 16 10:03:36 
2008
@@ -2622,6 +2622,7 @@
                 if (sconf->mount_file) {
                     sconf->uw_map->fname = sconf->mount_file;
                     sconf->uw_map->reload = sconf->mount_file_reload;
+                    uri_worker_map_switch(sconf->uw_map, sconf->log);
                     uri_worker_map_load(sconf->uw_map, sconf->log);
                 }
             }
@@ -2734,13 +2735,17 @@
                       "Error in creating the workers."
                       " Please consult your mod_jk log file '%s'.", 
conf->log_file);
     }
-    if (conf->uw_map)
+    if (conf->uw_map) {
         uri_worker_map_ext(conf->uw_map, conf->log);
+        uri_worker_map_switch(conf->uw_map, conf->log);
+    }
     for (srv = s; srv; srv = srv->next) {
         jk_server_conf_t *sconf = (jk_server_conf_t 
*)ap_get_module_config(srv->module_config,
                                                                            
&jk_module);
-        if (conf->uw_map != sconf->uw_map && sconf->uw_map)
+        if (conf->uw_map != sconf->uw_map && sconf->uw_map) {
             uri_worker_map_ext(sconf->uw_map, sconf->log);
+            uri_worker_map_switch(sconf->uw_map, sconf->log);
+        }
     }
 
 }

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=705283&r1=705282&r2=705283&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 Thu Oct 16 10:03:36 
2008
@@ -3100,6 +3100,7 @@
                         if (sconf->mount_file) {
                             sconf->uw_map->fname = sconf->mount_file;
                             sconf->uw_map->reload = sconf->mount_file_reload;
+                            uri_worker_map_switch(sconf->uw_map, sconf->log);
                             uri_worker_map_load(sconf->uw_map, sconf->log);
                         }
                     }
@@ -3147,13 +3148,17 @@
             conf->was_initialized = JK_TRUE;
             if (init_jk(pconf, conf, s) == JK_FALSE)
                 return HTTP_INTERNAL_SERVER_ERROR;
-            if (conf->uw_map)
+            if (conf->uw_map) {
                 uri_worker_map_ext(conf->uw_map, conf->log);
+                uri_worker_map_switch(conf->uw_map, conf->log);
+            }
             for (srv = s; srv; srv = srv->next) {
                 jk_server_conf_t *sconf = (jk_server_conf_t 
*)ap_get_module_config(srv->module_config,
                                                                                
    &jk_module);
-                if (conf->uw_map != sconf->uw_map && sconf->uw_map)
+                if (conf->uw_map != sconf->uw_map && sconf->uw_map) {
                     uri_worker_map_ext(sconf->uw_map, sconf->log);
+                    uri_worker_map_switch(sconf->uw_map, sconf->log);
+                }
             }
 
         }

Modified: tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c?rev=705283&r1=705282&r2=705283&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.c Thu Oct 16 
10:03:36 2008
@@ -46,8 +46,11 @@
 #define JK_UWMAP_EXTENSION_FAIL_ON_STATUS "fail_on_status="
 #define JK_UWMAP_EXTENSION_USE_SRV_ERRORS "use_server_errors="
 
+#define IND_SWITCH(x)                      (((x)+1) % 2)
 #define IND_THIS(x)                        ((x)[uw_map->index])
-#define IND_NEXT(x)                        ((x)[(uw_map->index+1) % 2])
+#define IND_NEXT(x)                        ((x)[IND_SWITCH(uw_map->index)])
+
+#define STRNULL_FOR_NULL(x) ((x) ? (x) : "(null)")
 
 static const char *uri_worker_map_source_type[] = {
     "unknown",
@@ -156,6 +159,42 @@
 
 }
 
+/* Dump the map contents - only call if debug log is active. */
+static void uri_worker_map_dump(jk_uri_worker_map_t *uw_map,
+                                const char *reason, jk_logger_t *l)
+{
+    JK_TRACE_ENTER(l);
+    if (uw_map) {
+        int i, j, off, k;
+        uri_worker_record_t *uwr = NULL;
+        char buf[32];
+        jk_log(l, JK_LOG_DEBUG, "uri map dump %s: index=%d file='%s' 
reject_unsafe=%d "
+               "reload=%d modified=%d checked=%d",
+               reason, uw_map->index, STRNULL_FOR_NULL(uw_map->fname), 
uw_map->reject_unsafe,
+               uw_map->reload, uw_map->modified, uw_map->checked);
+        for(i=0;i<=1;i++) {
+            jk_log(l, JK_LOG_DEBUG, "generation %d: size=%d nosize=%d 
capacity=%d",
+                   i, uw_map->size[i], uw_map->nosize[i], uw_map->capacity[i], 
uw_map->maps[i]);
+        }
+
+        off = uw_map->index;
+        for(i=0;i<=1;i++) {
+            k = (i + off) % 2;
+            for (j = 0; j < uw_map->size[k]; j++) {
+                uwr = uw_map->maps[k][j];
+                jk_log(l, JK_LOG_DEBUG, "%s (%d) map #%d: uri=%s worker=%s 
context=%s "
+                       "source=%s type=%s len=%d",
+                       i ? "NEXT" : "THIS", i, j,
+                       STRNULL_FOR_NULL(uwr->uri), 
STRNULL_FOR_NULL(uwr->worker_name),
+                       STRNULL_FOR_NULL(uwr->context), 
STRNULL_FOR_NULL(uri_worker_map_get_source(uwr,l)),
+                       STRNULL_FOR_NULL(uri_worker_map_get_match(uwr,buf,l)), 
uwr->context_len);
+            }
+        }
+    }
+    JK_TRACE_EXIT(l);
+}
+
+
 int uri_worker_map_alloc(jk_uri_worker_map_t **uw_map_p,
                          jk_map_t *init_data, jk_logger_t *l)
 {
@@ -430,6 +469,26 @@
 
 }
 
+void uri_worker_map_switch(jk_uri_worker_map_t *uw_map, jk_logger_t *l)
+{
+    int new_index;
+
+    JK_TRACE_ENTER(l);
+
+    if (uw_map) {
+        new_index = IND_SWITCH(uw_map->index);
+        if (JK_IS_DEBUG_LEVEL(l))
+            jk_log(l, JK_LOG_DEBUG,
+                   "Switching uri worker map from index %d to index %d",
+                   uw_map->index, new_index);
+        uw_map->index = new_index;
+        jk_reset_pool(&(IND_NEXT(uw_map->p_dyn)));
+    }
+
+    JK_TRACE_EXIT(l);
+
+}
+
 void uri_worker_map_ext(jk_uri_worker_map_t *uw_map, jk_logger_t *l)
 {
     unsigned int i;
@@ -510,14 +569,15 @@
             extract_fail_on_status(uw_map, uwr, l);
         }
     }
-    uw_map->index = (uw_map->index + 1) % 2;
-    jk_reset_pool(&(IND_NEXT(uw_map->p_dyn)));
+    if (JK_IS_DEBUG_LEVEL(l))
+        uri_worker_map_dump(uw_map, "after extension stripping", l);
 
     JK_TRACE_EXIT(l);
     return;
 
 }
 
+/* Add new entry to NEXT generation */
 int uri_worker_map_add(jk_uri_worker_map_t *uw_map,
                        const char *puri, const char *worker,
                        unsigned int source_type, jk_logger_t *l)
@@ -762,6 +822,8 @@
             jk_close_pool(&uw_map->p_dyn[1]);
             jk_close_pool(&uw_map->p);
         }
+        else if (JK_IS_DEBUG_LEVEL(l))
+            uri_worker_map_dump(uw_map, "after map open", l);
     }
 
     JK_TRACE_EXIT(l);
@@ -1076,6 +1138,8 @@
             }
         }
         uw_map->checked = time(NULL);
+        if (JK_IS_DEBUG_LEVEL(l))
+            uri_worker_map_dump(uw_map, "after file load", l);
         rc = JK_TRUE;
     }
     jk_map_free(&map);
@@ -1117,6 +1181,7 @@
         }
         rc = uri_worker_map_load(uw_map, l);
         uri_worker_map_ext(uw_map, l);
+        uri_worker_map_switch(uw_map, l);
         JK_LEAVE_CS(&(uw_map->cs), rc);
         jk_log(l, JK_LOG_INFO,
                "Reloaded urimaps from %s", uw_map->fname);

Modified: tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.h
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.h?rev=705283&r1=705282&r2=705283&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.h (original)
+++ tomcat/connectors/trunk/jk/native/common/jk_uri_worker_map.h Thu Oct 16 
10:03:36 2008
@@ -175,6 +175,8 @@
 int uri_worker_map_open(jk_uri_worker_map_t *uw_map,
                         jk_map_t *init_data, jk_logger_t *l);
 
+void uri_worker_map_switch(jk_uri_worker_map_t *uw_map, jk_logger_t *l);
+
 void uri_worker_map_ext(jk_uri_worker_map_t *uw_map, jk_logger_t *l);
 
 int uri_worker_map_add(jk_uri_worker_map_t *uw_map,

Modified: tomcat/connectors/trunk/jk/native/iis/jk_isapi_plugin.c
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/iis/jk_isapi_plugin.c?rev=705283&r1=705282&r2=705283&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/iis/jk_isapi_plugin.c (original)
+++ tomcat/connectors/trunk/jk/native/iis/jk_isapi_plugin.c Thu Oct 16 10:03:36 
2008
@@ -2538,6 +2538,7 @@
                     rc = JK_TRUE;
                 }
                 uri_worker_map_ext(uw_map, logger);
+                uri_worker_map_switch(uw_map, logger);
             }
             else
                 jk_log(logger, JK_LOG_EMERG,

Modified: tomcat/connectors/trunk/jk/native/netscape/jk_nsapi_plugin.c
URL: 
http://svn.apache.org/viewvc/tomcat/connectors/trunk/jk/native/netscape/jk_nsapi_plugin.c?rev=705283&r1=705282&r2=705283&view=diff
==============================================================================
--- tomcat/connectors/trunk/jk/native/netscape/jk_nsapi_plugin.c (original)
+++ tomcat/connectors/trunk/jk/native/netscape/jk_nsapi_plugin.c Thu Oct 16 
10:03:36 2008
@@ -101,6 +101,8 @@
         worker_env.uri_to_worker = uw_map;
         if (wc_open(init_map, &worker_env, logger)) {
             init_on_other_thread_is_ok = JK_TRUE;
+            uri_worker_map_ext(uw_map, logger);
+            uri_worker_map_switch(uw_map, logger);
         }
         else {
             jk_log(logger, JK_LOG_EMERG,



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

Reply via email to