From bf4cd88262afbfcdae29266b51adc5f35901d09c Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sat, 31 Oct 2026 14:48:03 -0700 Subject: Share one lock-file helper between the caches --- source/cache.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'source/cache.h') 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 -- cgit 2.11.1