MCPcopy Create free account
hub / github.com/apache/httpd / prep_walk_cache

Function prep_walk_cache

server/request.c:451–501  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

449} walk_cache_t;
450
451static walk_cache_t *prep_walk_cache(apr_size_t t, request_rec *r)
452{
453 void **note, **inherit_note;
454 walk_cache_t *cache, *prev_cache, *copy_cache;
455 int count;
456
457 /* Find the most relevant, recent walk cache to work from and provide
458 * a copy the caller is allowed to munge. In the case of a sub-request
459 * or internal redirect, this is the cache corresponding to the equivalent
460 * invocation of the same function call in the "parent" request, if such
461 * a cache exists. Otherwise it is the walk cache of the previous
462 * invocation of the same function call in the current request, if
463 * that exists; if not, then create a new walk cache.
464 */
465 note = ap_get_request_note(r, t);
466 AP_DEBUG_ASSERT(note != NULL);
467
468 copy_cache = prev_cache = *note;
469 count = prev_cache ? (prev_cache->count + 1) : 0;
470
471 if ((r->prev
472 && (inherit_note = ap_get_request_note(r->prev, t))
473 && *inherit_note)
474 || (r->main
475 && (inherit_note = ap_get_request_note(r->main, t))
476 && *inherit_note)) {
477 walk_cache_t *inherit_cache = *inherit_note;
478
479 while (inherit_cache->count > count) {
480 inherit_cache = inherit_cache->prev;
481 }
482 if (inherit_cache->count == count) {
483 copy_cache = inherit_cache;
484 }
485 }
486
487 if (copy_cache) {
488 cache = apr_pmemdup(r->pool, copy_cache, sizeof(*cache));
489 cache->walked = apr_array_copy(r->pool, cache->walked);
490 cache->prev = prev_cache;
491 cache->count = count;
492 }
493 else {
494 cache = apr_pcalloc(r->pool, sizeof(*cache));
495 cache->walked = apr_array_make(r->pool, 4, sizeof(walk_walked_t));
496 }
497
498 *note = cache;
499
500 return cache;
501}
502
503/*****************************************************************
504 *

Callers 4

ap_directory_walkFunction · 0.85
ap_location_walkFunction · 0.85
ap_file_walkFunction · 0.85
ap_if_walk_subFunction · 0.85

Calls 1

ap_get_request_noteFunction · 0.85

Tested by

no test coverage detected