国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Confused about the exclusive lock of PHP file lock?
曾經(jīng)蠟筆沒有小新
曾經(jīng)蠟筆沒有小新 2017-05-16 13:15:13
0
1
784

flock.php
<?php

$fp=fopen('lock.txt','a');

if (flock($fp,LOCK_EX)){

  fwrite($fp," HHHHHHHHHHHHHH".time()."\r\n");

}

?>
flock2.php
<?php

$fp=fopen('lock.txt','a');

if (flock($fp,LOCK_EX)){

  fwrite($fp," GGGGGGGGGGGGGG".time()."\r\n");

}

?>
Doubt:
Why is the flock.php file locked with an exclusive lock, but the lock is not released and the fclose file is not closed. But when executing flock2.php file, it can still be written.
Isn’t the exclusive lock of the file lock unable to be written by other processes after it is locked? Can I write again only when the lock is released?

曾經(jīng)蠟筆沒有小新
曾經(jīng)蠟筆沒有小新

reply all(1)
大家講道理

php is over after execution and the resources are released, and the lock will be released naturally

If you want to test, add an infinite loop to flock.php to ensure it never exits, and then execute flock2.php to see the effect

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template