Changes with Apache 2.3.0
[Remove entries to the current 2.0 and 2.2 section below, when backported]
+ *) mod_disk_cache: NULL fd pointers when closing them, fix missing
+ close/flush, remove some unneccessary code duplication instead
+ of calling the right helper in replace_brigade_with_cache().
+ [Niklas Edmundsson <nikke acc.umu.se>]
+
*) sendfile_nonblocking() takes the _brigade_ as an argument, gets
the first bucket from the brigade, finds it not to be a FILE
bucket and barfs. The fix is to pass a bucket rather than a brigade.
while(1) {
if(dobj->hfd) {
apr_file_close(dobj->hfd);
+ dobj->hfd = NULL;
}
rc = open_header(h, r, key, conf);
if(rc != APR_SUCCESS && rc != CACHE_ENODATA) {
}
apr_file_close(dobj->hfd);
+ dobj->hfd = NULL;
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"disk_cache: Recalled headers for URL %s", dobj->name);
rv = apr_file_open(&dobj->hfd, dobj->hdrsfile,
APR_WRITE | APR_BINARY | APR_BUFFERED, 0, r->pool);
if (rv != APR_SUCCESS) {
+ dobj->hfd = NULL;
return rv;
}
}
return rv;
}
+ /* If the body size is unknown, the header file will be rewritten later
+ so we can't close it */
+ if(dobj->initial_size < 0) {
+ rv = apr_file_flush(dobj->hfd);
+ }
+ else {
+ rv = apr_file_close(dobj->hfd);
+ dobj->hfd = NULL;
+ }
+ if(rv != APR_SUCCESS) {
+ return rv;
+ }
+
ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
"disk_cache: Stored headers for URL %s", dobj->name);
return APR_SUCCESS;
apr_bucket_brigade *bb)
{
apr_status_t rv;
- int flags;
apr_bucket *e;
- core_dir_config *pdcfg = ap_get_module_config(r->per_dir_config,
- &core_module);
disk_cache_object_t *dobj = (disk_cache_object_t *) h->cache_obj->vobj;
- flags = APR_READ|APR_BINARY;
-#if APR_HAS_SENDFILE
- flags |= ((pdcfg->enable_sendfile == ENABLE_SENDFILE_OFF)
- ? 0 : APR_SENDFILE_ENABLED);
-#endif
-
- rv = apr_file_open(&dobj->fd, dobj->datafile, flags, 0, r->pool);
+ if(dobj->fd) {
+ apr_file_close(dobj->fd);
+ dobj->fd = NULL;
+ }
+ rv = open_body_timeout(r, dobj->name, dobj);
if (rv != APR_SUCCESS) {
- ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
- "disk_cache: Error opening datafile %s for URL %s",
- dobj->datafile, dobj->name);
+ if(rv != CACHE_EDECLINED) {
+ ap_log_error(APLOG_MARK, APLOG_ERR, rv, r->server,
+ "disk_cache: Error opening datafile %s for URL %s",
+ dobj->datafile, dobj->name);
+ }
return rv;
}
/* All checks were fine, close output file */
rv = apr_file_close(dobj->fd);
+ dobj->fd = NULL;
if(rv != APR_SUCCESS) {
file_cache_errorcleanup(dobj, r);
return rv;
}
- ap_log_error(APLOG_MARK, APLOG_DEBUG, 0, r->server,
- "disk_cache: Body for URL %s cached.", dobj->name);
-
/* Redirect to cachefile if we copied a plain file */
if(copy_file) {
rv = replace_brigade_with_cache(h, r, bb);