| 402 | } |
| 403 | |
| 404 | static int open_entity(cache_handle_t *h, request_rec *r, const char *key) |
| 405 | { |
| 406 | apr_uint32_t format; |
| 407 | apr_size_t len; |
| 408 | const char *nkey; |
| 409 | apr_status_t rc; |
| 410 | static int error_logged = 0; |
| 411 | disk_cache_conf *conf = ap_get_module_config(r->server->module_config, |
| 412 | &cache_disk_module); |
| 413 | #ifdef APR_SENDFILE_ENABLED |
| 414 | core_dir_config *coreconf = ap_get_core_module_config(r->per_dir_config); |
| 415 | #endif |
| 416 | apr_finfo_t finfo; |
| 417 | cache_object_t *obj; |
| 418 | cache_info *info; |
| 419 | disk_cache_object_t *dobj; |
| 420 | int flags; |
| 421 | apr_pool_t *pool; |
| 422 | |
| 423 | h->cache_obj = NULL; |
| 424 | |
| 425 | /* Look up entity keyed to 'url' */ |
| 426 | if (conf->cache_root == NULL) { |
| 427 | if (!error_logged) { |
| 428 | error_logged = 1; |
| 429 | ap_log_rerror(APLOG_MARK, APLOG_ERR, 0, r, APLOGNO(00703) |
| 430 | "Cannot cache files to disk without a CacheRoot specified."); |
| 431 | } |
| 432 | return DECLINED; |
| 433 | } |
| 434 | |
| 435 | /* Create and init the cache object */ |
| 436 | obj = apr_pcalloc(r->pool, sizeof(cache_object_t)); |
| 437 | dobj = apr_pcalloc(r->pool, sizeof(disk_cache_object_t)); |
| 438 | |
| 439 | info = &(obj->info); |
| 440 | |
| 441 | /* Open the headers file */ |
| 442 | dobj->prefix = NULL; |
| 443 | |
| 444 | /* Save the cache root */ |
| 445 | dobj->root = apr_pstrmemdup(r->pool, conf->cache_root, conf->cache_root_len); |
| 446 | dobj->root_len = conf->cache_root_len; |
| 447 | |
| 448 | dobj->vary.file = header_file(r->pool, conf, dobj, key); |
| 449 | flags = APR_READ|APR_BINARY|APR_BUFFERED; |
| 450 | rc = apr_file_open(&dobj->vary.fd, dobj->vary.file, flags, 0, r->pool); |
| 451 | if (rc != APR_SUCCESS) { |
| 452 | return DECLINED; |
| 453 | } |
| 454 | |
| 455 | /* read the format from the cache file */ |
| 456 | len = sizeof(format); |
| 457 | apr_file_read_full(dobj->vary.fd, &format, len, &len); |
| 458 | |
| 459 | if (format == VARY_FORMAT_VERSION) { |
| 460 | apr_array_header_t* varray; |
| 461 | apr_time_t expire; |
nothing calls this directly
no test coverage detected