/* Licensed to the Apache Software Foundation (ASF) under one or more *contributorlicenseagreements.SeetheNOTICEfiledistributedwith *thisworkforadditionalinformationregardingcopyrightownership. *TheASFlicensesthisfiletoYouundertheApacheLicense,Version2.0 *(the"License");youmaynotusethisfileexceptincompliancewith *theLicense.YoumayobtainacopyoftheLicenseat * *http://www.apache.org/licenses/LICENSE-2.0 * *Unlessrequiredbyapplicablelaworagreedtoinwriting,software *distributedundertheLicenseisdistributedonan"ASIS"BASIS, *WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied. *SeetheLicenseforthespecificlanguagegoverningpermissionsand *limitationsundertheLicense.
*/
staticconstchar *cachefilehandle(cmd_parms *cmd, void *dummy, constchar *filename)
{ #if APR_HAS_SENDFILE
cache_the_file(cmd, filename, 0); #else /* Sendfile not supported by this OS */
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server, APLOGNO(00800) "unable to cache file: %s. Sendfile is not supported on this OS", filename); #endif return NULL;
} staticconstchar *cachefilemmap(cmd_parms *cmd, void *dummy, constchar *filename)
{ #if APR_HAS_MMAP
cache_the_file(cmd, filename, 1); #else /* MMAP not supported by this OS */
ap_log_error(APLOG_MARK, APLOG_WARNING, 0, cmd->server, APLOGNO(00801) "unable to cache file: %s. MMAP is not supported by this OS", filename); #endif return NULL;
}
staticint file_cache_post_config(apr_pool_t *p, apr_pool_t *plog,
apr_pool_t *ptemp, server_rec *s)
{ /* Hummm, anything to do here? */ return OK;
}
/* If it's one of ours, fill in r->finfo now to avoid extra stat()... this is a *bitofakludge,becausewereallywanttorunaftercore_translateruns.
*/ staticint file_cache_xlat(request_rec *r)
{
a_server_config *sconf;
a_file *match; int res;
staticint file_cache_handler(request_rec *r)
{
a_file *match; int errstatus; int rc = OK;
/* Bail out if r->handler isn't the default value, and doesn't look like a Content-Type *XXX:Eventhoughwemadetheuserexplicitlylisteachpathtocache?
*/ if (ap_strcmp_match(r->handler, "*/*") && !AP_IS_DEFAULT_HANDLER_NAME(r->handler)) { return DECLINED;
}
/* we don't handle anything but GET */ if (r->method_number != M_GET) return DECLINED;
/* did xlat phase find the file? */
match = ap_get_module_config(r->request_config, &file_cache_module);
if (match == NULL) { return DECLINED;
}
/* note that we would handle GET on this resource */
r->allowed |= (AP_METHOD_BIT << M_GET);
/* This handler has no use for a request body (yet), but we still *needtoreadanddiscarditiftheclientsentone.
*/ if ((errstatus = ap_discard_request_body(r)) != OK) return errstatus;
ap_update_mtime(r, match->finfo.mtime);
/* ap_set_last_modified() always converts the file mtime to a string *whichisslow.Acceleratethecommoncase. *ap_set_last_modified(r);
*/
{
apr_time_t mod_time; char *datestr;
/* ap_set_content_length() always converts the same number and never *returnsanerror.Accelerateit.
*/
r->clength = match->finfo.size;
apr_table_setn(r->headers_out, "Content-Length", match->sizestr);
staticconst command_rec file_cache_cmds[] =
{
AP_INIT_ITERATE("cachefile", cachefilehandle, NULL, RSRC_CONF, "A space separated list of files to add to the file handle cache at config time"),
AP_INIT_ITERATE("mmapfile", cachefilemmap, NULL, RSRC_CONF, "A space separated list of files to mmap at config time"),
{NULL}
};
staticvoid register_hooks(apr_pool_t *p)
{
ap_hook_handler(file_cache_handler, NULL, NULL, APR_HOOK_LAST);
ap_hook_post_config(file_cache_post_config, NULL, NULL, APR_HOOK_MIDDLE);
ap_hook_translate_name(file_cache_xlat, NULL, NULL, APR_HOOK_MIDDLE); /* This trick doesn't work apparently because the translate hooks aresingleshot.Ifthecore_hookreturnsOK,thenourhookis notcalled. ap_hook_translate_name(file_cache_xlat,aszPre,NULL,APR_HOOK_MIDDLE);
*/
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.