Changes with Apache 2.0.35
+ *) Add a new parameter to the quick_handler hook to instruct
+ quick handlers to optionally do a lookup rather than actually
+ serve content. This is the first of several changes required fix
+ several problems with how quick handlers work with subrequests.
+ [Bill Stoddard]
*) worker MPM: Get MaxRequestsPerChild to work again. [Jeff Trawick]
* 20020306 (2.0.34-dev) bump for filter type renames.
* 20020318 (2.0.34-dev) mod_dav's API for REPORT generation changed
* 20020319 (2.0.34-dev) M_INVALID changed, plus new M_* methods for RFC 3253
+ * 20020327 (2.0.35-dev) Add parameter to quick_handler hook
*/
#define MODULE_MAGIC_COOKIE 0x41503230UL /* "AP20" */
#ifndef MODULE_MAGIC_NUMBER_MAJOR
-#define MODULE_MAGIC_NUMBER_MAJOR 20020319
+#define MODULE_MAGIC_NUMBER_MAJOR 20020327
#endif
#define MODULE_MAGIC_NUMBER_MINOR 0 /* 0...n */
#define MODULE_MAGIC_NUMBER MODULE_MAGIC_NUMBER_MAJOR /* backward compat */
* is run before any other requests hooks are called (location_walk,
* directory_walk, access checking, et. al.). This hook was added
* to provide a quick way to serve content from a URI keyed cache.
+ *
* @param r The request_rec
+ * @param lookup_uri Controls whether the caller actually wants content or not.
+ * lookup is set when the quick_handler is called out of
+ * ap_sub_req_lookup_uri()
*/
-AP_DECLARE_HOOK(int,quick_handler,(request_rec *r))
+AP_DECLARE_HOOK(int,quick_handler,(request_rec *r, int lookup_uri))
/**
* Retrieve the optional functions for each module.
* oh well.
*/
-static int cache_url_handler(request_rec *r)
+static int cache_url_handler(request_rec *r, int lookup)
{
apr_status_t rv;
const char *cc_in, *pragma, *auth;
rv = cache_select_url(r, cache->types, url);
if (DECLINED == rv) {
- /* no existing cache file */
- ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
- "cache: no cache - add cache_in filter and DECLINE");
- /* add cache_in filter to cache this request */
- ap_add_output_filter("CACHE_IN", NULL, r, r->connection);
- /* return DECLINED */
+ if (!lookup) {
+ /* no existing cache file */
+ ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
+ "cache: no cache - add cache_in filter and DECLINE");
+ /* add cache_in filter to cache this request */
+ ap_add_output_filter("CACHE_IN", NULL, r, r->connection);
+ }
return DECLINED;
}
else if (OK == rv) {
apr_bucket_brigade *out;
/* fresh data available */
+ if (lookup) {
+ return OK;
+ }
ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
"cache: fresh cache - add cache_out filter and "
"handle request");
}
else {
/* stale data available */
+ if (lookup) {
+ return DECLINED;
+ }
+
ap_log_error(APLOG_MARK, APLOG_DEBUG | APLOG_NOERRNO, 0, r->server,
"cache: stale cache - test conditional");
/* if conditional request */
{
int access_status;
- access_status = ap_process_request_internal(r);
- if (access_status == OK) {
- access_status = ap_invoke_handler(r);
+ /* Give quick handlers a shot at serving the request on the fast
+ * path, bypassing all of the other Apache hooks.
+ *
+ * This hook was added to enable serving files out of a URI keyed
+ * content cache ( e.g., Mike Abbott's Quick Shortcut Cache,
+ * described here: http://oss.sgi.com/projects/apache/mod_qsc.html )
+ *
+ * It may have other uses as well, such as routing requests directly to
+ * content handlers that have the ability to grok HTTP and do their
+ * own access checking, etc (e.g. servlet engines).
+ *
+ * Use this hook with extreme care and only if you know what you are
+ * doing.
+ */
+ access_status = ap_run_quick_handler(r, 0); /* Not a look-up request */
+ if (access_status == DECLINED) {
+ access_status = ap_process_request_internal(r);
+ if (access_status == OK) {
+ access_status = ap_invoke_handler(r);
+ }
}
- else if (access_status == DONE) {
+
+ if (access_status == DONE) {
/* e.g., something not in storage like TRACE */
access_status = OK;
}
AP_IMPLEMENT_HOOK_RUN_FIRST(int, handler, (request_rec *r),
(r), DECLINED)
-AP_IMPLEMENT_HOOK_RUN_FIRST(int, quick_handler, (request_rec *r),
- (r), DECLINED)
+AP_IMPLEMENT_HOOK_RUN_FIRST(int, quick_handler, (request_rec *r, int lookup),
+ (r, lookup), DECLINED)
AP_IMPLEMENT_HOOK_VOID(optional_fn_retrieve, (void), ())
int file_req = (r->main && r->filename);
int access_status;
- /* Give quick handlers a shot at serving the request on the fast
- * path, bypassing all of the other Apache hooks. Bypass the call
- * for dirent subrequests (any other cases to bypass?)
- *
- * This hook was added to enable serving files out of a URI keyed
- * content cache ( e.g., Mike Abbott's Quick Shortcut Cache,
- * described here: http://oss.sgi.com/projects/apache/mod_qsc.html )
- *
- * It may have other uses as well, such as routing requests directly to
- * content handlers that have the ability to grok HTTP and do their
- * own access checking, etc (e.g. servlet engines).
- *
- * Use this hook with extreme care and only if you know what you are
- * doing. This hook is available to (non dirent) subrequests.
- */
- if (!(r->main && r->filename && r->finfo.filetype)) {
- /* TODO?: Add a field to the request_rec explicitly identifying
- * the type of subrequest?
- */
- access_status = ap_run_quick_handler(r);
- if (access_status != DECLINED) {
- if (access_status == OK) {
- return DONE;
- }
- else {
- return access_status;
- }
- }
- }
-
/* Ignore embedded %2F's in path for proxy requests */
if (!r->proxyreq && r->parsed_uri.path) {
access_status = ap_unescape_url(r->parsed_uri.path);
udir = ap_escape_uri(rnew->pool, udir); /* re-escape it */
ap_parse_uri(rnew, ap_make_full_path(rnew->pool, udir, new_file));
}
+ /* lookup_uri
+ * If the content can be served by the quick_handler, we can
+ * safely bypass request_internal processing.
+ */
+ res = ap_run_quick_handler(rnew, 1);
- if ((res = ap_process_request_internal(rnew))) {
- rnew->status = res;
- }
+ if (res != OK) {
+ if ((res = ap_process_request_internal(rnew))) {
+ rnew->status = res;
+ }
+ }
return rnew;
}
AP_DECLARE(int) ap_run_sub_req(request_rec *r)
{
- int retval;
-
- retval = ap_invoke_handler(r);
+ int retval = DECLINED;
+ /* Run the quick handler if the subrequest is not a dirent or file
+ * subrequest
+ */
+ if (!(r->filename && r->finfo.filetype)) {
+ retval = ap_run_quick_handler(r, 0);
+ }
+ if (retval != OK) {
+ retval = ap_invoke_handler(r);
+ }
ap_finalize_sub_req_protocol(r);
return retval;
}