summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2013-12-17 11:32:50 -0800
committerJunio C Hamano <gitster@pobox.com>2013-12-17 11:32:50 -0800
commita5d56530e0788fa7ffcae129355ec1eb401621df (patch)
tree4fda678d738690432510c71b62e5366ffc80ac3e /sha1_file.c
parent4766036ecdee2d45b5a955409da5e6751c3e2f05 (diff)
parentb2476a60bd92d89d85f16c3b614da54db2ebee1b (diff)
downloadgit-a5d56530e0788fa7ffcae129355ec1eb401621df.tar.gz
Merge branch 'jh/loose-object-dirs-creation-race' into maint
Two processes creating loose objects at the same time could have failed unnecessarily when the name of their new objects started with the same byte value, due to a race condition. * 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 9ae98c852c..760dd60031 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -2860,7 +2860,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 */