These two functions get and put state information into the data * file for an ap_cache_el, this state information will be read * and written transparent to clients of this module */
| 216 | * and written transparent to clients of this module |
| 217 | */ |
| 218 | static int file_cache_recall_mydata(apr_file_t *fd, cache_info *info, |
| 219 | disk_cache_object_t *dobj, request_rec *r) |
| 220 | { |
| 221 | apr_status_t rv; |
| 222 | char *urlbuff; |
| 223 | apr_size_t len; |
| 224 | |
| 225 | /* read the data from the cache file */ |
| 226 | len = sizeof(disk_cache_info_t); |
| 227 | rv = apr_file_read_full(fd, &dobj->disk_info, len, &len); |
| 228 | if (rv != APR_SUCCESS) { |
| 229 | return rv; |
| 230 | } |
| 231 | |
| 232 | /* Store it away so we can get it later. */ |
| 233 | info->status = dobj->disk_info.status; |
| 234 | info->date = dobj->disk_info.date; |
| 235 | info->expire = dobj->disk_info.expire; |
| 236 | info->request_time = dobj->disk_info.request_time; |
| 237 | info->response_time = dobj->disk_info.response_time; |
| 238 | |
| 239 | memcpy(&info->control, &dobj->disk_info.control, sizeof(cache_control_t)); |
| 240 | |
| 241 | /* Note that we could optimize this by conditionally doing the palloc |
| 242 | * depending upon the size. */ |
| 243 | urlbuff = apr_palloc(r->pool, dobj->disk_info.name_len + 1); |
| 244 | len = dobj->disk_info.name_len; |
| 245 | rv = apr_file_read_full(fd, urlbuff, len, &len); |
| 246 | if (rv != APR_SUCCESS) { |
| 247 | return rv; |
| 248 | } |
| 249 | urlbuff[dobj->disk_info.name_len] = '\0'; |
| 250 | |
| 251 | /* check that we have the same URL */ |
| 252 | /* Would strncmp be correct? */ |
| 253 | if (strcmp(urlbuff, dobj->name) != 0) { |
| 254 | return APR_EGENERAL; |
| 255 | } |
| 256 | |
| 257 | return APR_SUCCESS; |
| 258 | } |
| 259 | |
| 260 | static const char* regen_key(apr_pool_t *p, apr_table_t *headers, |
| 261 | apr_array_header_t *varray, const char *oldkey) |