]> git.ipfire.org Git - thirdparty/ccache.git/commitdiff
Don't use locks for reading/writing the manifest from/to disk
authorJoel Rosdahl <joel@rosdahl.net>
Sun, 1 Aug 2010 13:57:54 +0000 (15:57 +0200)
committerJoel Rosdahl <joel@rosdahl.net>
Sun, 1 Aug 2010 15:20:33 +0000 (17:20 +0200)
Since the rename-into-place idiom is already used, a race between two
processes will only result in one lost entry, which is not a big deal, and
it's also very unlikely.

manifest.c

index 4518fab8c223403b6757d0bb5c17bc8f7ad40f1f..02cf980c47ab9a82421f0a9a21650010081e2d56 100644 (file)
@@ -551,10 +551,6 @@ struct file_hash *manifest_get(const char *manifest_path)
                /* Cache miss. */
                goto out;
        }
-       if (read_lock_fd(fd) == -1) {
-               cc_log("Failed to read lock manifest file");
-               goto out;
-       }
        f = gzdopen(fd, "rb");
        if (!f) {
                cc_log("Failed to gzdopen manifest file");
@@ -606,16 +602,17 @@ int manifest_put(const char *manifest_path, struct file_hash *object_hash,
        struct manifest *mf = NULL;
        char *tmp_file = NULL;
 
+       /*
+        * We don't bother to acquire a lock when writing the manifest to disk. A
+        * race between two processes will only result in one lost entry, which is
+        * not a big deal, and it's also very unlikely.
+        */
+
        fd1 = safe_open(manifest_path);
        if (fd1 == -1) {
                cc_log("Failed to open manifest file");
                goto out;
        }
-       if (write_lock_fd(fd1) == -1) {
-               cc_log("Failed to write lock manifest file");
-               close(fd1);
-               goto out;
-       }
        if (fstat(fd1, &st) != 0) {
                cc_log("Failed to stat manifest file");
                close(fd1);