From: Joel Rosdahl Date: Sun, 1 Aug 2010 13:57:54 +0000 (+0200) Subject: Don't use locks for reading/writing the manifest from/to disk X-Git-Tag: v3.1~121 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ca008ee79a6f48166a04aed15e2f9d45b1b04707;p=thirdparty%2Fccache.git Don't use locks for reading/writing the manifest from/to disk 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. --- diff --git a/manifest.c b/manifest.c index 4518fab8c..02cf980c4 100644 --- a/manifest.c +++ b/manifest.c @@ -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);