Skip to content

Commit a5d5653

Browse files
committed
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
2 parents 4766036 + b2476a6 commit a5d5653

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

sha1_file.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2860,7 +2860,9 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
28602860
/* Make sure the directory exists */
28612861
memcpy(buffer, filename, dirlen);
28622862
buffer[dirlen-1] = 0;
2863-
if (mkdir(buffer, 0777) || adjust_shared_perm(buffer))
2863+
if (mkdir(buffer, 0777) && errno != EEXIST)
2864+
return -1;
2865+
if (adjust_shared_perm(buffer))
28642866
return -1;
28652867

28662868
/* Try again */

0 commit comments

Comments
 (0)