From aec08cc841a436a9a28468ce420e2f39adc3515a Mon Sep 17 00:00:00 2001 From: MARiA so cute <33935209+NathanFreeman@users.noreply.github.com> Date: Wed, 18 Aug 2021 18:34:04 +0800 Subject: [PATCH] Improve the success rate when use mkdir() in multiprocessing environment (#7383) Improve the success rate when use mkdir() in multiprocessing environment --- main/streams/plain_wrapper.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main/streams/plain_wrapper.c b/main/streams/plain_wrapper.c index 793779c1bca..f8c3d89aefa 100644 --- a/main/streams/plain_wrapper.c +++ b/main/streams/plain_wrapper.c @@ -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; } }