| 1122 | */ |
| 1123 | |
| 1124 | static void set_cache_value(const char *name, apr_time_t t, char *key, |
| 1125 | char *val) |
| 1126 | { |
| 1127 | cachedmap *map; |
| 1128 | |
| 1129 | if (cachep) { |
| 1130 | #if APR_HAS_THREADS |
| 1131 | apr_thread_mutex_lock(cachep->lock); |
| 1132 | #endif |
| 1133 | map = apr_hash_get(cachep->maps, name, APR_HASH_KEY_STRING); |
| 1134 | |
| 1135 | if (!map) { |
| 1136 | apr_pool_t *p; |
| 1137 | |
| 1138 | if (apr_pool_create(&p, cachep->pool) != APR_SUCCESS) { |
| 1139 | #if APR_HAS_THREADS |
| 1140 | apr_thread_mutex_unlock(cachep->lock); |
| 1141 | #endif |
| 1142 | return; |
| 1143 | } |
| 1144 | apr_pool_tag(p, "rewrite_cachedmap"); |
| 1145 | |
| 1146 | map = apr_palloc(cachep->pool, sizeof(cachedmap)); |
| 1147 | map->pool = p; |
| 1148 | map->entries = apr_hash_make(map->pool); |
| 1149 | map->mtime = t; |
| 1150 | |
| 1151 | apr_hash_set(cachep->maps, name, APR_HASH_KEY_STRING, map); |
| 1152 | } |
| 1153 | else if (map->mtime != t) { |
| 1154 | apr_pool_clear(map->pool); |
| 1155 | map->entries = apr_hash_make(map->pool); |
| 1156 | map->mtime = t; |
| 1157 | } |
| 1158 | |
| 1159 | /* Now we should have a valid map->entries hash, where we |
| 1160 | * can store our value. |
| 1161 | * |
| 1162 | * We need to copy the key and the value into OUR pool, |
| 1163 | * so that we don't leave it during the r->pool cleanup. |
| 1164 | */ |
| 1165 | apr_hash_set(map->entries, |
| 1166 | apr_pstrdup(map->pool, key), APR_HASH_KEY_STRING, |
| 1167 | apr_pstrdup(map->pool, val)); |
| 1168 | |
| 1169 | #if APR_HAS_THREADS |
| 1170 | apr_thread_mutex_unlock(cachep->lock); |
| 1171 | #endif |
| 1172 | } |
| 1173 | |
| 1174 | return; |
| 1175 | } |
| 1176 | |
| 1177 | static char *get_cache_value(const char *name, apr_time_t t, char *key, |
| 1178 | apr_pool_t *p) |