From 41dd4ffaf99532d8344c90a5b1a060ac1f73b232 Mon Sep 17 00:00:00 2001 From: Michael Haggerty Date: Wed, 1 Oct 2014 12:28:11 +0200 Subject: [PATCH] lockfile: unlock file if lockfile permissions cannot be adjusted If the call to adjust_shared_perm() fails, lock_file returns -1, which to the caller looks like any other failure to lock the file. So in this case, roll back the lockfile before returning so that the lock file is deleted immediately and the lockfile object is left in a predictable state (namely, unlocked). Previously, the lockfile was retained until process cleanup in this situation. Signed-off-by: Michael Haggerty Reviewed-by: Jonathan Nieder Signed-off-by: Junio C Hamano --- lockfile.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lockfile.c b/lockfile.c index 3df1e8306a..d74de8d329 100644 --- a/lockfile.c +++ b/lockfile.c @@ -153,6 +153,7 @@ static int lock_file(struct lock_file *lk, const char *path, int flags) int save_errno = errno; error("cannot fix permission bits on %s", lk->filename); + rollback_lock_file(lk); errno = save_errno; return -1; } -- 2.11.4.GIT