Throw an exception for possible file race condition
| From: | David Rodrigues | Date: | Wed, 05 Apr 2017 12:18:49 +0000 |
| Subject: | Throw an exception for possible file race condition | ||
| Groups: | php.internals | ||
| Request: | Send a blank email to internals+get-98732@lists.php.net to get a copy of this message | ||
Currently we should uses the @-operator on mkdir(), for instance, to check
a race condition. Something like:
if (!@mkdir('test')) {
throw new SomeException();
}
Should be fine if we can do something like that, instead:
try {
mkdir('test');
}
catch (FileExistsException $exception) {
throw new SomeException();
}
It will avoid the @-operator and make the result more reliable (for
instance, if you don't uses the @-operator in this case and is catched by a
race condition).
--
David Rodrigues