| 1175 | } |
| 1176 | |
| 1177 | static char *get_cache_value(const char *name, apr_time_t t, char *key, |
| 1178 | apr_pool_t *p) |
| 1179 | { |
| 1180 | cachedmap *map; |
| 1181 | char *val = NULL; |
| 1182 | |
| 1183 | if (cachep) { |
| 1184 | #if APR_HAS_THREADS |
| 1185 | apr_thread_mutex_lock(cachep->lock); |
| 1186 | #endif |
| 1187 | map = apr_hash_get(cachep->maps, name, APR_HASH_KEY_STRING); |
| 1188 | |
| 1189 | if (map) { |
| 1190 | /* if this map is outdated, forget it. */ |
| 1191 | if (map->mtime != t) { |
| 1192 | apr_pool_clear(map->pool); |
| 1193 | map->entries = apr_hash_make(map->pool); |
| 1194 | map->mtime = t; |
| 1195 | } |
| 1196 | else { |
| 1197 | val = apr_hash_get(map->entries, key, APR_HASH_KEY_STRING); |
| 1198 | if (val) { |
| 1199 | /* copy the cached value into the supplied pool, |
| 1200 | * where it belongs (r->pool usually) |
| 1201 | */ |
| 1202 | val = apr_pstrdup(p, val); |
| 1203 | } |
| 1204 | } |
| 1205 | } |
| 1206 | |
| 1207 | #if APR_HAS_THREADS |
| 1208 | apr_thread_mutex_unlock(cachep->lock); |
| 1209 | #endif |
| 1210 | } |
| 1211 | |
| 1212 | return val; |
| 1213 | } |
| 1214 | |
| 1215 | static int init_cache(apr_pool_t *p) |
| 1216 | { |