]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Mark the manifest file as used on direct cache hit
authorJoel Rosdahl <joel@rosdahl.net>
Wed, 27 Mar 2019 20:46:49 +0000 (21:46 +0100)
committerJoel Rosdahl <joel@rosdahl.net>
Wed, 27 Mar 2019 20:46:49 +0000 (21:46 +0100)
Fixes #367.

doc/NEWS.adoc
src/ccache.c
test/run
test/suites/direct.bash

index cea25ef9ca35c9bd76916d1bcd6d9e1eda95f752..46f618dc9842e623eb808a7308245f73be6a28c6 100644 (file)
@@ -27,6 +27,10 @@ Changes
 * Fixed a bug in the “depend mode” where a manifest hash only could be
   associated with one set of header dependencies.
 
+* Manifest files did not get marked as used on direct cache hits, so the LRU
+  cache cleanup would incorrectly remove them eventually. This has now been
+  fixed.
+
 
 ccache 3.6
 ----------
index d0c378548c2a7807d5d0d4ff776a824ac11e5ed5..2a04ce7433bc5af3714ad97294d43ee7f404877a 100644 (file)
@@ -1303,7 +1303,6 @@ update_manifest_file(void)
        }
        if (manifest_put(manifest_path, cached_obj_hash, included_files)) {
                cc_log("Added object file hash to %s", manifest_path);
-               update_mtime(manifest_path);
                if (x_stat(manifest_path, &st) == 0) {
                        stats_update_size(file_size(&st) - old_size, old_size == 0 ? 1 : 0);
                }
@@ -2137,6 +2136,7 @@ calculate_object_hash(struct args *args, struct hash *hash, int direct_mode)
                object_hash = manifest_get(conf, manifest_path);
                if (object_hash) {
                        cc_log("Got object file hash from manifest");
+                       update_mtime(manifest_path);
                } else {
                        cc_log("Did not find object file hash in manifest");
                }
index fa607336243ce7e7489fe73801bf6e33ca444298..b4a96b471894cf736492227a50bcfd470442a304 100755 (executable)
--- a/test/run
+++ b/test/run
@@ -197,6 +197,15 @@ expect_file_count() {
     fi
 }
 
+# Verify that $1 is newer than (or same age as) $2.
+expect_file_newer_than() {
+    local newer_file=$1
+    local older_file=$2
+    if [ "$newer_file" -ot "$older_file" ]; then
+        test_failed "$newer_file is older than $older_file"
+    fi
+}
+
 run_suite() {
     local suite_name=$1
 
index f3025b139d8ac47c08b3da18b6accfcd1329894c..643471c1885c0724d021628b7f9567891d77c6bb 100644 (file)
@@ -36,12 +36,16 @@ SUITE_direct() {
     expect_stat 'files in cache' 2 # .o + .manifest
     expect_equal_object_files reference_test.o test.o
 
+    manifest_file=$(find $CCACHE_DIR -name '*.manifest')
+    backdate $manifest_file
+
     $CCACHE_COMPILE -c test.c
     expect_stat 'cache hit (direct)' 1
     expect_stat 'cache hit (preprocessed)' 0
     expect_stat 'cache miss' 1
     expect_stat 'files in cache' 2
     expect_equal_object_files reference_test.o test.o
+    expect_file_newer_than $manifest_file test.c
 
     # -------------------------------------------------------------------------
     TEST "Corrupt manifest file"