I start 8 processes to execute a job, the code in the job like this:
<?php
$dir = "/home/test/fileputcontents/0";
if(! is_dir($dir)){
mkdir($dir, 0755, true);
}
file_put_contents("{$dir}/0.txt", "aaaa\n", FILE_APPEND | LOCK_EX);
but it raises an error which say "No such file or directory" sometimes,not very offen, thanks very much.
Is it because php_mkdir_ex method? Multi-process create directory at the same time.
/* DEPRECATED APIs: Use php_stream_mkdir() instead */
PHPAPI int php_mkdir_ex(const char *dir, zend_long mode, int options)
{
int ret;
if (php_check_open_basedir(dir)) {
return -1;
}
if ((ret = VCWD_MKDIR(dir, (mode_t)mode)) < 0 && (options & REPORT_ERRORS)) {
php_error_docref(NULL, E_WARNING, "%s", strerror(errno));
}
return ret;
}