summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLibravatar Michael Haggerty <mhagger@alum.mit.edu>2014-01-18 23:49:00 +0100
committerLibravatar Junio C Hamano <gitster@pobox.com>2014-01-21 13:47:24 -0800
commitf1e9e9a4dbe2cfb39dcb14ee4f34628ef46d7b15 (patch)
treed283e1b1d0b55483f338eeaf32e40e5a99bab491
parentrename_tmp_log(): handle a possible mkdir/rmdir race (diff)
downloadtgif-f1e9e9a4dbe2cfb39dcb14ee4f34628ef46d7b15.tar.xz
rename_tmp_log(): limit the number of remote_empty_directories() attempts
This doesn't seem to be a likely error, but we've got the counter anyway, so we might as well use it for an added bit of safety. Please note that the first call to rename() is optimistic, and it is normal for it to fail if there is a directory in the way. So bump the total number of allowed attempts to 4, to be sure that we can still have at least 3 retries in the case of a race. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--refs.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/refs.c b/refs.c
index bbcdc88e41..fd644f0f41 100644
--- a/refs.c
+++ b/refs.c
@@ -2530,7 +2530,7 @@ int delete_ref(const char *refname, const unsigned char *sha1, int delopt)
static int rename_tmp_log(const char *newrefname)
{
- int attempts_remaining = 3;
+ int attempts_remaining = 4;
retry:
if (safe_create_leading_directories(git_path("logs/%s", newrefname))) {
@@ -2539,7 +2539,7 @@ static int rename_tmp_log(const char *newrefname)
}
if (rename(git_path(TMP_RENAMED_LOG), git_path("logs/%s", newrefname))) {
- if (errno==EISDIR || errno==ENOTDIR) {
+ if ((errno==EISDIR || errno==ENOTDIR) && --attempts_remaining > 0) {
/*
* rename(a, b) when b is an existing
* directory ought to result in ISDIR, but