From: Michael Haggerty Date: Wed, 17 May 2017 12:05:31 GMT Subject: [PATCH 08/23] lockfile: add a new method, is_lock_file_locked() Message-ID: <70fbcd573f5c8a78a19a08ffc255437c36e7f49d.1495014840.git.mhagger@alum.mit.edu> In-Reply-To: It will soon prove useful. Signed-off-by: Michael Haggerty --- lockfile.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lockfile.h b/lockfile.h index 7b715f9e77..572064939c 100644 --- a/lockfile.h +++ b/lockfile.h @@ -175,6 +175,14 @@ static inline int hold_lock_file_for_update( return hold_lock_file_for_update_timeout(lk, path, flags, 0); } +/* + * Return a nonzero value iff `lk` is currently locked. + */ +static inline int is_lock_file_locked(struct lock_file *lk) +{ + return is_tempfile_active(&lk->tempfile); +} + /* * Append an appropriate error message to `buf` following the failure * of `hold_lock_file_for_update()` to lock `path`. `err` should be the -- 2.11.0