| 1653 | } |
| 1654 | |
| 1655 | AP_DECLARE(int) ap_file_walk(request_rec *r) |
| 1656 | { |
| 1657 | ap_conf_vector_t *now_merged = NULL; |
| 1658 | core_dir_config *dconf = ap_get_core_module_config(r->per_dir_config); |
| 1659 | ap_conf_vector_t **sec_ent = NULL; |
| 1660 | int num_sec = 0; |
| 1661 | walk_cache_t *cache; |
| 1662 | const char *test_file; |
| 1663 | int cached; |
| 1664 | |
| 1665 | if (dconf->sec_file) { |
| 1666 | sec_ent = (ap_conf_vector_t **)dconf->sec_file->elts; |
| 1667 | num_sec = dconf->sec_file->nelts; |
| 1668 | } |
| 1669 | |
| 1670 | /* To allow broken modules to proceed, we allow missing filenames to pass. |
| 1671 | * We will catch it later if it's heading for the core handler. |
| 1672 | * directory_walk already posted an INFO note for module debugging. |
| 1673 | */ |
| 1674 | if (r->filename == NULL) { |
| 1675 | return OK; |
| 1676 | } |
| 1677 | |
| 1678 | /* No tricks here, there are just no <Files > to parse in this context. |
| 1679 | * We won't destroy the cache, just in case _this_ redirect is later |
| 1680 | * redirected again to a context containing the same or similar <Files >. |
| 1681 | */ |
| 1682 | if (!num_sec) { |
| 1683 | return OK; |
| 1684 | } |
| 1685 | |
| 1686 | cache = prep_walk_cache(AP_NOTE_FILE_WALK, r); |
| 1687 | cached = (cache->cached != NULL); |
| 1688 | |
| 1689 | /* Get the basename .. and copy for the cache just |
| 1690 | * in case r->filename is munged by another module |
| 1691 | */ |
| 1692 | test_file = strrchr(r->filename, '/'); |
| 1693 | if (test_file == NULL) { |
| 1694 | test_file = apr_pstrdup(r->pool, r->filename); |
| 1695 | } |
| 1696 | else { |
| 1697 | test_file = apr_pstrdup(r->pool, ++test_file); |
| 1698 | } |
| 1699 | |
| 1700 | /* If we have an cache->cached file name that matches test_file, |
| 1701 | * and the directory's list of file sections hasn't changed, we |
| 1702 | * can skip rewalking the file_walk entries. |
| 1703 | */ |
| 1704 | if (cached |
| 1705 | && (cache->dir_conf_tested == sec_ent) |
| 1706 | && (strcmp(test_file, cache->cached) == 0)) { |
| 1707 | /* Well this looks really familiar! If our end-result (per_dir_result) |
| 1708 | * didn't change, we have absolutely nothing to do :) |
| 1709 | * Otherwise (as is the case with most dir_merged requests) |
| 1710 | * we must merge our dir_conf_merged onto this new r->per_dir_config. |
| 1711 | */ |
| 1712 | if (r->per_dir_config == cache->per_dir_result) { |
no test coverage detected