Diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Share one lock-file helper between the caches
Diffstat (limited to 'source/cache.h')
-rw-r--r--source/cache.h10
1 file changed, 10 insertions, 0 deletions
diff --git a/source/cache.h b/source/cache.h
index b73a6f4..cfe1fbf 100644
--- a/source/cache.h
+++ b/source/cache.h
@@ -40,4 +40,14 @@ extern int cache_abandon_fill(void);
extern unsigned long cache_hash_str(const char *str);
+/*
+ * Open the lock file at path, creating it if need be, then lock it without
+ * waiting and empty it, leaving the descriptor in *fd. The lock holds until
+ * the last descriptor on the file closes, and the caller renames or removes
+ * the file before that. Returns 0, EAGAIN or EWOULDBLOCK when another process
+ * holds the lock or has renamed the file away, or the errno of the step that
+ * failed, which has been logged. *fd is -1 on failure.
+ */
+extern int cache_lock_file(const char *path, int *fd);
+
#endif // CGIT_CACHE_H