Skip to content

Commit

Permalink
Merge branch 'jh/loose-object-dirs-creation-race' into maint
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Junio C Hamano committed Dec 17, 2013
2 parents 4766036 + b2476a6 commit a5d5653
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sha1_file.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit a5d5653

Please sign in to comment.