rename_tmp_log(): on SCLD_VANISHED, retry
If safe_create_leading_directories() fails because a file along the path unexpectedly vanished, try again from the beginning. Try at most 4 times. Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Michael Haggerty committed
Jan 18, 2014 at 23:49 UTC
08f555cb82f92797ca0aa0d6ba32e6872f1331e5
1 file changed
+8
-1
refs.c
+8
-1
@@ -2533,7 +2533,14 @@ static int rename_tmp_log(const char *newrefname)
2533
int attempts_remaining = 4;
2534
2535
retry:
2536
- if (safe_create_leading_directories(git_path("logs/%s", newrefname))) {
2536
+ switch (safe_create_leading_directories(git_path("logs/%s", newrefname))) {
2537
+ case SCLD_OK:
2538
+ break; /* success */
2539
+ case SCLD_VANISHED:
2540
+ if (--attempts_remaining > 0)
2541
+ goto retry;
2542
+ /* fall through */
2543
+ default:
2544
error("unable to create directory for %s", newrefname);
2545
return -1;
2546
}