mturk 2004/11/29 23:30:42 Modified: jk/native/apache-1.3 mod_jk.c jk/native/apache-2.0 mod_jk.c jk/native/common jk_uri_worker_map.c Log: Add JkUnMount for blocking context. This is something from JK2. Revision Changes Path 1.53 +36 -2 jakarta-tomcat-connectors/jk/native/apache-1.3/mod_jk.c Index: mod_jk.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-1.3/mod_jk.c,v retrieving revision 1.52 retrieving revision 1.53 diff -u -r1.52 -r1.53 --- mod_jk.c 12 Nov 2004 18:45:24 -0000 1.52 +++ mod_jk.c 30 Nov 2004 07:30:41 -0000 1.53 @@ -673,7 +673,7 @@ &jk_module); char *old; if (context[0] != '/') - return "Context should start with /"; + return "Mount context should start with /"; /* * Add the new worker to the alias map. @@ -683,6 +683,33 @@ } /* + * JkUnMount directive handling + * + * JkUnMount URI(context) worker + */ + +static const char *jk_unmount_context(cmd_parms * cmd, + void *dummy, + const char *context, + const char *worker, + const char *maybe_cookie) +{ + server_rec *s = cmd->server; + jk_server_conf_t *conf = + (jk_server_conf_t *) ap_get_module_config(s->module_config, + &jk_module); + char *old , *uri; + if (context[0] != '/') + return "Unmount context should start with /"; + uri = ap_pstrcat(cmd->temp_pool, "!", context, NULL); + /* + * Add the new worker to the alias map. + */ + jk_map_put(conf->uri_to_context, uri, worker, (void **)&old); + return NULL; +} + +/* * JkAutoMount directive handling * * JkAutoMount worker [virtualhost] @@ -1430,6 +1457,13 @@ "A mount point from a context to a servlet-engine worker"}, /* + * JkUnMount unmounts a url prefix to a worker (the worker need to be + * defined in the worker properties file. + */ + {"JkUnMount", jk_unmount_context, NULL, RSRC_CONF, TAKE23, + "A no mount point from a context to a servlet-engine worker"}, + + /* * JkMountCopy specifies if mod_jk should copy the mount points * from the main server to the virtual servers. */ 1.102 +36 -2 jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c Index: mod_jk.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/apache-2.0/mod_jk.c,v retrieving revision 1.101 retrieving revision 1.102 diff -u -r1.101 -r1.102 --- mod_jk.c 12 Nov 2004 18:45:24 -0000 1.101 +++ mod_jk.c 30 Nov 2004 07:30:42 -0000 1.102 @@ -714,7 +714,7 @@ &jk_module); char *old; if (context[0] != '/') - return "Context should start with /"; + return "Mount xontext should start with /"; /* * Add the new worker to the alias map. @@ -723,6 +723,33 @@ return NULL; } +/* + * JkUnMount directive handling + * + * JkUnMount URI(context) worker + */ + +static const char *jk_unmount_context(cmd_parms * cmd, + void *dummy, + const char *context, + const char *worker, + const char *maybe_cookie) +{ + server_rec *s = cmd->server; + jk_server_conf_t *conf = + (jk_server_conf_t *) ap_get_module_config(s->module_config, + &jk_module); + char *old , *uri; + if (context[0] != '/') + return "Unmount context should start with /"; + uri = apr_pstrcat(cmd->temp_pool, "!", context, NULL); + /* + * Add the new worker to the alias map. + */ + jk_map_put(conf->uri_to_context, uri, worker, (void **)&old); + return NULL; +} + /* * JkAutoMount directive handling @@ -1529,6 +1556,13 @@ */ AP_INIT_TAKE23("JkMount", jk_mount_context, NULL, RSRC_CONF, "A mount point from a context to a Tomcat worker"), + + /* + * JkUnMount unmounts a url prefix to a worker (the worker need to be + * defined in the worker properties file. + */ + AP_INIT_TAKE23("JkUnMount", jk_unmount_context, NULL, RSRC_CONF, + "A no mount point from a context to a Tomcat worker"), /* * JkMountCopy specifies if mod_jk should copy the mount points 1.33 +67 -10 jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c Index: jk_uri_worker_map.c =================================================================== RCS file: /home/cvs/jakarta-tomcat-connectors/jk/native/common/jk_uri_worker_map.c,v retrieving revision 1.32 retrieving revision 1.33 diff -u -r1.32 -r1.33 --- jk_uri_worker_map.c 29 Nov 2004 17:04:10 -0000 1.32 +++ jk_uri_worker_map.c 30 Nov 2004 07:30:42 -0000 1.33 @@ -60,7 +60,11 @@ unsigned ctxt_len; int match_type; + + /* no map directive */ + int no_match; }; + typedef struct uri_worker_record uri_worker_record_t; struct jk_uri_worker_map @@ -270,6 +274,13 @@ JK_TRACE_EXIT(l); return JK_FALSE; } + + if (*puri == '!') { + uwr->no_match = 1; + puri++; + } + else + uwr->no_match = 0; uri = jk_pool_strdup(&uw_map->p, puri); worker = jk_pool_strdup(&uw_map->p, pworker); @@ -281,7 +292,7 @@ return JK_FALSE; } - if ('/' == uri[0]) { + if (uri[0] == '/') { char *asterisk = strchr(uri, '*'); if (asterisk && strchr(asterisk + 1, '*') || @@ -563,12 +574,15 @@ for (i = 0; i < uw_map->size; i++) { uri_worker_record_t *uwr = uw_map->maps[i]; - if (uwr->ctxt_len < longest_match) { - continue; /* can not be a best match anyway */ + /* Check for no match in any case */ + if (uwr->ctxt_len < longest_match && !uwr->no_match) { + /* can not be a best match anyway */ + continue; } jk_log(l, JK_LOG_DEBUG, "Attempting to map context URI '%s'\n", uwr->uri); if (uwr->match_type == MATCH_TYPE_WILDCHAR_PATH) { + char *wname; /* Map is already sorted by ctxt_len */ if (wildchar_match(uri, uwr->context, #ifdef WIN32 @@ -577,17 +591,31 @@ 0 #endif ) == 0) { - - jk_log(l, JK_LOG_DEBUG, - "Found an wildchar match %s -> %s\n", - uwr->worker_name, uwr->context); + wname = uwr->worker_name; + if (uwr->no_match) { + jk_log(l, JK_LOG_DEBUG, + "Found a wildchar no match %s -> %s\n", + uwr->worker_name, uwr->context); + wname = NULL; + } + else + jk_log(l, JK_LOG_DEBUG, + "Found a wildchar match %s -> %s\n", + uwr->worker_name, uwr->context); JK_TRACE_EXIT(l); - return uwr->worker_name; + return wname; } } else if (strncmp(uwr->context, uri, uwr->ctxt_len) == 0) { if (uwr->match_type == MATCH_TYPE_EXACT) { if (strlen(uri) == uwr->ctxt_len) { + if (uwr->no_match) { + jk_log(l, JK_LOG_DEBUG, + "Found an exact no match %s -> %s\n", + uwr->worker_name, uwr->context); + JK_TRACE_EXIT(l); + return NULL; + } jk_log(l, JK_LOG_DEBUG, "Found an exact match %s -> %s\n", uwr->worker_name, uwr->context); @@ -597,6 +625,13 @@ } else if (uwr->match_type == MATCH_TYPE_CONTEXT) { if (uwr->ctxt_len > longest_match) { + if (uwr->no_match) { + jk_log(l, JK_LOG_DEBUG, + "Found a context no match %s -> %s\n", + uwr->worker_name, uwr->context); + JK_TRACE_EXIT(l); + return NULL; + } jk_log(l, JK_LOG_DEBUG, "Found a context match %s -> %s\n", uwr->worker_name, uwr->context); @@ -609,6 +644,13 @@ if (suffix_start >= 0 && 0 == strcmp(uri + suffix_start, uwr->suffix)) { if (uwr->ctxt_len >= longest_match) { + if (uwr->no_match) { + jk_log(l, JK_LOG_DEBUG, + "Found a general no suffix match for %s -> %s\n", + uwr->worker_name, uwr->uri); + JK_TRACE_EXIT(l); + return NULL; + } jk_log(l, JK_LOG_DEBUG, "Found a general suffix match %s -> *%s\n", uwr->worker_name, uwr->suffix); @@ -624,7 +666,14 @@ if (0 == strncmp(suffix_path, uwr->suffix, strlen(uwr->suffix))) { - if (uwr->ctxt_len >= longest_match) { + if (uwr->no_match) { + jk_log(l, JK_LOG_DEBUG, + "Found a general context no match %s -> %s\n", + uwr->worker_name, uwr->context); + JK_TRACE_EXIT(l); + return NULL; + } + else if (uwr->ctxt_len >= longest_match) { jk_log(l, JK_LOG_DEBUG, "Found a general context path match %s -> *%s\n", uwr->worker_name, uwr->suffix); @@ -650,7 +699,15 @@ #else if (strcmp(suffix, uwr->suffix) == 0) { #endif + if (uwr->ctxt_len >= longest_match) { + if (uwr->no_match) { + jk_log(l, JK_LOG_DEBUG, + "Found a no suffix match for %s -> %s\n", + uwr->worker_name, uwr->uri); + JK_TRACE_EXIT(l); + return NULL; + } jk_log(l, JK_LOG_DEBUG, "Found a suffix match %s -> *.%s\n", uwr->worker_name, uwr->suffix);
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]