this moves the apr_file_info_get on the data fd to recall_body. This saves a system call when we aren't going to serve the body (expired object, for example).

Question, in it's original place, we never handle the non success case, so I duplicated this behaviour here. We should probably handle this error and complain.

Also, if we stored the data length in the headers file and did not write out the headers until the body, we could save s system call on every cache hit...


--
Brian Akins
Lead Systems Engineer
CNN Internet Technologies
--- mod_disk_cache.c.orig       2006-01-18 13:44:55.000000000 -0500
+++ mod_disk_cache.c    2006-01-24 18:00:02.000000000 -0500
@@ -457,15 +487,11 @@
 #endif
     rc = apr_file_open(&dobj->fd, dobj->datafile, flags, 0, r->pool);
     if (rc != APR_SUCCESS) {
         /* XXX: Log message */
         return DECLINED;
     }
 
-    rc = apr_file_info_get(&finfo, APR_FINFO_SIZE, dobj->fd);
-    if (rc == APR_SUCCESS) {
-        dobj->file_size = finfo.size;
-    }
 
     /* Read the bytes to setup the cache_info fields */
     rc = file_cache_recall_mydata(dobj->mf, info, dobj, r);
     if (rc != APR_SUCCESS) {
@@ -756,7 +781,13 @@
 {
     apr_bucket *e;
     disk_cache_object_t *dobj = (disk_cache_object_t*) h->cache_obj->vobj;
+    apr_status_t rc;
+    apr_finfo_t finfo;
 
+    rc = apr_file_info_get(&finfo, APR_FINFO_SIZE, dobj->fd);
+    if (rc == APR_SUCCESS) {
+        dobj->file_size = finfo.size;
+    }
     e = apr_bucket_file_create(dobj->fd, 0, (apr_size_t) dobj->file_size, p,
                                bb->bucket_alloc);
     APR_BRIGADE_INSERT_HEAD(bb, e);

Reply via email to