summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-12-05 20:54:14 (GMT)
committerJunio C Hamano <gitster@pobox.com>2013-12-05 20:54:14 (GMT)
commit86cd8dc8e7b04e143bff4e61a7a036a989775507 (patch)
tree43b862f55627ffe883cae37a6f5e65904398cdf9 /sha1_file.c
parent5bb62059f21ebe8a38226f6fbe76f0f9b6ad65f7 (diff)
parentb2476a60bd92d89d85f16c3b614da54db2ebee1b (diff)
downloadgit-86cd8dc8e7b04e143bff4e61a7a036a989775507.zip
git-86cd8dc8e7b04e143bff4e61a7a036a989775507.tar.gz
git-86cd8dc8e7b04e143bff4e61a7a036a989775507.tar.bz2
Merge branch 'jh/loose-object-dirs-creation-race'
When two processes created one loose object file each, which fell into the same fan-out bucket that previously did not have any objects, they both tried to do an equivalent of mkdir .git/objects/$fanout && chmod $shared_perm .git/objects/$fanout before writing into their file .git/objects/$fanout/$remainder, one of which could have failed unnecessarily when the second invocation of mkdir found that the directory already has been created by the first one. * jh/loose-object-dirs-creation-race: sha1_file.c:create_tmpfile(): Fix race when creating loose object dirs
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 7dadd04..5f15223 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2857,7 +2857,9 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
/* Make sure the directory exists */
memcpy(buffer, filename, dirlen);
buffer[dirlen-1] = 0;
- if (mkdir(buffer, 0777) || adjust_shared_perm(buffer))
+ if (mkdir(buffer, 0777) && errno != EEXIST)
+ return -1;
+ if (adjust_shared_perm(buffer))
return -1;
/* Try again */