BUG: locks not working as expected
Dieses Issue hat noch niemand übernommen.
- Vorherrschende Sprache
- C
- Sterne
- 40.4k
- Forks
- 8.2k
- Ø Merge
- 2 T. 13 Std.
- Gemergte PRs (30 T.)
- 96
Beschreibung
Description
The following code:
<?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
Beitragsleitfaden
Erste Schritte
- Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
- Forke das Repository und arbeite in einem Branch.
- Öffne einen Pull Request, der die Issue-Nummer nennt.
Rechercherichtung
Beginne damit, die Reproduktion mit zwei Tabs in test.php mit PHP 8.x auf den gemeldeten Umgebungen CentOS 9 Stream und Windows 11 auszuführen, wobei der Schwerpunkt auf flock mit LOCK_EX|LOCK_NB liegt. Verfolge den Einstiegspunkt von flock und das plattformspezifische Sperrverhalten; abgeschlossen ist die Aufgabe, wenn die erste Anfrage Yes meldet, während überlappende Anfragen sofort No zurückgeben, mit Abdeckung der bestätigten Umgebungen.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- php
- Bereich
- operating-systems
- Issue-Typ
- Bug
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Aktivitätsstatus
- Ruhig
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 48/100