[php-src] Issue #14592: BUG: locks not working as expected
| From: | batata004 | Date: | Tue, 18 Jun 2024 02:42:25 +0000 |
| Subject: | [php-src] Issue #14592: BUG: locks not working as expected | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-247108@lists.php.net to get a copy of this message | ||
Issue: https://github.com/php/php-src/issues/14592
Author: batata004
### Description
The following code:
```php
<?php
$arquivo_lock = fopen("test.txt","a");
if (flock($arquivo_lock,LOCK_EX|LOCK_NB)) {
echo "Yes";
} else {
echo "No";
}
sleep(10);
fclose($arquivo_lock);
?>
```
Save the simple code above to the file
test.php, for example. Now, in less than 10
seconds apart, open 2 (or more) tabs on your browser calling the file test.php and you
will see every tab will show you Yes after some seconds. It should show
Yes only on the first tab, all the other should return immediatly with No
because I am using LOCK_NB flag.
This bug is pretty simple to reproduce and other people also confirmed it on Stackoverflow when I
reported there.
### PHP Version
8.x
### Operating System
Confirmed at least on centos 9 stream and windows 11