- struct domaintree_entry *elem;
- char *path = apr_pstrdup(pool, DT->prefix);
- APR_RING_FOREACH(elem, tree, domaintree_entry, link) {
- path = apr_pstrcat(pool, path, "/", elem->name, NULL);
+ apr_pool_t *pool;
+ dircache_entry_t *cache_entry;
+
+ apr_pool_create(&pool, DT->dircache.pool);
+ cache_entry = apr_palloc(pool, sizeof(dircache_entry_t));
+
+ cache_entry->pool = pool;
+ cache_entry->lacc = atime;
+ cache_entry->host = apr_pstrdup(pool, host);
+ cache_entry->path = apr_pstrdup(pool, path);
+
+ apr_global_mutex_lock(DT->dircache.lock);
+
+ if (apr_hash_count(DT->dircache.hmap) >= DT->dircache.clim) {
+ apr_hash_index_t *idx;
+ dircache_entry_t *purge_this = NULL;
+
+ DT_LOG_WRN
+ "DomainTree: reached cache limit (%ld)", DT->dircache.clim
+ DT_LOG_END
+
+ for (idx = apr_hash_first(DT->dircache.pool, DT->dircache.hmap); idx; idx = apr_hash_next(idx)) {
+ dircache_entry_t *current;
+
+ apr_hash_this(idx, NULL, NULL, (void *) ¤t);
+ if ((!purge_this) || (purge_this->lacc > current->lacc)) {
+ purge_this = current;
+ }
+ }
+
+ if (purge_this) {
+ DT_LOG_DBG
+ "DomainTree: cache del = %s", purge_this->host
+ DT_LOG_END
+ apr_hash_set(DT->dircache.hmap, purge_this->host, APR_HASH_KEY_STRING, NULL);
+ apr_pool_destroy(purge_this->pool);
+ }