Skip to content

Commit

Permalink
Improve the success rate when use mkdir() in multiprocessing environm…
Browse files Browse the repository at this point in the history
…ent (php#7383)

Improve the success rate when use mkdir() in multiprocessing environment
  • Loading branch information
NathanFreeman authored Aug 18, 2021
1 parent 0b98ac6 commit aec08cc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion main/streams/plain_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -1414,7 +1414,7 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
}
while (true) {
int ret = VCWD_MKDIR(buf, (mode_t) mode);
if (ret < 0) {
if (ret < 0 && errno != EEXIST) {
if (options & REPORT_ERRORS) {
php_error_docref(NULL, E_WARNING, "%s", strerror(errno));
}
Expand All @@ -1433,6 +1433,13 @@ static int php_plain_files_mkdir(php_stream_wrapper *wrapper, const char *dir, i
}
if (p == e || !replaced_slash) {
/* No more directories to create */
/* issue a warning to client when the last directory was created failed */
if (ret < 0) {
if (options & REPORT_ERRORS) {
php_error_docref(NULL, E_WARNING, "%s", strerror(errno));
}
return 0;
}
return 1;
}
}
Expand Down

0 comments on commit aec08cc

Please sign in to comment.