Improve the success rate when use mkdir() in multiprocessing environment (#7383)

Improve the success rate when use mkdir() in multiprocessing environment
This commit is contained in:
MARiA so cute 2021-08-18 18:34:04 +08:00 committed by GitHub
parent 0b98ac69d9
commit aec08cc841
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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));
}
@ -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;
}
}